Browse Source

修复,emby 内置路径与本程序读取到的 movie 和 series 路径的映射逻辑;

Signed-off-by: allan716 <[email protected]>
allan716 4 years ago
parent
commit
f6906c607f
1 changed files with 10 additions and 3 deletions
  1. 10 3
      internal/logic/emby_helper/embyhelper.go

+ 10 - 3
internal/logic/emby_helper/embyhelper.go

@@ -131,18 +131,25 @@ func (em *EmbyHelper) filterEmbyVideoList(videoFolderName string, videoIdList []
 			if len(mixInfo.Ancestors) < 2 {
 			if len(mixInfo.Ancestors) < 2 {
 				return nil, err
 				return nil, err
 			}
 			}
+
 			// 过滤掉不符合要求的
 			// 过滤掉不符合要求的
-			if mixInfo.Ancestors[0].Name != videoFolderName || mixInfo.Ancestors[0].Type != "Folder" {
+			ancestorsCount := len(mixInfo.Ancestors)
+			usefulAncestorIndex := ancestorsCount - 2
+			if mixInfo.Ancestors[usefulAncestorIndex].Name != videoFolderName || mixInfo.Ancestors[usefulAncestorIndex].Type != "Folder" {
 				return nil, err
 				return nil, err
 			}
 			}
+
 			// 这个电影的文件夹
 			// 这个电影的文件夹
 			mixInfo.VideoFolderName = filepath.Base(filepath.Dir(mixInfo.VideoInfo.Path))
 			mixInfo.VideoFolderName = filepath.Base(filepath.Dir(mixInfo.VideoInfo.Path))
 			mixInfo.VideoFileName = filepath.Base(mixInfo.VideoInfo.Path)
 			mixInfo.VideoFileName = filepath.Base(mixInfo.VideoInfo.Path)
-			mixInfo.VideoFileRelativePath = filepath.Join(mixInfo.VideoFolderName, mixInfo.VideoFileName)
+			// 这里需要注意,仅仅这样是不能够解决嵌套文件夹问题的。
+			//mixInfo.VideoFileRelativePath = filepath.Join(mixInfo.VideoFolderName, mixInfo.VideoFileName)
+			// 需要从上面得到的 Ancestors 对应的“电影”根目录的 index 处,拿到 Path,然后用 info 这个实例的 Path 剪掉前面那个 Path,就是相对路径了
+			mixInfo.VideoFileRelativePath = strings.ReplaceAll(info.Path, mixInfo.Ancestors[usefulAncestorIndex].Path, "")
 		} else {
 		} else {
 			// 连续剧
 			// 连续剧
 			// 过滤掉不符合要求的
 			// 过滤掉不符合要求的
-			if len(mixInfo.Ancestors) < 3 {
+			if len(mixInfo.Ancestors) < 4 {
 				return nil, err
 				return nil, err
 			}
 			}
 			// 过滤掉不符合要求的
 			// 过滤掉不符合要求的