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