2017-10-29 06:21:18 +00:00
using System.Collections.Generic ;
using System.Text ;
using System.Text.RegularExpressions ;
using System.Threading.Tasks ;
2018-03-10 08:05:56 +00:00
using Jackett.Common.Indexers.Abstract ;
using Jackett.Common.Models ;
using Jackett.Common.Models.IndexerConfig ;
using Jackett.Common.Services.Interfaces ;
using Jackett.Common.Utils.Clients ;
2015-10-24 14:54:32 +00:00
using NLog ;
2017-04-15 08:45:10 +00:00
2018-03-10 08:05:56 +00:00
namespace Jackett.Common.Indexers
2015-10-24 14:54:32 +00:00
{
2017-09-15 16:57:43 +00:00
public class DanishBits : CouchPotatoTracker
2015-10-24 14:54:32 +00:00
{
2017-11-30 15:12:10 +00:00
public override string [ ] LegacySiteLinks { get ; protected set ; } = new string [ ] {
"http://danishbits.org/" ,
} ;
2017-10-29 06:21:18 +00:00
private new ConfigurationDataUserPasskey configData
2017-10-06 08:36:04 +00:00
{
get { return ( ConfigurationDataUserPasskey ) base . configData ; }
set { base . configData = value ; }
}
2017-11-05 09:42:03 +00:00
public DanishBits ( IIndexerConfigurationService configService , WebClient c , Logger l , IProtectionService ps )
2015-10-24 14:54:32 +00:00
: base ( name : "DanishBits" ,
description : "A danish closed torrent tracker" ,
link : "https://danishbits.org/" ,
2017-09-15 16:57:43 +00:00
endpoint : "couchpotato.php" ,
2017-07-10 20:58:44 +00:00
configService : configService ,
2015-10-24 14:54:32 +00:00
client : c ,
logger : l ,
2017-10-06 08:36:04 +00:00
p : ps ,
configData : new ConfigurationDataUserPasskey ( "Note about Passkey: This is not your login Password. Find the Passkey by logging into DanishBits with your Browser, and under your account page you'll see your passkey under the 'Personal' section on the left side." )
)
2015-10-24 14:54:32 +00:00
{
2017-11-05 09:42:03 +00:00
Encoding = Encoding . UTF8 ;
2016-12-09 17:20:58 +00:00
Language = "da-dk" ;
2017-01-27 15:57:32 +00:00
Type = "private" ;
2016-12-06 13:56:47 +00:00
2017-09-15 16:57:43 +00:00
AddCategoryMapping ( "movie" , TorznabCatType . Movies ) ;
AddCategoryMapping ( "tv" , TorznabCatType . TV ) ;
2018-01-09 15:13:15 +00:00
AddCategoryMapping ( "blandet" , TorznabCatType . Other ) ; // e.g. games
2015-10-24 14:54:32 +00:00
}
2017-09-19 09:32:12 +00:00
protected override string GetSearchString ( TorznabQuery query )
{
if ( string . IsNullOrEmpty ( query . SearchTerm ) & & string . IsNullOrEmpty ( query . ImdbID ) )
{
return "%" ;
}
var searchString = query . GetQueryString ( ) ;
2020-02-10 22:16:19 +00:00
var ReplaceRegex = new Regex ( "[^a-zA-Z0-9]+" ) ;
2017-09-19 09:32:12 +00:00
searchString = ReplaceRegex . Replace ( searchString , "%" ) ;
return searchString ;
}
2017-10-03 12:23:31 +00:00
protected override async Task < WebClientByteResult > RequestBytesWithCookies ( string url , string cookieOverride = null , RequestType method = RequestType . GET , string referer = null , IEnumerable < KeyValuePair < string , string > > data = null , Dictionary < string , string > headers = null )
2015-10-24 14:54:32 +00:00
{
2017-10-03 12:23:31 +00:00
CookieHeader = null ; // Download fill fail with cookies set
return await base . RequestBytesWithCookies ( url , cookieOverride , method , referer , data , headers ) ;
2015-10-24 14:54:32 +00:00
}
}
}