|
|
@ -1,4 +1,5 @@ |
|
|
|
using Bugsnag; |
|
|
|
using System.Collections.Immutable; |
|
|
|
|
|
|
|
using Bugsnag; |
|
|
|
using ErsatzTV.Core; |
|
|
|
using ErsatzTV.Core; |
|
|
|
using ErsatzTV.Core.Domain; |
|
|
|
using ErsatzTV.Core.Domain; |
|
|
|
using ErsatzTV.Core.Errors; |
|
|
|
using ErsatzTV.Core.Errors; |
|
|
@ -20,6 +21,7 @@ public class TelevisionFolderScanner : LocalFolderScanner, ITelevisionFolderScan |
|
|
|
private readonly IClient _client; |
|
|
|
private readonly IClient _client; |
|
|
|
private readonly IFallbackMetadataProvider _fallbackMetadataProvider; |
|
|
|
private readonly IFallbackMetadataProvider _fallbackMetadataProvider; |
|
|
|
private readonly ILibraryRepository _libraryRepository; |
|
|
|
private readonly ILibraryRepository _libraryRepository; |
|
|
|
|
|
|
|
private readonly IMediaItemRepository _mediaItemRepository; |
|
|
|
private readonly ILocalFileSystem _localFileSystem; |
|
|
|
private readonly ILocalFileSystem _localFileSystem; |
|
|
|
private readonly ILocalMetadataProvider _localMetadataProvider; |
|
|
|
private readonly ILocalMetadataProvider _localMetadataProvider; |
|
|
|
private readonly ILocalSubtitlesProvider _localSubtitlesProvider; |
|
|
|
private readonly ILocalSubtitlesProvider _localSubtitlesProvider; |
|
|
@ -60,6 +62,7 @@ public class TelevisionFolderScanner : LocalFolderScanner, ITelevisionFolderScan |
|
|
|
_localSubtitlesProvider = localSubtitlesProvider; |
|
|
|
_localSubtitlesProvider = localSubtitlesProvider; |
|
|
|
_metadataRepository = metadataRepository; |
|
|
|
_metadataRepository = metadataRepository; |
|
|
|
_libraryRepository = libraryRepository; |
|
|
|
_libraryRepository = libraryRepository; |
|
|
|
|
|
|
|
_mediaItemRepository = mediaItemRepository; |
|
|
|
_mediator = mediator; |
|
|
|
_mediator = mediator; |
|
|
|
_client = client; |
|
|
|
_client = client; |
|
|
|
_fallbackMetadataProvider = fallbackMetadataProvider; |
|
|
|
_fallbackMetadataProvider = fallbackMetadataProvider; |
|
|
@ -86,6 +89,8 @@ public class TelevisionFolderScanner : LocalFolderScanner, ITelevisionFolderScan |
|
|
|
await _libraryRepository.UpdatePath(libraryPath, normalizedLibraryPath); |
|
|
|
await _libraryRepository.UpdatePath(libraryPath, normalizedLibraryPath); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImmutableHashSet<string> allTrashedItems = await _mediaItemRepository.GetAllTrashedItems(libraryPath); |
|
|
|
|
|
|
|
|
|
|
|
var allShowFolders = _localFileSystem.ListSubdirectories(libraryPath.Path) |
|
|
|
var allShowFolders = _localFileSystem.ListSubdirectories(libraryPath.Path) |
|
|
|
.Filter(ShouldIncludeFolder) |
|
|
|
.Filter(ShouldIncludeFolder) |
|
|
|
.OrderBy(identity) |
|
|
|
.OrderBy(identity) |
|
|
@ -153,6 +158,7 @@ public class TelevisionFolderScanner : LocalFolderScanner, ITelevisionFolderScan |
|
|
|
ffprobePath, |
|
|
|
ffprobePath, |
|
|
|
result.Item, |
|
|
|
result.Item, |
|
|
|
showFolder, |
|
|
|
showFolder, |
|
|
|
|
|
|
|
allTrashedItems, |
|
|
|
cancellationToken); |
|
|
|
cancellationToken); |
|
|
|
|
|
|
|
|
|
|
|
foreach (ScanCanceled error in scanResult.LeftToSeq().OfType<ScanCanceled>()) |
|
|
|
foreach (ScanCanceled error in scanResult.LeftToSeq().OfType<ScanCanceled>()) |
|
|
@ -227,6 +233,7 @@ public class TelevisionFolderScanner : LocalFolderScanner, ITelevisionFolderScan |
|
|
|
string ffprobePath, |
|
|
|
string ffprobePath, |
|
|
|
Show show, |
|
|
|
Show show, |
|
|
|
string showFolder, |
|
|
|
string showFolder, |
|
|
|
|
|
|
|
ImmutableHashSet<string> allTrashedItems, |
|
|
|
CancellationToken cancellationToken) |
|
|
|
CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (string seasonFolder in _localFileSystem.ListSubdirectories(showFolder).Filter(ShouldIncludeFolder) |
|
|
|
foreach (string seasonFolder in _localFileSystem.ListSubdirectories(showFolder).Filter(ShouldIncludeFolder) |
|
|
@ -248,8 +255,16 @@ public class TelevisionFolderScanner : LocalFolderScanner, ITelevisionFolderScan |
|
|
|
// skip folder if etag matches
|
|
|
|
// skip folder if etag matches
|
|
|
|
if (knownFolder.Etag == etag) |
|
|
|
if (knownFolder.Etag == etag) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (allTrashedItems.Any(f => f.StartsWith(seasonFolder, StringComparison.OrdinalIgnoreCase))) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_logger.LogDebug("Previously trashed items are now present in folder {Folder}", seasonFolder); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// etag matches and no trashed items are now present, continue to next folder
|
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Option<int> maybeSeasonNumber = _fallbackMetadataProvider.GetSeasonNumberForFolder(seasonFolder); |
|
|
|
Option<int> maybeSeasonNumber = _fallbackMetadataProvider.GetSeasonNumberForFolder(seasonFolder); |
|
|
|
foreach (int seasonNumber in maybeSeasonNumber) |
|
|
|
foreach (int seasonNumber in maybeSeasonNumber) |
|
|
|