aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Library
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-12-01 13:42:07 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-12-01 13:42:07 -0500
commitc48458f215bd5ea1da3ef3636f801a4652e77aa0 (patch)
tree9572d1f4ca5aaeb0214f1febbf6d0fce49375ff1 /MediaBrowser.Server.Implementations/Library
parentdc8fb33a1f5ad474fed88d58a19c1098c68b815f (diff)
parentcbf1bca2ea25c63bd10d167f170cc10bb23e2496 (diff)
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Conflicts: SharedVersion.cs
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library')
-rw-r--r--MediaBrowser.Server.Implementations/Library/LibraryManager.cs108
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs2
6 files changed, 113 insertions, 5 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
index 81751545c..dfddae24d 100644
--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
@@ -1736,5 +1736,113 @@ namespace MediaBrowser.Server.Implementations.Library
return new List<FileSystemInfo>();
}
+
+ public IEnumerable<Trailer> FindTrailers(BaseItem owner, List<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService)
+ {
+ var files = fileSystemChildren.OfType<DirectoryInfo>()
+ .Where(i => string.Equals(i.Name, BaseItem.TrailerFolderName, StringComparison.OrdinalIgnoreCase))
+ .SelectMany(i => i.EnumerateFiles("*", SearchOption.TopDirectoryOnly))
+ .ToList();
+
+ var extraTypes = new List<ExtraType> { ExtraType.Trailer };
+ var suffixes = BaseItem.ExtraSuffixes.Where(i => extraTypes.Contains(i.Value))
+ .Select(i => i.Key)
+ .ToList();
+
+ files.AddRange(fileSystemChildren.OfType<FileInfo>()
+ .Where(i =>
+ {
+ var nameEithoutExtension = _fileSystem.GetFileNameWithoutExtension(i);
+
+ if (!suffixes.Any(s => nameEithoutExtension.EndsWith(s, StringComparison.OrdinalIgnoreCase)))
+ {
+ return false;
+ }
+
+ return !string.Equals(owner.Path, i.FullName, StringComparison.OrdinalIgnoreCase);
+ }));
+
+ return ResolvePaths<Trailer>(files, directoryService, null).Select(video =>
+ {
+ // Try to retrieve it from the db. If we don't find it, use the resolved version
+ var dbItem = GetItemById(video.Id) as Trailer;
+
+ if (dbItem != null)
+ {
+ video = dbItem;
+ }
+
+ if (video != null)
+ {
+ video.ExtraType = ExtraType.Trailer;
+ }
+
+ return video;
+
+ // Sort them so that the list can be easily compared for changes
+ }).OrderBy(i => i.Path).ToList();
+ }
+
+ public IEnumerable<Video> FindExtras(BaseItem owner, List<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService)
+ {
+ var files = fileSystemChildren.OfType<DirectoryInfo>()
+ .Where(i => string.Equals(i.Name, "extras", StringComparison.OrdinalIgnoreCase) || string.Equals(i.Name, "specials", StringComparison.OrdinalIgnoreCase))
+ .SelectMany(i => i.EnumerateFiles("*", SearchOption.TopDirectoryOnly))
+ .ToList();
+
+ var extraTypes = new List<ExtraType> { ExtraType.BehindTheScenes, ExtraType.DeletedScene, ExtraType.Interview, ExtraType.Sample, ExtraType.Scene, ExtraType.Clip };
+ var suffixes = BaseItem.ExtraSuffixes.Where(i => extraTypes.Contains(i.Value))
+ .Select(i => i.Key)
+ .ToList();
+
+ files.AddRange(fileSystemChildren.OfType<FileInfo>()
+ .Where(i =>
+ {
+ var nameEithoutExtension = _fileSystem.GetFileNameWithoutExtension(i);
+
+ if (!suffixes.Any(s => nameEithoutExtension.EndsWith(s, StringComparison.OrdinalIgnoreCase)))
+ {
+ return false;
+ }
+
+ return !string.Equals(owner.Path, i.FullName, StringComparison.OrdinalIgnoreCase);
+ }));
+
+ return ResolvePaths<Video>(files, directoryService, null).Select(video =>
+ {
+ // Try to retrieve it from the db. If we don't find it, use the resolved version
+ var dbItem = GetItemById(video.Id) as Video;
+
+ if (dbItem != null)
+ {
+ video = dbItem;
+ }
+
+ if (video != null)
+ {
+ SetExtraTypeFromFilename(video);
+ }
+
+ return video;
+
+ // Sort them so that the list can be easily compared for changes
+ }).OrderBy(i => i.Path).ToList();
+ }
+
+ private void SetExtraTypeFromFilename(Video item)
+ {
+ var name = System.IO.Path.GetFileNameWithoutExtension(item.Path) ?? string.Empty;
+
+ foreach (var suffix in BaseItem.ExtraSuffixes)
+ {
+ if (name.EndsWith(suffix.Key, StringComparison.OrdinalIgnoreCase))
+ {
+ item.ExtraType = suffix.Value;
+ return;
+ }
+ }
+
+ item.ExtraType = ExtraType.Clip;
+ }
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs
index 575ffec14..60116ac61 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs
@@ -32,7 +32,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- return _libraryManager.ValidateArtists(cancellationToken, progress);
+ return ((LibraryManager)_libraryManager).ValidateArtists(cancellationToken, progress);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs
index 097e94216..ae6c863a7 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs
@@ -32,7 +32,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- return _libraryManager.ValidateGameGenres(cancellationToken, progress);
+ return ((LibraryManager)_libraryManager).ValidateGameGenres(cancellationToken, progress);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs
index d7add8574..f1d0ef370 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs
@@ -29,7 +29,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- return _libraryManager.ValidateGenres(cancellationToken, progress);
+ return ((LibraryManager)_libraryManager).ValidateGenres(cancellationToken, progress);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs
index da378228a..280dd90f4 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs
@@ -32,7 +32,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- return _libraryManager.ValidateMusicGenres(cancellationToken, progress);
+ return ((LibraryManager)_libraryManager).ValidateMusicGenres(cancellationToken, progress);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs
index a3a8b8678..0f998b070 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs
@@ -32,7 +32,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- return _libraryManager.ValidateStudios(cancellationToken, progress);
+ return ((LibraryManager)_libraryManager).ValidateStudios(cancellationToken, progress);
}
}
}