2020-02-09 02:35:16 +00:00
using System ;
2017-10-29 06:50:47 +00:00
using System.Collections.Generic ;
2020-05-03 23:35:52 +00:00
using System.Diagnostics.CodeAnalysis ;
2017-10-29 06:50:47 +00:00
using System.Linq ;
using System.Threading.Tasks ;
2018-03-10 08:05:56 +00:00
using Jackett.Common.Helpers ;
using Jackett.Common.Models ;
using Jackett.Common.Models.IndexerConfig ;
using Jackett.Common.Services.Interfaces ;
using Jackett.Common.Utils ;
using Jackett.Common.Utils.Clients ;
2018-01-30 13:11:10 +00:00
using Newtonsoft.Json ;
2017-04-15 08:45:10 +00:00
using Newtonsoft.Json.Linq ;
using NLog ;
2022-01-16 18:34:50 +00:00
using static Jackett . Common . Models . IndexerConfig . ConfigurationData ;
2017-04-15 08:45:10 +00:00
2018-03-10 08:05:56 +00:00
namespace Jackett.Common.Indexers
2017-04-15 08:45:10 +00:00
{
2020-05-03 23:35:52 +00:00
[ExcludeFromCodeCoverage]
2023-03-09 14:06:12 +00:00
public class TorrentDay : IndexerBase
2017-04-15 08:45:10 +00:00
{
2023-03-09 14:06:12 +00:00
public override string Id = > "torrentday" ;
public override string Name = > "TorrentDay" ;
public override string Description = > "TorrentDay (TD) is a Private site for TV / MOVIES / GENERAL" ;
public override string SiteLink { get ; protected set ; } = "https://tday.love/" ;
public override string [ ] AlternativeSiteLinks = > new [ ]
{
2021-05-10 09:41:33 +00:00
"https://tday.love/" ,
2020-07-06 19:40:13 +00:00
"https://torrentday.cool/" ,
2017-04-15 08:45:10 +00:00
"https://secure.torrentday.com/" ,
"https://classic.torrentday.com/" ,
"https://www.torrentday.com/" ,
2024-04-17 21:07:28 +00:00
"https://www.torrentday.me/" ,
2020-07-06 19:40:13 +00:00
"https://torrentday.it/" ,
2019-01-15 12:06:05 +00:00
"https://td.findnemo.net/" ,
"https://td.getcrazy.me/" ,
"https://td.venom.global/" ,
2022-08-02 09:39:18 +00:00
"https://td.workisboring.net/" ,
"https://tday.findnemo.net/" ,
"https://tday.getcrazy.me/" ,
"https://tday.venom.global/" ,
"https://tday.workisboring.net/"
2020-05-15 21:06:58 +00:00
} ;
2023-03-09 14:06:12 +00:00
public override string [ ] LegacySiteLinks = > new [ ]
{
2020-05-15 21:06:58 +00:00
"https://torrentday.com/" ,
"https://tdonline.org/" , // redirect to https://www.torrentday.com/
"https://torrentday.eu/" , // redirect to https://www.torrentday.com/
"https://td-update.com/" , // redirect to https://www.torrentday.com/
"https://www.torrentday.ru/" ,
2021-05-10 09:41:33 +00:00
"https://www.td.af/"
2017-04-15 08:45:10 +00:00
} ;
2023-03-09 14:06:12 +00:00
public override string Language = > "en-US" ;
public override string Type = > "private" ;
2023-03-10 11:20:29 +00:00
public override TorznabCapabilities TorznabCaps = > SetCapabilities ( ) ;
2023-03-09 14:06:12 +00:00
private string SearchUrl = > SiteLink + "t.json" ;
2017-04-15 08:45:10 +00:00
2020-06-09 19:25:19 +00:00
private new ConfigurationDataCookie configData = > ( ConfigurationDataCookie ) base . configData ;
2017-04-15 08:45:10 +00:00
2020-12-11 22:14:21 +00:00
public TorrentDay ( IIndexerConfigurationService configService , WebClient wc , Logger l , IProtectionService ps ,
ICacheService cs )
2023-03-10 11:20:29 +00:00
: base ( configService : configService ,
2020-04-04 20:34:38 +00:00
client : wc ,
logger : l ,
p : ps ,
2020-12-11 22:14:21 +00:00
cacheService : cs ,
2020-06-09 19:25:19 +00:00
configData : new ConfigurationDataCookie (
2020-04-04 20:34:38 +00:00
"Make sure you get the cookies from the same torrent day domain as configured above." ) )
2017-04-15 08:45:10 +00:00
{
2020-04-04 20:34:38 +00:00
wc . EmulateBrowser = false ;
2017-04-15 08:45:10 +00:00
2022-01-16 18:34:50 +00:00
configData . AddDynamic ( "freeleech" , new BoolConfigurationItem ( "Search freeleech only" ) { Value = false } ) ;
2023-03-10 11:20:29 +00:00
}
private TorznabCapabilities SetCapabilities ( )
{
var caps = new TorznabCapabilities
{
TvSearchParams = new List < TvSearchParam >
{
TvSearchParam . Q , TvSearchParam . Season , TvSearchParam . Ep , TvSearchParam . ImdbId , TvSearchParam . Genre
} ,
MovieSearchParams = new List < MovieSearchParam >
{
MovieSearchParam . Q , MovieSearchParam . ImdbId , MovieSearchParam . Genre
} ,
MusicSearchParams = new List < MusicSearchParam >
{
MusicSearchParam . Q
} ,
BookSearchParams = new List < BookSearchParam >
{
BookSearchParam . Q
2024-04-17 20:17:47 +00:00
} ,
SupportsRawSearch = true
2023-03-10 11:20:29 +00:00
} ;
caps . Categories . AddCategoryMapping ( 96 , TorznabCatType . MoviesUHD , "Movie/4K" ) ;
caps . Categories . AddCategoryMapping ( 25 , TorznabCatType . MoviesSD , "Movies/480p" ) ;
caps . Categories . AddCategoryMapping ( 11 , TorznabCatType . MoviesBluRay , "Movies/Bluray" ) ;
caps . Categories . AddCategoryMapping ( 5 , TorznabCatType . MoviesBluRay , "Movies/Bluray-Full" ) ;
caps . Categories . AddCategoryMapping ( 3 , TorznabCatType . MoviesDVD , "Movies/DVD-R" ) ;
caps . Categories . AddCategoryMapping ( 21 , TorznabCatType . MoviesSD , "Movies/MP4" ) ;
caps . Categories . AddCategoryMapping ( 22 , TorznabCatType . MoviesForeign , "Movies/Non-English" ) ;
caps . Categories . AddCategoryMapping ( 13 , TorznabCatType . Movies , "Movies/Packs" ) ;
caps . Categories . AddCategoryMapping ( 44 , TorznabCatType . MoviesSD , "Movies/SD/x264" ) ;
caps . Categories . AddCategoryMapping ( 48 , TorznabCatType . Movies , "Movies/x265" ) ;
caps . Categories . AddCategoryMapping ( 1 , TorznabCatType . MoviesSD , "Movies/XviD" ) ;
caps . Categories . AddCategoryMapping ( 24 , TorznabCatType . TVSD , "TV/480p" ) ;
caps . Categories . AddCategoryMapping ( 32 , TorznabCatType . TVHD , "TV/Bluray" ) ;
caps . Categories . AddCategoryMapping ( 31 , TorznabCatType . TVSD , "TV/DVD-R" ) ;
caps . Categories . AddCategoryMapping ( 33 , TorznabCatType . TVSD , "TV/DVD-Rip" ) ;
caps . Categories . AddCategoryMapping ( 46 , TorznabCatType . TVSD , "TV/Mobile" ) ;
caps . Categories . AddCategoryMapping ( 82 , TorznabCatType . TVForeign , "TV/Non-English" ) ;
caps . Categories . AddCategoryMapping ( 14 , TorznabCatType . TV , "TV/Packs" ) ;
caps . Categories . AddCategoryMapping ( 26 , TorznabCatType . TVSD , "TV/SD/x264" ) ;
caps . Categories . AddCategoryMapping ( 7 , TorznabCatType . TVHD , "TV/x264" ) ;
caps . Categories . AddCategoryMapping ( 34 , TorznabCatType . TVUHD , "TV/x265" ) ;
caps . Categories . AddCategoryMapping ( 2 , TorznabCatType . TVSD , "TV/XviD" ) ;
caps . Categories . AddCategoryMapping ( 4 , TorznabCatType . PCGames , "PC/Games" ) ;
caps . Categories . AddCategoryMapping ( 18 , TorznabCatType . ConsolePS3 , "PS" ) ;
caps . Categories . AddCategoryMapping ( 8 , TorznabCatType . ConsolePSP , "PSP" ) ;
caps . Categories . AddCategoryMapping ( 10 , TorznabCatType . ConsoleNDS , "Nintendo" ) ;
caps . Categories . AddCategoryMapping ( 9 , TorznabCatType . ConsoleXBox , "Xbox" ) ;
caps . Categories . AddCategoryMapping ( 17 , TorznabCatType . AudioMP3 , "Music/Audio" ) ;
caps . Categories . AddCategoryMapping ( 27 , TorznabCatType . Audio , "Music/Flac" ) ;
caps . Categories . AddCategoryMapping ( 23 , TorznabCatType . AudioForeign , "Music/Non-English" ) ;
caps . Categories . AddCategoryMapping ( 41 , TorznabCatType . Audio , "Music/Packs" ) ;
caps . Categories . AddCategoryMapping ( 16 , TorznabCatType . AudioVideo , "Music/Video" ) ;
caps . Categories . AddCategoryMapping ( 29 , TorznabCatType . TVAnime , "Anime" ) ;
caps . Categories . AddCategoryMapping ( 42 , TorznabCatType . AudioAudiobook , "Audio Books" ) ;
caps . Categories . AddCategoryMapping ( 20 , TorznabCatType . Books , "Books" ) ;
caps . Categories . AddCategoryMapping ( 102 , TorznabCatType . BooksForeign , "Books/Non-English" ) ;
caps . Categories . AddCategoryMapping ( 30 , TorznabCatType . TVDocumentary , "Documentary" ) ;
caps . Categories . AddCategoryMapping ( 95 , TorznabCatType . TVDocumentary , "Educational" ) ;
caps . Categories . AddCategoryMapping ( 47 , TorznabCatType . Other , "Fonts" ) ;
caps . Categories . AddCategoryMapping ( 43 , TorznabCatType . PCMac , "Mac" ) ;
caps . Categories . AddCategoryMapping ( 45 , TorznabCatType . AudioOther , "Podcast" ) ;
caps . Categories . AddCategoryMapping ( 28 , TorznabCatType . PC , "Softwa/Packs" ) ;
caps . Categories . AddCategoryMapping ( 12 , TorznabCatType . PC , "Software" ) ;
caps . Categories . AddCategoryMapping ( 19 , TorznabCatType . XXX , "XXX/0Day" ) ;
caps . Categories . AddCategoryMapping ( 6 , TorznabCatType . XXX , "XXX/Movies" ) ;
caps . Categories . AddCategoryMapping ( 15 , TorznabCatType . XXXPack , "XXX/Packs" ) ;
2022-01-16 18:34:50 +00:00
2023-03-10 11:20:29 +00:00
return caps ;
2017-04-15 08:45:10 +00:00
}
2017-06-28 05:31:38 +00:00
public override async Task < IndexerConfigurationStatus > ApplyConfiguration ( JToken configJson )
2017-04-15 08:45:10 +00:00
{
LoadValuesFromJson ( configJson ) ;
2020-06-09 19:25:19 +00:00
CookieHeader = configData . Cookie . Value ;
try
2017-04-15 08:45:10 +00:00
{
2020-06-09 19:25:19 +00:00
var results = await PerformQuery ( new TorznabQuery ( ) ) ;
if ( ! results . Any ( ) )
throw new Exception ( "Found 0 results in the tracker" ) ;
2017-04-15 08:45:10 +00:00
2020-06-09 19:25:19 +00:00
IsConfigured = true ;
SaveConfig ( ) ;
return IndexerConfigurationStatus . Completed ;
}
catch ( Exception e )
2017-04-15 08:45:10 +00:00
{
2020-06-09 19:25:19 +00:00
IsConfigured = false ;
throw new Exception ( "Your cookie did not work: " + e . Message ) ;
}
2017-04-15 08:45:10 +00:00
}
2017-07-03 05:15:47 +00:00
protected override async Task < IEnumerable < ReleaseInfo > > PerformQuery ( TorznabQuery query )
2017-04-15 08:45:10 +00:00
{
var releases = new List < ReleaseInfo > ( ) ;
2023-03-09 14:06:12 +00:00
/ * notes :
2022-08-08 20:35:23 +00:00
* TorrentDay can search for genre ( tags ) using the default title & tags search
2023-03-09 14:06:12 +00:00
* qf =
2022-08-08 20:35:23 +00:00
* "" = Title and Tags
* ta = Tags
* all = Title , Tags & Description
* adv = Advanced
2023-03-09 14:06:12 +00:00
*
2022-08-08 20:35:23 +00:00
* But only movies and tv have tags and the t . json does not return tags in results .
* /
2018-01-30 13:11:10 +00:00
var cats = MapTorznabCapsToTrackers ( query ) ;
if ( cats . Count = = 0 )
cats = GetAllTrackerCategories ( ) ;
var catStr = string . Join ( ";" , cats ) ;
2020-04-04 20:34:38 +00:00
var searchUrl = SearchUrl + "?" + catStr ;
2018-01-30 13:11:10 +00:00
2020-04-04 20:34:38 +00:00
if ( query . IsImdbQuery )
searchUrl + = ";q=" + query . ImdbID ;
2022-08-08 20:35:23 +00:00
else
if ( query . IsGenreQuery )
searchUrl + = ";q=" + WebUtilityHelpers . UrlEncode ( query . GetQueryString ( ) + " " + query . Genre , Encoding ) ;
2017-04-15 08:45:10 +00:00
else
2020-04-04 20:34:38 +00:00
searchUrl + = ";q=" + WebUtilityHelpers . UrlEncode ( query . GetQueryString ( ) , Encoding ) ;
2017-04-15 08:45:10 +00:00
2022-01-16 18:34:50 +00:00
if ( ( ( BoolConfigurationItem ) configData . GetDynamic ( "freeleech" ) ) . Value )
searchUrl + = ";free=on" ;
2020-06-11 15:09:27 +00:00
var results = await RequestWithCookiesAndRetryAsync ( searchUrl ) ;
2017-04-15 08:45:10 +00:00
// Check for being logged out
if ( results . IsRedirect )
if ( results . RedirectingTo . Contains ( "login.php" ) )
2020-06-09 19:25:19 +00:00
throw new Exception ( "The user is not logged in. It is possible that the cookie has expired or you made a mistake when copying it. Please check the settings." ) ;
2017-04-15 08:45:10 +00:00
else
2020-06-09 19:25:19 +00:00
throw new Exception ( $"Got a redirect to {results.RedirectingTo}, please adjust your the alternative link" ) ;
2017-04-15 08:45:10 +00:00
try
{
2020-06-09 17:36:57 +00:00
var rows = JsonConvert . DeserializeObject < dynamic > ( results . ContentString ) ;
2018-01-30 13:11:10 +00:00
2020-04-04 20:34:38 +00:00
foreach ( var row in rows )
2017-04-15 08:45:10 +00:00
{
2020-04-04 20:34:38 +00:00
var title = ( string ) row . name ;
2020-10-18 17:26:22 +00:00
if ( ( ! query . IsImdbQuery | | ! TorznabCaps . MovieSearchImdbAvailable ) & & ! query . MatchQueryStringAND ( title ) )
2017-04-15 08:45:10 +00:00
continue ;
2020-04-04 20:34:38 +00:00
var torrentId = ( long ) row . t ;
2020-11-08 02:11:27 +00:00
var details = new Uri ( SiteLink + "details.php?id=" + torrentId ) ;
2020-04-04 20:34:38 +00:00
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 ( ) ;
2023-05-21 09:09:32 +00:00
var imdb = ParseUtil . GetImdbId ( imdbId ) ;
2020-04-04 20:34:38 +00:00
2020-03-26 22:15:28 +00:00
var release = new ReleaseInfo
{
2020-03-27 20:23:10 +00:00
Title = title ,
2020-11-08 02:11:27 +00:00
Details = details ,
Guid = details ,
2020-03-26 22:15:28 +00:00
Link = link ,
PublishDate = publishDate ,
2020-04-04 20:34:38 +00:00
Category = MapTrackerCatToNewznab ( row . c . ToString ( ) ) ,
Size = ( long ) row . size ,
Files = ( long ) row . files ,
Grabs = ( long ) row . completed ,
2020-03-26 22:15:28 +00:00
Seeders = seeders ,
2020-04-04 20:34:38 +00:00
Peers = seeders + ( int ) row . leechers ,
2020-03-26 22:15:28 +00:00
Imdb = imdb ,
2020-04-04 20:34:38 +00:00
DownloadVolumeFactor = downloadMultiplier ,
UploadVolumeFactor = 1 ,
MinimumRatio = 1 ,
2024-04-17 21:07:28 +00:00
MinimumSeedTime = 259200 // 72 hours
2020-03-26 22:15:28 +00:00
} ;
2020-04-04 20:34:38 +00:00
2017-04-15 08:45:10 +00:00
releases . Add ( release ) ;
}
}
catch ( Exception ex )
{
2020-06-09 17:36:57 +00:00
OnParseError ( results . ContentString , ex ) ;
2017-04-15 08:45:10 +00:00
}
return releases ;
}
}
}