gazellegames-api: fixed release titles

This commit is contained in:
Bogdan 2024-08-16 14:41:27 +03:00
parent e37bba7d17
commit e07f595c6e
1 changed files with 12 additions and 3 deletions

View File

@ -5,6 +5,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using Jackett.Common.Extensions; using Jackett.Common.Extensions;
using Jackett.Common.Indexers.Definitions.Abstract; using Jackett.Common.Indexers.Definitions.Abstract;
@ -37,6 +38,9 @@ namespace Jackett.Common.Indexers.Definitions
protected override string AuthorizationName => "X-API-Key"; protected override string AuthorizationName => "X-API-Key";
protected override int ApiKeyLength => 64; protected override int ApiKeyLength => 64;
protected override string FlipOptionalTokenString(string requestLink) => requestLink.Replace("&usetoken=1", ""); protected override string FlipOptionalTokenString(string requestLink) => requestLink.Replace("&usetoken=1", "");
private static Regex YearRegex => new (@"\b(?:19|20|21)\d{2}\b", RegexOptions.Compiled);
public GazelleGamesApi(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps, public GazelleGamesApi(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps,
ICacheService cs) ICacheService cs)
: base(configService: configService, : base(configService: configService,
@ -317,16 +321,16 @@ namespace Jackett.Common.Indexers.Definitions
var link = GetDownloadUrl(torrentId, false); var link = GetDownloadUrl(torrentId, false);
var title = WebUtility.HtmlDecode(torrent.Value<string>("ReleaseTitle")); var title = WebUtility.HtmlDecode(torrent.Value<string>("ReleaseTitle"));
var groupYear = group.Value<int>("year"); var groupYear = group.Value<int?>("year");
if (groupYear > 0 && !title.Contains(groupYear.ToString())) if (groupYear is > 0 && title.IsNotNullOrWhiteSpace() && !YearRegex.Match(title).Success)
{ {
title += $" ({groupYear})"; title += $" ({groupYear})";
} }
if (torrent.Value<string>("RemasterTitle").IsNotNullOrWhiteSpace()) if (torrent.Value<string>("RemasterTitle").IsNotNullOrWhiteSpace())
{ {
title += $" [{$"{torrent.Value<string>("RemasterTitle")} {torrent.Value<int>("RemasterYear")}".Trim()}]"; title += $" [{$"{WebUtility.HtmlDecode(torrent.Value<string>("RemasterTitle"))} {torrent.Value<int>("RemasterYear")}".Trim()}]";
} }
var tags = new List<string>(); var tags = new List<string>();
@ -355,6 +359,11 @@ namespace Jackett.Common.Indexers.Definitions
} }
} }
if (torrent.Value<int>("Dupable") == 1)
{
tags.Add("Trumpable");
}
if (tags.Count > 0) if (tags.Count > 0)
{ {
title += $" [{string.Join(", ", tags)}]"; title += $" [{string.Join(", ", tags)}]";