mirror of
https://github.com/Jackett/Jackett
synced 2025-01-01 12:46:23 +00:00
torrentday: some fixes and code cleanup (#8035)
* Add SupportsImdbTVSearch * Code cleanup Tested
This commit is contained in:
parent
45e5d032f7
commit
16a59b8abd
1 changed files with 44 additions and 45 deletions
|
@ -45,29 +45,29 @@ namespace Jackett.Common.Indexers
|
|||
"https://td.workisboring.net/",
|
||||
};
|
||||
|
||||
private new ConfigurationDataRecaptchaLogin configData
|
||||
{
|
||||
get => (ConfigurationDataRecaptchaLogin)base.configData;
|
||||
set => base.configData = value;
|
||||
}
|
||||
private new ConfigurationDataRecaptchaLogin configData => (ConfigurationDataRecaptchaLogin)base.configData;
|
||||
|
||||
public TorrentDay(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
||||
: base(name: "TorrentDay",
|
||||
description: "TorrentDay (TD) is a Private site for TV / MOVIES / GENERAL",
|
||||
link: "https://tday.love/",
|
||||
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
||||
configService: configService,
|
||||
client: wc,
|
||||
logger: l,
|
||||
p: ps,
|
||||
configData: new ConfigurationDataRecaptchaLogin("Make sure you get the cookies from the same torrent day domain as configured above."))
|
||||
: base("TorrentDay",
|
||||
description: "TorrentDay (TD) is a Private site for TV / MOVIES / GENERAL",
|
||||
link: "https://tday.love/",
|
||||
caps: new TorznabCapabilities
|
||||
{
|
||||
SupportsImdbMovieSearch = true,
|
||||
SupportsImdbTVSearch = true
|
||||
},
|
||||
configService: configService,
|
||||
client: wc,
|
||||
logger: l,
|
||||
p: ps,
|
||||
configData: new ConfigurationDataRecaptchaLogin(
|
||||
"Make sure you get the cookies from the same torrent day domain as configured above."))
|
||||
{
|
||||
wc.EmulateBrowser = false;
|
||||
Encoding = Encoding.UTF8;
|
||||
Language = "en-us";
|
||||
Type = "private";
|
||||
|
||||
TorznabCaps.SupportsImdbMovieSearch = true;
|
||||
wc.EmulateBrowser = false;
|
||||
|
||||
AddCategoryMapping(29, TorznabCatType.TVAnime, "Anime");
|
||||
AddCategoryMapping(28, TorznabCatType.PC, "Appz/Packs");
|
||||
|
@ -181,7 +181,7 @@ namespace Jackett.Common.Indexers
|
|||
errorMessage = dom.TextContent;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(errorMessage) && result.IsRedirect)
|
||||
errorMessage = string.Format("Got a redirect to {0}, please adjust your the alternative link", result.RedirectingTo);
|
||||
errorMessage = $"Got a redirect to {result.RedirectingTo}, please adjust your the alternative link";
|
||||
|
||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
||||
});
|
||||
|
@ -191,66 +191,65 @@ namespace Jackett.Common.Indexers
|
|||
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
var releases = new List<ReleaseInfo>();
|
||||
var searchString = query.GetQueryString();
|
||||
var queryUrl = SearchUrl;
|
||||
|
||||
var cats = MapTorznabCapsToTrackers(query);
|
||||
if (cats.Count == 0)
|
||||
cats = GetAllTrackerCategories();
|
||||
|
||||
var catStr = string.Join(";", cats);
|
||||
queryUrl += "?" + catStr;
|
||||
var searchUrl = SearchUrl + "?" + catStr;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(query.ImdbID))
|
||||
queryUrl += ";q=" + query.ImdbID;
|
||||
if (query.IsImdbQuery)
|
||||
searchUrl += ";q=" + query.ImdbID;
|
||||
else
|
||||
queryUrl += ";q=" + WebUtilityHelpers.UrlEncode(searchString, Encoding);
|
||||
searchUrl += ";q=" + WebUtilityHelpers.UrlEncode(query.GetQueryString(), Encoding);
|
||||
|
||||
var results = await RequestStringWithCookiesAndRetry(queryUrl);
|
||||
var results = await RequestStringWithCookiesAndRetry(searchUrl);
|
||||
|
||||
// Check for being logged out
|
||||
if (results.IsRedirect)
|
||||
if (results.RedirectingTo.Contains("login.php"))
|
||||
throw new ExceptionWithConfigData("Login failed, please reconfigure the tracker to update the cookies", configData);
|
||||
else
|
||||
throw new ExceptionWithConfigData(string.Format("Got a redirect to {0}, please adjust your the alternative link", results.RedirectingTo), configData);
|
||||
throw new ExceptionWithConfigData($"Got a redirect to {results.RedirectingTo}, please adjust your the alternative link", configData);
|
||||
|
||||
try
|
||||
{
|
||||
var json = JsonConvert.DeserializeObject<dynamic>(results.Content);
|
||||
var rows = JsonConvert.DeserializeObject<dynamic>(results.Content);
|
||||
|
||||
foreach (var torrent in json)
|
||||
foreach (var row in rows)
|
||||
{
|
||||
var title = (string)torrent.name;
|
||||
var title = (string)row.name;
|
||||
if ((!query.IsImdbQuery || !TorznabCaps.SupportsImdbMovieSearch) && !query.MatchQueryStringAND(title))
|
||||
continue;
|
||||
var torrentID = (long)torrent.t;
|
||||
var comments = new Uri(SiteLink + "details.php?id=" + torrentID);
|
||||
var seeders = (int)torrent.seeders;
|
||||
var imdbId = (string)torrent["imdb-id"];
|
||||
var downloadMultiplier = (double?)torrent["download-multiplier"];
|
||||
var link = new Uri(SiteLink + "download.php/" + torrentID + "/" + torrentID + ".torrent");
|
||||
var publishDate = DateTimeUtil.UnixTimestampToDateTime((long)torrent.ctime).ToLocalTime();
|
||||
var torrentId = (long)row.t;
|
||||
var comments = new Uri(SiteLink + "details.php?id=" + torrentId);
|
||||
var seeders = (int)row.seeders;
|
||||
var imdbId = (string)row["imdb-id"];
|
||||
var downloadMultiplier = (double?)row["download-multiplier"] ?? 1;
|
||||
var link = new Uri(SiteLink + "download.php/" + torrentId + "/" + torrentId + ".torrent");
|
||||
var publishDate = DateTimeUtil.UnixTimestampToDateTime((long)row.ctime).ToLocalTime();
|
||||
var imdb = ParseUtil.GetImdbID(imdbId);
|
||||
|
||||
var release = new ReleaseInfo
|
||||
{
|
||||
Title = title,
|
||||
MinimumRatio = 1,
|
||||
MinimumSeedTime = 172800, // 48 hours
|
||||
Category = MapTrackerCatToNewznab(torrent.c.ToString()),
|
||||
Comments = comments,
|
||||
Guid = comments,
|
||||
Link = link,
|
||||
PublishDate = publishDate,
|
||||
Size = (long)torrent.size,
|
||||
Category = MapTrackerCatToNewznab(row.c.ToString()),
|
||||
Size = (long)row.size,
|
||||
Files = (long)row.files,
|
||||
Grabs = (long)row.completed,
|
||||
Seeders = seeders,
|
||||
Peers = seeders + (int)torrent.leechers,
|
||||
Files = (long)torrent.files,
|
||||
Grabs = (long)torrent.completed,
|
||||
Peers = seeders + (int)row.leechers,
|
||||
Imdb = imdb,
|
||||
DownloadVolumeFactor = downloadMultiplier ?? 1,
|
||||
UploadVolumeFactor = 1
|
||||
DownloadVolumeFactor = downloadMultiplier,
|
||||
UploadVolumeFactor = 1,
|
||||
MinimumRatio = 1,
|
||||
MinimumSeedTime = 172800 // 48 hours
|
||||
};
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue