mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
animebytes: code clean up (#10080)
This commit is contained in:
@@ -15,6 +15,7 @@ using Jackett.Common.Utils;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using WebClient = Jackett.Common.Utils.Clients.WebClient;
|
||||||
|
|
||||||
namespace Jackett.Common.Indexers
|
namespace Jackett.Common.Indexers
|
||||||
{
|
{
|
||||||
@@ -22,20 +23,16 @@ namespace Jackett.Common.Indexers
|
|||||||
public class AnimeBytes : BaseCachingWebIndexer
|
public class AnimeBytes : BaseCachingWebIndexer
|
||||||
{
|
{
|
||||||
private string ScrapeUrl => SiteLink + "scrape.php";
|
private string ScrapeUrl => SiteLink + "scrape.php";
|
||||||
public bool AllowRaws => configData.IncludeRaw.Value;
|
private bool AllowRaws => ConfigData.IncludeRaw.Value;
|
||||||
public bool PadEpisode => configData.PadEpisode != null && configData.PadEpisode.Value;
|
private bool PadEpisode => ConfigData.PadEpisode != null && ConfigData.PadEpisode.Value;
|
||||||
public bool AddJapaneseTitle => configData.AddJapaneseTitle.Value;
|
private bool AddJapaneseTitle => ConfigData.AddJapaneseTitle.Value;
|
||||||
public bool AddRomajiTitle => configData.AddRomajiTitle.Value;
|
private bool AddRomajiTitle => ConfigData.AddRomajiTitle.Value;
|
||||||
public bool AddAlternativeTitles => configData.AddAlternativeTitles.Value;
|
private bool AddAlternativeTitles => ConfigData.AddAlternativeTitles.Value;
|
||||||
public bool FilterSeasonEpisode => configData.FilterSeasonEpisode.Value;
|
private bool FilterSeasonEpisode => ConfigData.FilterSeasonEpisode.Value;
|
||||||
|
|
||||||
private new ConfigurationDataAnimeBytes configData
|
private ConfigurationDataAnimeBytes ConfigData => (ConfigurationDataAnimeBytes)configData;
|
||||||
{
|
|
||||||
get => (ConfigurationDataAnimeBytes)base.configData;
|
|
||||||
set => base.configData = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AnimeBytes(IIndexerConfigurationService configService, Utils.Clients.WebClient client, Logger l, IProtectionService ps)
|
public AnimeBytes(IIndexerConfigurationService configService, WebClient client, Logger l, IProtectionService ps)
|
||||||
: base(id: "animebytes",
|
: base(id: "animebytes",
|
||||||
name: "AnimeBytes",
|
name: "AnimeBytes",
|
||||||
description: "Powered by Tentacles",
|
description: "Powered by Tentacles",
|
||||||
@@ -86,25 +83,18 @@ namespace Jackett.Common.Indexers
|
|||||||
AddCategoryMapping("printedtype[manhwa]", TorznabCatType.BooksComics, "Manhwa");
|
AddCategoryMapping("printedtype[manhwa]", TorznabCatType.BooksComics, "Manhwa");
|
||||||
AddCategoryMapping("printedtype[light_novel]", TorznabCatType.BooksComics, "Light Novel");
|
AddCategoryMapping("printedtype[light_novel]", TorznabCatType.BooksComics, "Light Novel");
|
||||||
AddCategoryMapping("printedtype[artbook]", TorznabCatType.BooksComics, "Artbook");
|
AddCategoryMapping("printedtype[artbook]", TorznabCatType.BooksComics, "Artbook");
|
||||||
|
|
||||||
}
|
}
|
||||||
// Prevent filtering
|
|
||||||
protected override IEnumerable<ReleaseInfo> FilterResults(TorznabQuery query, IEnumerable<ReleaseInfo> input) =>
|
|
||||||
|
|
||||||
input;
|
|
||||||
|
|
||||||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||||
{
|
{
|
||||||
LoadValuesFromJson(configJson);
|
LoadValuesFromJson(configJson);
|
||||||
|
|
||||||
if (configData.Passkey.Value.Length != 32 && configData.Passkey.Value.Length != 48)
|
if (ConfigData.Passkey.Value.Length != 32 && ConfigData.Passkey.Value.Length != 48)
|
||||||
throw new Exception("invalid passkey configured: expected length: 32 or 48, got " + configData.Passkey.Value.Length.ToString());
|
throw new Exception("invalid passkey configured: expected length: 32 or 48, got " + ConfigData.Passkey.Value.Length);
|
||||||
|
|
||||||
var results = await PerformQuery(new TorznabQuery());
|
var results = await PerformQuery(new TorznabQuery());
|
||||||
if (results.Count() == 0)
|
if (!results.Any())
|
||||||
{
|
|
||||||
throw new Exception("no results found, please report this bug");
|
throw new Exception("no results found, please report this bug");
|
||||||
}
|
|
||||||
|
|
||||||
IsConfigured = true;
|
IsConfigured = true;
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
@@ -122,21 +112,14 @@ namespace Jackett.Common.Indexers
|
|||||||
|
|
||||||
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||||
{
|
{
|
||||||
// The result list
|
|
||||||
var releases = new List<ReleaseInfo>();
|
var releases = new List<ReleaseInfo>();
|
||||||
|
|
||||||
if (ContainsMusicCategories(query.Categories))
|
if (ContainsMusicCategories(query.Categories))
|
||||||
{
|
releases.AddRange(await GetResults(query, "music", query.SanitizedSearchTerm));
|
||||||
foreach (var result in await GetResults(query, "music", query.SanitizedSearchTerm))
|
|
||||||
{
|
|
||||||
releases.Add(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var result in await GetResults(query, "anime", StripEpisodeNumber(query.SanitizedSearchTerm)))
|
releases.AddRange(
|
||||||
{
|
await GetResults(query, "anime", StripEpisodeNumber(query.SanitizedSearchTerm))
|
||||||
releases.Add(result);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
return releases.ToArray();
|
return releases.ToArray();
|
||||||
}
|
}
|
||||||
@@ -157,24 +140,21 @@ namespace Jackett.Common.Indexers
|
|||||||
|
|
||||||
private async Task<IEnumerable<ReleaseInfo>> GetResults(TorznabQuery query, string searchType, string searchTerm)
|
private async Task<IEnumerable<ReleaseInfo>> GetResults(TorznabQuery query, string searchType, string searchTerm)
|
||||||
{
|
{
|
||||||
// The result list
|
|
||||||
var releases = new List<ReleaseInfo>();
|
var releases = new List<ReleaseInfo>();
|
||||||
|
|
||||||
var queryCollection = new NameValueCollection();
|
var queryCollection = new NameValueCollection
|
||||||
|
{
|
||||||
|
{"username", ConfigData.Username.Value},
|
||||||
|
{"torrent_pass", ConfigData.Passkey.Value},
|
||||||
|
{"type", searchType},
|
||||||
|
{"searchstr", searchTerm}
|
||||||
|
};
|
||||||
|
|
||||||
var queryCats = MapTorznabCapsToTrackers(query);
|
var queryCats = MapTorznabCapsToTrackers(query);
|
||||||
if (queryCats.Count > 0)
|
if (queryCats.Count > 0)
|
||||||
{
|
|
||||||
foreach (var cat in queryCats)
|
foreach (var cat in queryCats)
|
||||||
{
|
|
||||||
queryCollection.Add(cat, "1");
|
queryCollection.Add(cat, "1");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
queryCollection.Add("username", configData.Username.Value);
|
|
||||||
queryCollection.Add("torrent_pass", configData.Passkey.Value);
|
|
||||||
queryCollection.Add("type", searchType);
|
|
||||||
queryCollection.Add("searchstr", searchTerm);
|
|
||||||
var queryUrl = ScrapeUrl + "?" + queryCollection.GetQueryString();
|
var queryUrl = ScrapeUrl + "?" + queryCollection.GetQueryString();
|
||||||
|
|
||||||
// Check cache first so we don't query the server for each episode when searching for each episode in a series.
|
// Check cache first so we don't query the server for each episode when searching for each episode in a series.
|
||||||
@@ -191,7 +171,7 @@ namespace Jackett.Common.Indexers
|
|||||||
// Get the content from the tracker
|
// Get the content from the tracker
|
||||||
var response = await RequestWithCookiesAndRetryAsync(queryUrl);
|
var response = await RequestWithCookiesAndRetryAsync(queryUrl);
|
||||||
if (!response.ContentString.StartsWith("{")) // not JSON => error
|
if (!response.ContentString.StartsWith("{")) // not JSON => error
|
||||||
throw new ExceptionWithConfigData("unexcepted response (not JSON)", configData);
|
throw new ExceptionWithConfigData("Unexpected response (not JSON)", ConfigData);
|
||||||
var json = JsonConvert.DeserializeObject<dynamic>(response.ContentString);
|
var json = JsonConvert.DeserializeObject<dynamic>(response.ContentString);
|
||||||
|
|
||||||
// Parse
|
// Parse
|
||||||
@@ -200,24 +180,23 @@ namespace Jackett.Common.Indexers
|
|||||||
if (json["error"] != null)
|
if (json["error"] != null)
|
||||||
throw new Exception(json["error"].ToString());
|
throw new Exception(json["error"].ToString());
|
||||||
|
|
||||||
var Matches = (long)json["Matches"];
|
var matches = (long)json["Matches"];
|
||||||
|
|
||||||
if (Matches > 0)
|
if (matches > 0)
|
||||||
{
|
{
|
||||||
var groups = (JArray)json.Groups;
|
var groups = (JArray)json.Groups;
|
||||||
|
|
||||||
foreach (JObject group in groups)
|
foreach (var group in groups)
|
||||||
{
|
{
|
||||||
var synonyms = new List<string>();
|
var synonyms = new List<string>();
|
||||||
var groupID = (long)group["ID"];
|
var image = (string)group["Image"];
|
||||||
var Image = (string)group["Image"];
|
var imageUrl = (string.IsNullOrWhiteSpace(image) ? null : new Uri(image));
|
||||||
var ImageUrl = (string.IsNullOrWhiteSpace(Image) ? null : new Uri(Image));
|
var year = (int)group["Year"];
|
||||||
var Year = (int)group["Year"];
|
var groupName = (string)group["GroupName"];
|
||||||
var GroupName = (string)group["GroupName"];
|
var seriesName = (string)group["SeriesName"];
|
||||||
var SeriesName = (string)group["SeriesName"];
|
|
||||||
var mainTitle = WebUtility.HtmlDecode((string)group["FullName"]);
|
var mainTitle = WebUtility.HtmlDecode((string)group["FullName"]);
|
||||||
if (SeriesName != null)
|
if (seriesName != null)
|
||||||
mainTitle = SeriesName;
|
mainTitle = seriesName;
|
||||||
|
|
||||||
synonyms.Add(mainTitle);
|
synonyms.Add(mainTitle);
|
||||||
|
|
||||||
@@ -247,35 +226,35 @@ namespace Jackett.Common.Indexers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<int> Category = null;
|
List<int> category = null;
|
||||||
var category = (string)group["CategoryName"];
|
var categoryName = (string)group["CategoryName"];
|
||||||
|
|
||||||
var Description = (string)group["Description"];
|
var description = (string)group["Description"];
|
||||||
|
|
||||||
foreach (JObject torrent in group["Torrents"])
|
foreach (var torrent in group["Torrents"])
|
||||||
{
|
{
|
||||||
var releaseInfo = "S01";
|
var releaseInfo = "S01";
|
||||||
string episode = null;
|
string episode = null;
|
||||||
int? season = null;
|
int? season = null;
|
||||||
var EditionTitle = (string)torrent["EditionData"]["EditionTitle"];
|
var editionTitle = (string)torrent["EditionData"]["EditionTitle"];
|
||||||
if (!string.IsNullOrWhiteSpace(EditionTitle))
|
if (!string.IsNullOrWhiteSpace(editionTitle))
|
||||||
releaseInfo = WebUtility.HtmlDecode(EditionTitle);
|
releaseInfo = WebUtility.HtmlDecode(editionTitle);
|
||||||
|
|
||||||
var SeasonRegEx = new Regex(@"Season (\d+)", RegexOptions.Compiled);
|
var seasonRegEx = new Regex(@"Season (\d+)", RegexOptions.Compiled);
|
||||||
var SeasonRegExMatch = SeasonRegEx.Match(releaseInfo);
|
var seasonRegExMatch = seasonRegEx.Match(releaseInfo);
|
||||||
if (SeasonRegExMatch.Success)
|
if (seasonRegExMatch.Success)
|
||||||
season = ParseUtil.CoerceInt(SeasonRegExMatch.Groups[1].Value);
|
season = ParseUtil.CoerceInt(seasonRegExMatch.Groups[1].Value);
|
||||||
|
|
||||||
var EpisodeRegEx = new Regex(@"Episode (\d+)", RegexOptions.Compiled);
|
var episodeRegEx = new Regex(@"Episode (\d+)", RegexOptions.Compiled);
|
||||||
var EpisodeRegExMatch = EpisodeRegEx.Match(releaseInfo);
|
var episodeRegExMatch = episodeRegEx.Match(releaseInfo);
|
||||||
if (EpisodeRegExMatch.Success)
|
if (episodeRegExMatch.Success)
|
||||||
episode = EpisodeRegExMatch.Groups[1].Value;
|
episode = episodeRegExMatch.Groups[1].Value;
|
||||||
|
|
||||||
releaseInfo = releaseInfo.Replace("Episode ", "");
|
releaseInfo = releaseInfo.Replace("Episode ", "");
|
||||||
releaseInfo = releaseInfo.Replace("Season ", "S");
|
releaseInfo = releaseInfo.Replace("Season ", "S");
|
||||||
releaseInfo = releaseInfo.Trim();
|
releaseInfo = releaseInfo.Trim();
|
||||||
|
|
||||||
if (PadEpisode && int.TryParse(releaseInfo, out var test) && releaseInfo.Length == 1)
|
if (PadEpisode && int.TryParse(releaseInfo, out _) && releaseInfo.Length == 1)
|
||||||
{
|
{
|
||||||
releaseInfo = "0" + releaseInfo;
|
releaseInfo = "0" + releaseInfo;
|
||||||
}
|
}
|
||||||
@@ -287,74 +266,69 @@ namespace Jackett.Common.Indexers
|
|||||||
if (query.Episode != null && episode != null && episode != query.Episode) // skip if episode doesn't match
|
if (query.Episode != null && episode != null && episode != query.Episode) // skip if episode doesn't match
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var torrentID = (long)torrent["ID"];
|
var torrentId = (long)torrent["ID"];
|
||||||
var Property = (string)torrent["Property"];
|
var property = ((string)torrent["Property"]).Replace(" | Freeleech", "");
|
||||||
Property = Property.Replace(" | Freeleech", "");
|
var link = (string)torrent["Link"];
|
||||||
var Link = (string)torrent["Link"];
|
var linkUri = new Uri(link);
|
||||||
var LinkUri = new Uri(Link);
|
var uploadTimeString = (string)torrent["UploadTime"];
|
||||||
var UploadTimeString = (string)torrent["UploadTime"];
|
var uploadTime = DateTime.ParseExact(uploadTimeString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
|
||||||
var UploadTime = DateTime.ParseExact(UploadTimeString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
|
var publishDate = DateTime.SpecifyKind(uploadTime, DateTimeKind.Utc).ToLocalTime();
|
||||||
var PublushDate = DateTime.SpecifyKind(UploadTime, DateTimeKind.Utc).ToLocalTime();
|
var commentsLink = SiteLink + "torrent/" + torrentId + "/group";
|
||||||
var CommentsLink = SiteLink + "torrent/" + torrentID.ToString() + "/group";
|
var commentsLinkUri = new Uri(commentsLink);
|
||||||
var CommentsLinkUri = new Uri(CommentsLink);
|
var size = (long)torrent["Size"];
|
||||||
var Size = (long)torrent["Size"];
|
var snatched = (long)torrent["Snatched"];
|
||||||
var Snatched = (long)torrent["Snatched"];
|
var seeders = (int)torrent["Seeders"];
|
||||||
var Seeders = (int)torrent["Seeders"];
|
var leechers = (int)torrent["Leechers"];
|
||||||
var Leechers = (int)torrent["Leechers"];
|
var fileCount = (long)torrent["FileCount"];
|
||||||
var FileCount = (long)torrent["FileCount"];
|
var peers = seeders + leechers;
|
||||||
var Peers = Seeders + Leechers;
|
|
||||||
|
|
||||||
var RawDownMultiplier = (int?)torrent["RawDownMultiplier"];
|
var rawDownMultiplier = (int?)torrent["RawDownMultiplier"] ?? 0;
|
||||||
if (RawDownMultiplier == null)
|
var rawUpMultiplier = (int?)torrent["RawUpMultiplier"] ?? 0;
|
||||||
RawDownMultiplier = 0;
|
|
||||||
var RawUpMultiplier = (int?)torrent["RawUpMultiplier"];
|
|
||||||
if (RawUpMultiplier == null)
|
|
||||||
RawDownMultiplier = 0;
|
|
||||||
|
|
||||||
if (searchType == "anime")
|
if (searchType == "anime")
|
||||||
{
|
{
|
||||||
if (GroupName == "TV Series" || GroupName == "OVA")
|
if (groupName == "TV Series" || groupName == "OVA")
|
||||||
Category = new List<int> { TorznabCatType.TVAnime.ID };
|
category = new List<int> { TorznabCatType.TVAnime.ID };
|
||||||
|
|
||||||
// Ignore these categories as they'll cause hell with the matcher
|
// Ignore these categories as they'll cause hell with the matcher
|
||||||
// TV Special, OVA, ONA, DVD Special, BD Special
|
// TV Special, OVA, ONA, DVD Special, BD Special
|
||||||
|
|
||||||
if (GroupName == "Movie" || GroupName == "Live Action Movie")
|
if (groupName == "Movie" || groupName == "Live Action Movie")
|
||||||
Category = new List<int> { TorznabCatType.Movies.ID };
|
category = new List<int> { TorznabCatType.Movies.ID };
|
||||||
|
|
||||||
if (category == "Manga" || category == "Oneshot" || category == "Anthology" || category == "Manhwa" || category == "Manhua" || category == "Light Novel")
|
if (categoryName == "Manga" || categoryName == "Oneshot" || categoryName == "Anthology" || categoryName == "Manhwa" || categoryName == "Manhua" || categoryName == "Light Novel")
|
||||||
Category = new List<int> { TorznabCatType.BooksComics.ID };
|
category = new List<int> { TorznabCatType.BooksComics.ID };
|
||||||
|
|
||||||
if (category == "Novel" || category == "Artbook")
|
if (categoryName == "Novel" || categoryName == "Artbook")
|
||||||
Category = new List<int> { TorznabCatType.BooksComics.ID };
|
category = new List<int> { TorznabCatType.BooksComics.ID };
|
||||||
|
|
||||||
if (category == "Game" || category == "Visual Novel")
|
if (categoryName == "Game" || categoryName == "Visual Novel")
|
||||||
{
|
{
|
||||||
if (Property.Contains(" PSP "))
|
if (property.Contains(" PSP "))
|
||||||
Category = new List<int> { TorznabCatType.ConsolePSP.ID };
|
category = new List<int> { TorznabCatType.ConsolePSP.ID };
|
||||||
if (Property.Contains("PSX"))
|
if (property.Contains("PSX"))
|
||||||
Category = new List<int> { TorznabCatType.ConsoleOther.ID };
|
category = new List<int> { TorznabCatType.ConsoleOther.ID };
|
||||||
if (Property.Contains(" NES "))
|
if (property.Contains(" NES "))
|
||||||
Category = new List<int> { TorznabCatType.ConsoleOther.ID };
|
category = new List<int> { TorznabCatType.ConsoleOther.ID };
|
||||||
if (Property.Contains(" PC "))
|
if (property.Contains(" PC "))
|
||||||
Category = new List<int> { TorznabCatType.PCGames.ID };
|
category = new List<int> { TorznabCatType.PCGames.ID };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (searchType == "music")
|
else if (searchType == "music")
|
||||||
{
|
{
|
||||||
if (category == "Single" || category == "EP" || category == "Album" || category == "Compilation" || category == "Soundtrack" || category == "Remix CD" || category == "PV" || category == "Live Album" || category == "Image CD" || category == "Drama CD" || category == "Vocal CD")
|
if (categoryName == "Single" || categoryName == "EP" || categoryName == "Album" || categoryName == "Compilation" || categoryName == "Soundtrack" || categoryName == "Remix CD" || categoryName == "PV" || categoryName == "Live Album" || categoryName == "Image CD" || categoryName == "Drama CD" || categoryName == "Vocal CD")
|
||||||
{
|
{
|
||||||
if (Property.Contains(" Lossless "))
|
if (property.Contains(" Lossless "))
|
||||||
Category = new List<int> { TorznabCatType.AudioLossless.ID };
|
category = new List<int> { TorznabCatType.AudioLossless.ID };
|
||||||
else if (Property.Contains("MP3"))
|
else if (property.Contains("MP3"))
|
||||||
Category = new List<int> { TorznabCatType.AudioMP3.ID };
|
category = new List<int> { TorznabCatType.AudioMP3.ID };
|
||||||
else
|
else
|
||||||
Category = new List<int> { TorznabCatType.AudioOther.ID };
|
category = new List<int> { TorznabCatType.AudioOther.ID };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We dont actually have a release name >.> so try to create one
|
// We don't actually have a release name >.> so try to create one
|
||||||
var releaseTags = Property.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList();
|
var releaseTags = property.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
for (var i = releaseTags.Count - 1; i >= 0; i--)
|
for (var i = releaseTags.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
releaseTags[i] = releaseTags[i].Trim();
|
releaseTags[i] = releaseTags[i].Trim();
|
||||||
@@ -362,62 +336,56 @@ namespace Jackett.Common.Indexers
|
|||||||
releaseTags.RemoveAt(i);
|
releaseTags.RemoveAt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
var releasegroup = releaseTags.LastOrDefault();
|
var releaseGroup = releaseTags.LastOrDefault();
|
||||||
if (releasegroup != null && releasegroup.Contains("(") && releasegroup.Contains(")"))
|
if (releaseGroup != null && releaseGroup.Contains("(") && releaseGroup.Contains(")"))
|
||||||
{
|
{
|
||||||
// Skip raws if set
|
// Skip raws if set
|
||||||
if (releasegroup.ToLowerInvariant().StartsWith("raw") && !AllowRaws)
|
if (releaseGroup.ToLowerInvariant().StartsWith("raw") && !AllowRaws)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var start = releasegroup.IndexOf("(");
|
var start = releaseGroup.IndexOf("(", StringComparison.Ordinal);
|
||||||
releasegroup = "[" + releasegroup.Substring(start + 1, (releasegroup.IndexOf(")") - 1) - start) + "] ";
|
releaseGroup = "[" + releaseGroup.Substring(start + 1, (releaseGroup.IndexOf(")", StringComparison.Ordinal) - 1) - start) + "] ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
releasegroup = string.Empty;
|
releaseGroup = string.Empty;
|
||||||
}
|
}
|
||||||
if (!AllowRaws && releaseTags.Contains("raw", StringComparer.InvariantCultureIgnoreCase))
|
if (!AllowRaws && releaseTags.Contains("raw", StringComparer.InvariantCultureIgnoreCase))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var infoString = releaseTags.Aggregate("", (prev, cur) => prev + "[" + cur + "]");
|
var infoString = releaseTags.Aggregate("", (prev, cur) => prev + "[" + cur + "]");
|
||||||
var MinimumSeedTime = 259200;
|
var minimumSeedTime = 259200;
|
||||||
// Additional 5 hours per GB
|
// Additional 5 hours per GB
|
||||||
MinimumSeedTime += (int)((Size / 1000000000) * 18000);
|
minimumSeedTime += (int)((size / 1000000000) * 18000);
|
||||||
|
|
||||||
foreach (var title in synonyms)
|
foreach (var title in synonyms)
|
||||||
{
|
{
|
||||||
string releaseTitle = null;
|
var releaseTitle = groupName == "Movie" ?
|
||||||
if (GroupName == "Movie")
|
$"{title} {year} {releaseGroup}{infoString}" :
|
||||||
{
|
$"{releaseGroup}{title} {releaseInfo} {infoString}";
|
||||||
releaseTitle = string.Format("{0} {1} {2}{3}", title, Year, releasegroup, infoString);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
releaseTitle = string.Format("{0}{1} {2} {3}", releasegroup, title, releaseInfo, infoString);
|
|
||||||
}
|
|
||||||
|
|
||||||
var guid = new Uri(CommentsLinkUri + "&nh=" + StringUtil.Hash(title));
|
var guid = new Uri(commentsLinkUri + "&nh=" + StringUtil.Hash(title));
|
||||||
var release = new ReleaseInfo
|
var release = new ReleaseInfo
|
||||||
{
|
{
|
||||||
MinimumRatio = 1,
|
MinimumRatio = 1,
|
||||||
MinimumSeedTime = MinimumSeedTime,
|
MinimumSeedTime = minimumSeedTime,
|
||||||
Title = releaseTitle,
|
Title = releaseTitle,
|
||||||
Comments = CommentsLinkUri,
|
Comments = commentsLinkUri,
|
||||||
Guid = guid, // Sonarr should dedupe on this url - allow a url per name.
|
Guid = guid,
|
||||||
Link = LinkUri,
|
Link = linkUri,
|
||||||
BannerUrl = ImageUrl,
|
BannerUrl = imageUrl,
|
||||||
PublishDate = PublushDate,
|
PublishDate = publishDate,
|
||||||
Category = Category,
|
Category = category,
|
||||||
Description = Description,
|
Description = description,
|
||||||
Size = Size,
|
Size = size,
|
||||||
Seeders = Seeders,
|
Seeders = seeders,
|
||||||
Peers = Peers,
|
Peers = peers,
|
||||||
Grabs = Snatched,
|
Grabs = snatched,
|
||||||
Files = FileCount,
|
Files = fileCount,
|
||||||
DownloadVolumeFactor = RawDownMultiplier,
|
DownloadVolumeFactor = rawDownMultiplier,
|
||||||
UploadVolumeFactor = RawUpMultiplier
|
UploadVolumeFactor = rawUpMultiplier
|
||||||
};
|
};
|
||||||
|
|
||||||
releases.Add(release);
|
releases.Add(release);
|
||||||
|
Reference in New Issue
Block a user