Fixed: (AnimeBytes) Ignore useless extensions to improve single file names

pull/1606/head
Bogdan 2 years ago
parent d3ca861aea
commit 025156978b

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Text;
@ -223,8 +224,6 @@ namespace NzbDrone.Core.Indexers.Definitions
public class AnimeBytesParser : IParseIndexerResponse public class AnimeBytesParser : IParseIndexerResponse
{ {
private readonly AnimeBytesSettings _settings;
private static readonly HashSet<string> ExcludedProperties = new (StringComparer.OrdinalIgnoreCase) { "Freeleech" }; private static readonly HashSet<string> ExcludedProperties = new (StringComparer.OrdinalIgnoreCase) { "Freeleech" };
private static readonly HashSet<string> RemuxResolutions = new (StringComparer.OrdinalIgnoreCase) { "1080i", "1080p", "2160p", "4K" }; private static readonly HashSet<string> RemuxResolutions = new (StringComparer.OrdinalIgnoreCase) { "1080i", "1080p", "2160p", "4K" };
private static readonly HashSet<string> CommonReleaseGroupsProperties = new (StringComparer.OrdinalIgnoreCase) private static readonly HashSet<string> CommonReleaseGroupsProperties = new (StringComparer.OrdinalIgnoreCase)
@ -234,6 +233,9 @@ namespace NzbDrone.Core.Indexers.Definitions
"RAW", "RAW",
"Translated" "Translated"
}; };
private static readonly HashSet<string> ExcludedFileExtensions = new (StringComparer.OrdinalIgnoreCase) { ".mka", ".mds", ".md5", ".nfo", ".sfv", ".ass", ".mks", ".srt", ".ssa", ".sup", ".jpeg", ".jpg", ".png", ".otf", ".ttf" };
private readonly AnimeBytesSettings _settings;
public AnimeBytesParser(AnimeBytesSettings settings) public AnimeBytesParser(AnimeBytesSettings settings)
{ {
@ -497,35 +499,45 @@ namespace NzbDrone.Core.Indexers.Definitions
var infoString = properties.Select(p => "[" + p + "]").Join(string.Empty); var infoString = properties.Select(p => "[" + p + "]").Join(string.Empty);
if (_settings.UseFilenameForSingleEpisodes && torrent.FileCount == 1) if (_settings.UseFilenameForSingleEpisodes)
{ {
var fileName = torrent.Files.First().FileName; var files = torrent.Files;
var guid = new Uri(details + "?nh=" + HashUtil.CalculateMd5(fileName)); if (files.Count > 1)
{
files = files.Where(f => !ExcludedFileExtensions.Contains(Path.GetExtension(f.FileName))).ToList();
}
var release = new TorrentInfo if (files.Count == 1)
{ {
MinimumRatio = 1, var fileName = files.First().FileName;
MinimumSeedTime = minimumSeedTime,
Title = fileName,
InfoUrl = details.AbsoluteUri,
Guid = guid.AbsoluteUri,
DownloadUrl = link.AbsoluteUri,
PublishDate = publishDate,
Categories = categories,
Description = description,
Size = size,
Seeders = seeders,
Peers = peers,
Grabs = snatched,
Files = fileCount,
DownloadVolumeFactor = rawDownMultiplier,
UploadVolumeFactor = rawUpMultiplier,
};
releaseInfos.Add(release); var guid = new Uri(details + "?nh=" + HashUtil.CalculateMd5(fileName));
continue; var release = new TorrentInfo
{
MinimumRatio = 1,
MinimumSeedTime = minimumSeedTime,
Title = fileName,
InfoUrl = details.AbsoluteUri,
Guid = guid.AbsoluteUri,
DownloadUrl = link.AbsoluteUri,
PublishDate = publishDate,
Categories = categories,
Description = description,
Size = size,
Seeders = seeders,
Peers = peers,
Grabs = snatched,
Files = fileCount,
DownloadVolumeFactor = rawDownMultiplier,
UploadVolumeFactor = rawUpMultiplier,
};
releaseInfos.Add(release);
continue;
}
} }
foreach (var title in synonyms) foreach (var title in synonyms)

Loading…
Cancel
Save