mirror of
https://github.com/Sonarr/Sonarr
synced 2025-12-06 08:28:37 +01:00
New: Ignore extra files in theme-music and backdrop folders
Closes #8195
This commit is contained in:
parent
d4f14246f1
commit
7284898c7d
3 changed files with 48 additions and 1 deletions
|
|
@ -90,6 +90,7 @@ public void should_return_video_files_only()
|
|||
[TestCase(".secret")]
|
||||
[TestCase(".hidden")]
|
||||
[TestCase(".unwanted")]
|
||||
[TestCase("theme-music")]
|
||||
public void should_filter_certain_sub_folders(string subFolder)
|
||||
{
|
||||
var path = @"C:\Test\";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Extras.Files;
|
||||
using NzbDrone.Core.Extras.Others;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Housekeeping.Housekeepers
|
||||
{
|
||||
public class CleanupExtraFilesInExcludedFolders : IHousekeepingTask
|
||||
{
|
||||
private readonly IExtraFileRepository<OtherExtraFile> _extraFileRepository;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly IDiskScanService _diskScanService;
|
||||
|
||||
public CleanupExtraFilesInExcludedFolders(IExtraFileRepository<OtherExtraFile> extraFileRepository, ISeriesService seriesService, IDiskScanService diskScanService)
|
||||
{
|
||||
_extraFileRepository = extraFileRepository;
|
||||
_seriesService = seriesService;
|
||||
_diskScanService = diskScanService;
|
||||
}
|
||||
|
||||
public void Clean()
|
||||
{
|
||||
var allSeries = _seriesService.GetAllSeries();
|
||||
|
||||
foreach (var series in allSeries)
|
||||
{
|
||||
var extraFiles = _extraFileRepository.GetFilesBySeries(series.Id);
|
||||
var filteredExtraFiles = _diskScanService.FilterPaths(series.Path, extraFiles.Select(e => Path.Combine(series.Path, e.RelativePath)));
|
||||
|
||||
if (filteredExtraFiles.Count == extraFiles.Count)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var excludedExtraFiles = extraFiles.Where(e => !filteredExtraFiles.Contains(Path.Combine(e.RelativePath))).ToList();
|
||||
|
||||
if (excludedExtraFiles.Any())
|
||||
{
|
||||
_extraFileRepository.DeleteMany(excludedExtraFiles.Select(e => e.Id));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ public DiskScanService(IDiskProvider diskProvider,
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
private static readonly Regex ExcludedExtrasSubFolderRegex = new Regex(@"(?:\\|\/|^)(?:extras|extrafanart|behind the scenes|deleted scenes|featurettes|interviews|other|scenes|samples|shorts|trailers)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex ExcludedExtrasSubFolderRegex = new Regex(@"(?:\\|\/|^)(?:extras|extrafanart|behind the scenes|deleted scenes|featurettes|interviews|other|scenes|samples|shorts|trailers|theme[-_. ]music|backdrops)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex ExcludedSubFoldersRegex = new Regex(@"(?:\\|\/|^)(?:@eadir|\.@__thumb|plex versions|\.[^\\/]+)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex ExcludedExtraFilesRegex = new Regex(@"(-(trailer|other|behindthescenes|deleted|featurette|interview|scene|short)\.[^.]+$)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex ExcludedFilesRegex = new Regex(@"^\.(_|unmanic|DS_Store$)|^Thumbs\.db$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
|
|
|||
Loading…
Reference in a new issue