Backport pull request #11935 from jellyfin/release-10.9.z

Fix dateadded and movie NFO recognition

Original-merge: 0c039145e5fae917f2d8969322a541880bbb23c1

Merged-by: joshuaboniface <joshua@boniface.me>

Backported-by: Joshua M. Boniface <joshua@boniface.me>
This commit is contained in:
Shadowghost 2024-06-05 17:02:56 -04:00 committed by Joshua M. Boniface
parent a705e56acc
commit c554321495
3 changed files with 12 additions and 12 deletions

View File

@ -763,7 +763,7 @@ namespace MediaBrowser.Providers.Manager
else else
{ {
var shouldReplace = options.MetadataRefreshMode > MetadataRefreshMode.ValidationOnly || options.ReplaceAllMetadata; var shouldReplace = options.MetadataRefreshMode > MetadataRefreshMode.ValidationOnly || options.ReplaceAllMetadata;
MergeData(temp, metadata, item.LockedFields, shouldReplace, false); MergeData(temp, metadata, item.LockedFields, shouldReplace, true);
} }
} }
} }

View File

@ -45,27 +45,24 @@ namespace MediaBrowser.XbmcMetadata.Savers
internal static IEnumerable<string> GetMovieSavePaths(ItemInfo item) internal static IEnumerable<string> GetMovieSavePaths(ItemInfo item)
{ {
var path = item.ContainingFolderPath;
if (item.VideoType == VideoType.Dvd && !item.IsPlaceHolder) if (item.VideoType == VideoType.Dvd && !item.IsPlaceHolder)
{ {
var path = item.ContainingFolderPath;
yield return Path.Combine(path, "VIDEO_TS", "VIDEO_TS.nfo"); yield return Path.Combine(path, "VIDEO_TS", "VIDEO_TS.nfo");
} }
// only allow movie object to read movie.nfo, not owned videos (which will be itemtype video, not movie)
if (!item.IsInMixedFolder && item.ItemType == typeof(Movie))
{
yield return Path.Combine(path, "movie.nfo");
}
if (!item.IsPlaceHolder && (item.VideoType == VideoType.Dvd || item.VideoType == VideoType.BluRay)) if (!item.IsPlaceHolder && (item.VideoType == VideoType.Dvd || item.VideoType == VideoType.BluRay))
{ {
var path = item.ContainingFolderPath;
yield return Path.Combine(path, Path.GetFileName(path) + ".nfo"); yield return Path.Combine(path, Path.GetFileName(path) + ".nfo");
} }
else else
{ {
// only allow movie object to read movie.nfo, not owned videos (which will be itemtype video, not movie)
if (!item.IsInMixedFolder && item.ItemType == typeof(Movie))
{
yield return Path.Combine(item.ContainingFolderPath, "movie.nfo");
}
yield return Path.ChangeExtension(item.Path, ".nfo"); yield return Path.ChangeExtension(item.Path, ".nfo");
} }
} }

View File

@ -47,6 +47,7 @@ namespace Jellyfin.XbmcMetadata.Tests.Location
var movie = new Movie() { Path = "/media/movies/Avengers Endgame", VideoType = VideoType.Dvd }; var movie = new Movie() { Path = "/media/movies/Avengers Endgame", VideoType = VideoType.Dvd };
var path1 = "/media/movies/Avengers Endgame/Avengers Endgame.nfo"; var path1 = "/media/movies/Avengers Endgame/Avengers Endgame.nfo";
var path2 = "/media/movies/Avengers Endgame/VIDEO_TS/VIDEO_TS.nfo"; var path2 = "/media/movies/Avengers Endgame/VIDEO_TS/VIDEO_TS.nfo";
var path3 = "/media/movies/Avengers Endgame/movie.nfo";
// uses ContainingFolderPath which uses Operating system specific paths // uses ContainingFolderPath which uses Operating system specific paths
if (OperatingSystem.IsWindows()) if (OperatingSystem.IsWindows())
@ -54,12 +55,14 @@ namespace Jellyfin.XbmcMetadata.Tests.Location
movie.Path = movie.Path.Replace('/', '\\'); movie.Path = movie.Path.Replace('/', '\\');
path1 = path1.Replace('/', '\\'); path1 = path1.Replace('/', '\\');
path2 = path2.Replace('/', '\\'); path2 = path2.Replace('/', '\\');
path3 = path3.Replace('/', '\\');
} }
var paths = MovieNfoSaver.GetMovieSavePaths(new ItemInfo(movie)).ToArray(); var paths = MovieNfoSaver.GetMovieSavePaths(new ItemInfo(movie)).ToArray();
Assert.Equal(2, paths.Length); Assert.Equal(3, paths.Length);
Assert.Contains(path1, paths); Assert.Contains(path1, paths);
Assert.Contains(path2, paths); Assert.Contains(path2, paths);
Assert.Contains(path3, paths);
} }
} }
} }