Convert functions and properties to expression bodies when able (#7312)

Convert functions and properties to expression bodies when able
This commit is contained in:
Cory 2020-02-25 10:08:03 -06:00 committed by GitHub
parent 2f91d99e19
commit 889a8da4e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
136 changed files with 726 additions and 1512 deletions

View File

@ -286,9 +286,7 @@ namespace DateTimeRoutines
/// <param name="parsed_time">parsed date-time output</param>
/// <returns>true if time was found, else false</returns>
public static bool TryParseTime(this string str, DateTimeFormat default_format, out ParsedDateTime parsed_time)
{
return TryParseTime(str, default_format, out parsed_time, null);
}
=> TryParseTime(str, default_format, out parsed_time, null);
/// <summary>
/// Tries to find date and/or time within the passed string and return it as ParsedDateTime object.

View File

@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>8</LangVersion>
</PropertyGroup>
</Project>

View File

@ -9,9 +9,7 @@ namespace Jackett.Common
public ConfigurationData ConfigData { get; private set; }
public ExceptionWithConfigData(string message, ConfigurationData data)
: base(message)
{
ConfigData = data;
}
=> ConfigData = data;
}
}

View File

@ -44,14 +44,8 @@ namespace Jackett.Common.Helpers
}
}
public static void DumpToJson(this CookieContainer cookies, string uri, JToken json)
{
DumpToJson(cookies, new Uri(uri), json);
}
public static void DumpToJson(this CookieContainer cookies, string uri, JToken json) => DumpToJson(cookies, new Uri(uri), json);
public static void DumpToJson(this CookieContainer cookies, Uri uri, JToken json)
{
json["cookie_header"] = cookies.GetCookieHeader(uri);
}
public static void DumpToJson(this CookieContainer cookies, Uri uri, JToken json) => json["cookie_header"] = cookies.GetCookieHeader(uri);
}
}

View File

@ -9,9 +9,7 @@ namespace Jackett.Common
public IndexerException(IIndexer Indexer, string message, Exception innerException)
: base(message, innerException)
{
this.Indexer = Indexer;
}
=> this.Indexer = Indexer;
public IndexerException(IIndexer Indexer, string message)
: this(Indexer, message, null)

View File

@ -27,15 +27,15 @@ namespace Jackett.Common.Indexers
/// </summary>
public class Abnormal : BaseCachingWebIndexer
{
private string LoginUrl { get { return SiteLink + "login.php"; } }
private string SearchUrl { get { return SiteLink + "torrents.php"; } }
private string TorrentCommentUrl { get { return TorrentDescriptionUrl; } }
private string TorrentDescriptionUrl { get { return SiteLink + "torrents.php?id="; } }
private string TorrentDownloadUrl { get { return SiteLink + "torrents.php?action=download&id={id}&authkey={auth_key}&torrent_pass={torrent_pass}"; } }
private string ReplaceMulti { get { return ConfigData.ReplaceMulti.Value; } }
private bool Latency { get { return ConfigData.Latency.Value; } }
private bool DevMode { get { return ConfigData.DevMode.Value; } }
private bool CacheMode { get { return ConfigData.HardDriveCache.Value; } }
private string LoginUrl => SiteLink + "login.php";
private string SearchUrl => SiteLink + "torrents.php";
private string TorrentCommentUrl => TorrentDescriptionUrl;
private string TorrentDescriptionUrl => SiteLink + "torrents.php?id=";
private string TorrentDownloadUrl => SiteLink + "torrents.php?action=download&id={id}&authkey={auth_key}&torrent_pass={torrent_pass}";
private string ReplaceMulti => ConfigData.ReplaceMulti.Value;
private bool Latency => ConfigData.Latency.Value;
private bool DevMode => ConfigData.DevMode.Value;
private bool CacheMode => ConfigData.HardDriveCache.Value;
private static string Directory => Path.Combine(Path.GetTempPath(), Assembly.GetExecutingAssembly().GetName().Name.ToLower(), MethodBase.GetCurrentMethod().DeclaringType?.Name.ToLower());
private readonly Dictionary<string, string> emulatedBrowserHeaders = new Dictionary<string, string>();
@ -43,8 +43,8 @@ namespace Jackett.Common.Indexers
private ConfigurationDataAbnormal ConfigData
{
get { return (ConfigurationDataAbnormal)configData; }
set { base.configData = value; }
get => (ConfigurationDataAbnormal)configData;
set => base.configData = value;
}
public Abnormal(IIndexerConfigurationService configService, Utils.Clients.WebClient w, Logger l, IProtectionService ps)
@ -633,12 +633,8 @@ namespace Jackett.Common.Indexers
/// Find torrent rows in search pages
/// </summary>
/// <returns>JQuery Object</returns>
private CQ findTorrentRows()
{
// Return all occurencis of torrents found
return fDom[".torrent_table > tbody > tr"].Not(".colhead");
}
// Return all occurences of torrents found
private CQ findTorrentRows() => fDom[".torrent_table > tbody > tr"].Not(".colhead");
/// <summary>
/// Output message for logging or developpment (console)

View File

@ -15,12 +15,12 @@ namespace Jackett.Common.Indexers.Abstract
public abstract class CouchPotatoTracker : BaseWebIndexer
{
protected string endpoint;
protected string APIUrl { get { return SiteLink + endpoint; } }
protected string APIUrl => SiteLink + endpoint;
private new ConfigurationDataUserPasskey configData
{
get { return (ConfigurationDataUserPasskey)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataUserPasskey)base.configData;
set => base.configData = value;
}
public CouchPotatoTracker(IIndexerConfigurationService configService, WebClient client, Logger logger, IProtectionService p, ConfigurationDataUserPasskey configData, string name, string description, string link, string endpoint)
@ -47,11 +47,8 @@ namespace Jackett.Common.Indexers.Abstract
return await Task.FromResult(IndexerConfigurationStatus.RequiresTesting);
}
protected virtual string GetSearchString(TorznabQuery query)
{
// can be overriden to alter the search string
return query.GetQueryString();
}
// can be overriden to alter the search string
protected virtual string GetSearchString(TorznabQuery query) => query.GetQueryString();
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
@ -96,10 +93,12 @@ namespace Jackett.Common.Indexers.Abstract
{
foreach (JObject r in json["results"])
{
var release = new ReleaseInfo();
release.Title = (string)r["release_name"];
release.Comments = new Uri((string)r["details_url"]);
release.Link = new Uri((string)r["download_url"]);
var release = new ReleaseInfo
{
Title = (string)r["release_name"],
Comments = new Uri((string)r["details_url"]),
Link = new Uri((string)r["download_url"])
};
release.Guid = release.Link;
release.Imdb = ParseUtil.GetImdbID((string)r["imdb_id"]);
var freeleech = (bool)r["freeleech"];

View File

@ -18,10 +18,10 @@ namespace Jackett.Common.Indexers.Abstract
{
public abstract class GazelleTracker : BaseWebIndexer
{
protected string LoginUrl { get { return SiteLink + "login.php"; } }
protected string APIUrl { get { return SiteLink + "ajax.php"; } }
protected string DownloadUrl { get { return SiteLink + "torrents.php?action=download&usetoken=" + (useTokens ? "1" : "0") + "&id="; } }
protected string DetailsUrl { get { return SiteLink + "torrents.php?torrentid="; } }
protected string LoginUrl => SiteLink + "login.php";
protected string APIUrl => SiteLink + "ajax.php";
protected string DownloadUrl => SiteLink + "torrents.php?action=download&usetoken=" + (useTokens ? "1" : "0") + "&id=";
protected string DetailsUrl => SiteLink + "torrents.php?torrentid=";
protected bool supportsFreeleechTokens;
protected bool imdbInTags;
protected bool supportsCategories = true; // set to false if the tracker doesn't include the categories in the API search results
@ -30,8 +30,8 @@ namespace Jackett.Common.Indexers.Abstract
private new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLogin)base.configData;
set => base.configData = value;
}
public GazelleTracker(IIndexerConfigurationService configService, Utils.Clients.WebClient webClient, Logger logger, IProtectionService protectionService, string name, string desc, string link, bool supportsFreeleechTokens, bool imdbInTags = false, bool has2Fa = false)
@ -138,10 +138,7 @@ namespace Jackett.Common.Indexers.Abstract
}
// hook to adjust the search term
protected virtual string GetSearchTerm(TorznabQuery query)
{
return query.GetQueryString();
}
protected virtual string GetSearchTerm(TorznabQuery query) => query.GetQueryString();
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
@ -269,10 +266,7 @@ namespace Jackett.Common.Indexers.Abstract
}
// hook to add/modify the parsed information, return false to exclude the torrent from the results
protected virtual bool ReleaseInfoPostParse(ReleaseInfo release, JObject torrent, JObject result)
{
return true;
}
protected virtual bool ReleaseInfoPostParse(ReleaseInfo release, JObject torrent, JObject result) => true;
private void FillReleaseInfoFromJson(ReleaseInfo release, JObject torrent)
{

View File

@ -7,17 +7,11 @@ namespace Jackett.Common.Indexers
{
public class AlphaRatio : GazelleTracker
{
public AlphaRatio(IIndexerConfigurationService configService, Utils.Clients.WebClient webClient, Logger logger, IProtectionService protectionService)
: base(name: "AlphaRatio",
desc: "AlphaRatio (AR) is a Private Torrent Tracker for 0DAY / GENERAL",
link: "https://alpharatio.cc/",
configService: configService,
logger: logger,
protectionService: protectionService,
webClient: webClient,
supportsFreeleechTokens: true,
imdbInTags: true
)
public AlphaRatio(IIndexerConfigurationService configService, Utils.Clients.WebClient webClient, Logger logger,
IProtectionService protectionService) : base(
name: "AlphaRatio", desc: "AlphaRatio (AR) is a Private Torrent Tracker for 0DAY / GENERAL",
link: "https://alpharatio.cc/", configService: configService, logger: logger,
protectionService: protectionService, webClient: webClient, supportsFreeleechTokens: true, imdbInTags: true)
{
Language = "en-us";
Type = "private";
@ -55,9 +49,7 @@ namespace Jackett.Common.Indexers
AddCategoryMapping(30, TorznabCatType.Other, "Misc");
}
protected override string GetSearchTerm(TorznabQuery query)
{
return query.GetQueryString().Replace(".", " "); // Alpharatio can't handle dots in the searchstr
}
// Alpharatio can't handle dots in the searchstr
protected override string GetSearchTerm(TorznabQuery query) => query.GetQueryString().Replace(".", " ");
}
}

View File

@ -83,8 +83,8 @@ namespace Jackett.Common.Indexers
private ConfigurationDataAniDub Configuration
{
get { return (ConfigurationDataAniDub)configData; }
set { configData = value; }
get => (ConfigurationDataAniDub)configData;
set => configData = value;
}
/// <summary>
@ -134,18 +134,11 @@ namespace Jackett.Common.Indexers
return await base.Download(link);
}
// If the search string is empty use the latest releases
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
// If the search string is empty use the latest releases
if (query.IsTest || query.SearchTerm.IsNullOrEmptyOrWhitespace())
{
return await FetchNewReleases();
}
else
{
return await PerformSearch(query);
}
}
=> query.IsTest || query.SearchTerm.IsNullOrEmptyOrWhitespace()
? await FetchNewReleases()
: await PerformSearch(query);
private async Task EnsureAuthorized()
{
@ -258,11 +251,8 @@ namespace Jackett.Common.Indexers
return releases;
}
private static string GetReleaseGuid(string url, IElement tabNode)
{
// Appending id to differentiate between different quality versions
return QueryHelpers.AddQueryString(url, "id", GetTorrentId(tabNode));
}
// Appending id to differentiate between different quality versions
private static string GetReleaseGuid(string url, IElement tabNode) => QueryHelpers.AddQueryString(url, "id", GetTorrentId(tabNode));
private static int GetReleaseLeechers(IElement tabNode)
{
@ -443,15 +433,9 @@ namespace Jackett.Common.Indexers
return defaultSeason;
}
private string StripRussianTitle(string title)
{
if (Configuration.StripRussianTitle.Value)
{
return StripRussianTitleRegex.Value.Replace(title, string.Empty);
}
return title;
}
private string StripRussianTitle(string title) => Configuration.StripRussianTitle.Value
? StripRussianTitleRegex.Value.Replace(title, string.Empty)
: title;
private static string FixBookInfo(string title) =>
title.Replace("[Главы ", "[");

View File

@ -19,17 +19,17 @@ namespace Jackett.Common.Indexers
{
public class AnimeBytes : BaseCachingWebIndexer
{
private string ScrapeUrl { get { return SiteLink + "scrape.php"; } }
private string TorrentsUrl { get { return SiteLink + "torrents.php"; } }
public bool AllowRaws { get { return configData.IncludeRaw.Value; } }
public bool PadEpisode { get { return configData.PadEpisode != null && configData.PadEpisode.Value; } }
public bool AddSynonyms { get { return configData.AddSynonyms.Value; } }
public bool FilterSeasonEpisode { get { return configData.FilterSeasonEpisode.Value; } }
private string ScrapeUrl => SiteLink + "scrape.php";
private string TorrentsUrl => SiteLink + "torrents.php";
public bool AllowRaws => configData.IncludeRaw.Value;
public bool PadEpisode => configData.PadEpisode != null && configData.PadEpisode.Value;
public bool AddSynonyms => configData.AddSynonyms.Value;
public bool FilterSeasonEpisode => configData.FilterSeasonEpisode.Value;
private new ConfigurationDataAnimeBytes configData
{
get { return (ConfigurationDataAnimeBytes)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataAnimeBytes)base.configData;
set => base.configData = value;
}
public AnimeBytes(IIndexerConfigurationService configService, Utils.Clients.WebClient client, Logger l, IProtectionService ps)
@ -74,12 +74,10 @@ namespace Jackett.Common.Indexers
AddCategoryMapping("printedtype[artbook]", TorznabCatType.BooksComics, "Artbook");
}
// Prevent filtering
protected override IEnumerable<ReleaseInfo> FilterResults(TorznabQuery query, IEnumerable<ReleaseInfo> input) =>
protected override IEnumerable<ReleaseInfo> FilterResults(TorznabQuery query, IEnumerable<ReleaseInfo> input)
{
// Prevent filtering
return input;
}
input;
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
@ -365,24 +363,26 @@ namespace Jackett.Common.Indexers
releaseTitle = string.Format("{0}{1} {2} {3}", releasegroup, title, releaseInfo, infoString);
}
var release = new ReleaseInfo();
release.MinimumRatio = 1;
release.MinimumSeedTime = MinimumSeedTime;
release.Title = releaseTitle;
release.Comments = CommentsLinkUri;
release.Guid = new Uri(CommentsLinkUri + "&nh=" + StringUtil.Hash(title)); // Sonarr should dedupe on this url - allow a url per name.
release.Link = LinkUri;
release.BannerUrl = ImageUrl;
release.PublishDate = PublushDate;
release.Category = Category;
release.Description = Description;
release.Size = Size;
release.Seeders = Seeders;
release.Peers = Peers;
release.Grabs = Snatched;
release.Files = FileCount;
release.DownloadVolumeFactor = RawDownMultiplier;
release.UploadVolumeFactor = RawUpMultiplier;
var release = new ReleaseInfo
{
MinimumRatio = 1,
MinimumSeedTime = MinimumSeedTime,
Title = releaseTitle,
Comments = CommentsLinkUri,
Guid = new Uri(CommentsLinkUri + "&nh=" + StringUtil.Hash(title)), // Sonarr should dedupe on this url - allow a url per name.
Link = LinkUri,
BannerUrl = ImageUrl,
PublishDate = PublushDate,
Category = Category,
Description = Description,
Size = Size,
Seeders = Seeders,
Peers = Peers,
Grabs = Snatched,
Files = FileCount,
DownloadVolumeFactor = RawDownMultiplier,
UploadVolumeFactor = RawUpMultiplier
};
releases.Add(release);
}

View File

@ -19,14 +19,14 @@ namespace Jackett.Common.Indexers
{
public class AnimeTorrents : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "login.php"; } }
private string SearchUrl { get { return SiteLink + "ajax/torrents_data.php"; } }
private string SearchUrlReferer { get { return SiteLink + "torrents.php?cat=0&searchin=filename&search="; } }
private string LoginUrl => SiteLink + "login.php";
private string SearchUrl => SiteLink + "ajax/torrents_data.php";
private string SearchUrlReferer => SiteLink + "torrents.php?cat=0&searchin=filename&search=";
private new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLogin)base.configData;
set => base.configData = value;
}
public AnimeTorrents(IIndexerConfigurationService configService, WebClient c, Logger l, IProtectionService ps)

View File

@ -20,15 +20,15 @@ namespace Jackett.Common.Indexers
public class BB : BaseWebIndexer
{
private string BaseUrl { get { return StringUtil.FromBase64("aHR0cHM6Ly9iYWNvbmJpdHMub3JnLw=="); } }
private Uri BaseUri { get { return new Uri(BaseUrl); } }
private string LoginUrl { get { return BaseUri + "login.php"; } }
private string SearchUrl { get { return BaseUri + "torrents.php?searchtags=&tags_type=0&order_by=s3&order_way=desc&disablegrouping=1&"; } }
private string BaseUrl => StringUtil.FromBase64("aHR0cHM6Ly9iYWNvbmJpdHMub3JnLw==");
private Uri BaseUri => new Uri(BaseUrl);
private string LoginUrl => BaseUri + "login.php";
private string SearchUrl => BaseUri + "torrents.php?searchtags=&tags_type=0&order_by=s3&order_way=desc&disablegrouping=1&";
private new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLogin)base.configData;
set => base.configData = value;
}
public BB(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)

View File

@ -22,8 +22,8 @@ namespace Jackett.Common.Indexers
private new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLogin)base.configData;
set => base.configData = value;
}
public BakaBT(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps)

View File

@ -18,10 +18,7 @@ namespace Jackett.Common.Indexers
{
public abstract class BaseIndexer : IIndexer
{
public static string GetIndexerID(Type type)
{
return type.Name.ToLowerInvariant().StripNonAlphaNumeric();
}
public static string GetIndexerID(Type type) => type.Name.ToLowerInvariant().StripNonAlphaNumeric();
public string SiteLink { get; protected set; }
public virtual string[] LegacySiteLinks { get; protected set; }
@ -31,7 +28,7 @@ namespace Jackett.Common.Indexers
public string DisplayName { get; protected set; }
public string Language { get; protected set; }
public string Type { get; protected set; }
public virtual string ID { get { return GetIndexerID(GetType()); } }
public virtual string ID => GetIndexerID(GetType());
[JsonConverter(typeof(EncodingJsonConverter))]
public Encoding Encoding { get; protected set; }
@ -45,13 +42,13 @@ namespace Jackett.Common.Indexers
protected string CookieHeader
{
get { return configData.CookieHeader.Value; }
set { configData.CookieHeader.Value = value; }
get => configData.CookieHeader.Value;
set => configData.CookieHeader.Value = value;
}
public string LastError
{
get { return configData.LastError.Value; }
get => configData.LastError.Value;
set
{
var SaveNeeded = configData.LastError.Value != value && IsConfigured;
@ -82,10 +79,7 @@ namespace Jackett.Common.Indexers
LoadValuesFromJson(null);
}
public virtual Task<ConfigurationData> GetConfigurationForSetup()
{
return Task.FromResult<ConfigurationData>(configData);
}
public virtual Task<ConfigurationData> GetConfigurationForSetup() => Task.FromResult<ConfigurationData>(configData);
public virtual void ResetBaseConfig()
{
@ -93,10 +87,7 @@ namespace Jackett.Common.Indexers
IsConfigured = false;
}
public virtual void SaveConfig()
{
configurationService.Save(this as IIndexer, configData.ToJson(protectionService, forDisplay: false));
}
public virtual void SaveConfig() => configurationService.Save(this as IIndexer, configData.ToJson(protectionService, forDisplay: false));
protected void LoadLegacyCookieConfig(JToken jsonConfig)
{
@ -273,10 +264,9 @@ namespace Jackett.Common.Indexers
if (query.Categories.Length == 0)
return results;
var filteredResults = results.Where(result =>
{
return result.Category.IsEmptyOrNull() || query.Categories.Intersect(result.Category).Any() || TorznabCatType.QueryContainsParentCategory(query.Categories, result.Category);
});
var filteredResults = results.Where(
result => result.Category.IsEmptyOrNull() || query.Categories.Intersect(result.Category).Any() ||
TorznabCatType.QueryContainsParentCategory(query.Categories, result.Category));
return filteredResults;
}
@ -372,10 +362,7 @@ namespace Jackett.Common.Indexers
// minimal constructor used by e.g. cardigann generic indexer
protected BaseWebIndexer(IIndexerConfigurationService configService, WebClient client, Logger logger, IProtectionService p)
: base("", "/", "", configService, logger, null, p)
{
webclient = client;
}
: base("", "/", "", configService, logger, null, p) => webclient = client;
public virtual async Task<byte[]> Download(Uri link)
{
@ -671,10 +658,7 @@ namespace Jackett.Common.Indexers
}
}
protected List<string> GetAllTrackerCategories()
{
return categoryMapping.Select(x => x.TrackerCategory).ToList();
}
protected List<string> GetAllTrackerCategories() => categoryMapping.Select(x => x.TrackerCategory).ToList();
protected void AddCategoryMapping(string trackerCategory, TorznabCategory newznabCategory, string trackerCategoryDesc = null)
{
@ -703,10 +687,7 @@ namespace Jackett.Common.Indexers
}
}
protected void AddCategoryMapping(int trackerCategory, TorznabCategory newznabCategory, string trackerCategoryDesc = null)
{
AddCategoryMapping(trackerCategory.ToString(), newznabCategory, trackerCategoryDesc);
}
protected void AddCategoryMapping(int trackerCategory, TorznabCategory newznabCategory, string trackerCategoryDesc = null) => AddCategoryMapping(trackerCategory.ToString(), newznabCategory, trackerCategoryDesc);
protected void AddMultiCategoryMapping(TorznabCategory newznabCategory, params int[] trackerCategories)
{

View File

@ -17,14 +17,14 @@ namespace Jackett.Common.Indexers
{
public class BitCityReloaded : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "login/index.php"; } }
private string BrowseUrl { get { return SiteLink + "uebersicht.php"; } }
private string LoginUrl => SiteLink + "login/index.php";
private string BrowseUrl => SiteLink + "uebersicht.php";
private readonly TimeZoneInfo germanyTz = TimeZoneInfo.CreateCustomTimeZone("W. Europe Standard Time", new TimeSpan(1, 0, 0), "W. Europe Standard Time", "W. Europe Standard Time");
private new ConfigurationDataBasicLoginWithRSSAndDisplay configData
{
get { return (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData;
set => base.configData = value;
}
public BitCityReloaded(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -18,15 +18,15 @@ namespace Jackett.Common.Indexers
{
public class BitHdtv : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "login.php"; } }
private string TakeLoginUrl { get { return SiteLink + "takelogin.php"; } }
private string SearchUrl { get { return SiteLink + "torrents.php?"; } }
private string DownloadUrl { get { return SiteLink + "download.php?id={0}"; } }
private string LoginUrl => SiteLink + "login.php";
private string TakeLoginUrl => SiteLink + "takelogin.php";
private string SearchUrl => SiteLink + "torrents.php?";
private string DownloadUrl => SiteLink + "download.php?id={0}";
private new ConfigurationDataRecaptchaLogin configData
{
get { return (ConfigurationDataRecaptchaLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataRecaptchaLogin)base.configData;
set => base.configData = value;
}
public BitHdtv(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)

View File

@ -22,8 +22,8 @@ namespace Jackett.Common.Indexers
private new ConfigurationDataAPIKey configData
{
get { return (ConfigurationDataAPIKey)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataAPIKey)base.configData;
set => base.configData = value;
}
public BroadcastTheNet(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -26,7 +26,7 @@ namespace Jackett.Common.Indexers
public class CardigannIndexer : BaseWebIndexer
{
protected IndexerDefinition Definition;
public override string ID { get { return (Definition != null ? Definition.Site : GetIndexerID(GetType())); } }
public override string ID => (Definition != null ? Definition.Site : GetIndexerID(GetType()));
protected WebClientStringResult landingResult;
protected IHtmlDocument landingResultDocument;
@ -35,8 +35,8 @@ namespace Jackett.Common.Indexers
private new ConfigurationData configData
{
get { return base.configData; }
set { base.configData = value; }
get => base.configData;
set => base.configData = value;
}
protected readonly string[] OptionalFileds = new string[] { "imdb", "rageid", "tvdbid", "banner" };
@ -764,15 +764,9 @@ namespace Jackett.Common.Indexers
return null;
}
protected string getRedirectDomainHint(WebClientByteResult result)
{
return getRedirectDomainHint(result.Request.Url, result.RedirectingTo);
}
protected string getRedirectDomainHint(WebClientByteResult result) => getRedirectDomainHint(result.Request.Url, result.RedirectingTo);
protected string getRedirectDomainHint(WebClientStringResult result)
{
return getRedirectDomainHint(result.Request.Url, result.RedirectingTo);
}
protected string getRedirectDomainHint(WebClientStringResult result) => getRedirectDomainHint(result.Request.Url, result.RedirectingTo);
protected async Task<bool> TestLogin()
{
@ -1188,13 +1182,7 @@ namespace Jackett.Common.Indexers
return applyFilters(ParseUtil.NormalizeSpace(value), Selector.Filters, variables);
}
protected Uri resolvePath(string path, Uri currentUrl = null)
{
if (currentUrl == null)
currentUrl = new Uri(SiteLink);
return new Uri(currentUrl, path);
}
protected Uri resolvePath(string path, Uri currentUrl = null) => new Uri(currentUrl ?? new Uri(SiteLink), path);
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{

View File

@ -16,8 +16,6 @@ namespace Jackett.Common.Indexers
protectionService: protectionService,
webClient: webClient
)
{
Type = "private";
}
=> Type = "private";
}
}

View File

@ -19,8 +19,8 @@ namespace Jackett.Common.Indexers
private new ConfigurationDataUserPasskey configData
{
get { return (ConfigurationDataUserPasskey)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataUserPasskey)base.configData;
set => base.configData = value;
}
public DanishBits(IIndexerConfigurationService configService, WebClient c, Logger l, IProtectionService ps)

View File

@ -17,14 +17,14 @@ namespace Jackett.Common.Indexers
{
public class DigitalHive : BaseWebIndexer
{
private string SearchUrl { get { return SiteLink + "browse.php"; } }
private string LoginUrl { get { return SiteLink + "login.php?returnto=%2F"; } }
private string AjaxLoginUrl { get { return SiteLink + "takelogin.php"; } }
private string SearchUrl => SiteLink + "browse.php";
private string LoginUrl => SiteLink + "login.php?returnto=%2F";
private string AjaxLoginUrl => SiteLink + "takelogin.php";
private new ConfigurationDataRecaptchaLogin configData
{
get { return (ConfigurationDataRecaptchaLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataRecaptchaLogin)base.configData;
set => base.configData = value;
}
public DigitalHive(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)

View File

@ -18,17 +18,15 @@ namespace Jackett.Common.Indexers
{
internal class EliteTracker : BaseWebIndexer
{
private string LoginUrl
{ get { return SiteLink + "takelogin.php"; } }
private string BrowseUrl
{ get { return SiteLink + "browse.php"; } }
private string LoginUrl => SiteLink + "takelogin.php";
private string BrowseUrl => SiteLink + "browse.php";
private bool TorrentHTTPSMode => configData.TorrentHTTPSMode.Value;
private string ReplaceMulti => configData.ReplaceMulti.Value;
private new ConfigurationDataEliteTracker configData
{
get { return (ConfigurationDataEliteTracker)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataEliteTracker)base.configData;
set => base.configData = value;
}
public EliteTracker(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService)

View File

@ -23,13 +23,13 @@ namespace Jackett.Common.Indexers
"http://filelist.ro/",
};
private string LoginUrl { get { return SiteLink + "takelogin.php"; } }
private string BrowseUrl { get { return SiteLink + "browse.php"; } }
private string LoginUrl => SiteLink + "takelogin.php";
private string BrowseUrl => SiteLink + "browse.php";
private new ConfigurationDataFileList configData
{
get { return (ConfigurationDataFileList)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataFileList)base.configData;
set => base.configData = value;
}
public FileList(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -16,13 +16,13 @@ namespace Jackett.Common.Indexers
{
public class FunFile : BaseWebIndexer
{
private string SearchUrl { get { return SiteLink + "browse.php"; } }
private string LoginUrl { get { return SiteLink + "takelogin.php"; } }
private string SearchUrl => SiteLink + "browse.php";
private string LoginUrl => SiteLink + "takelogin.php";
private new ConfigurationDataBasicLoginWithRSSAndDisplay configData
{
get { return (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData;
set => base.configData = value;
}
public FunFile(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)

View File

@ -23,14 +23,14 @@ namespace Jackett.Common.Indexers
"https://fuzer.me/",
};
private string SearchUrl { get { return SiteLink + "browse.php"; } }
private string LoginUrl { get { return SiteLink + "login.php"; } }
private string SearchUrl => SiteLink + "browse.php";
private string LoginUrl => SiteLink + "login.php";
private const int MAXPAGES = 3;
private new ConfigurationDataRecaptchaLogin configData
{
get { return (ConfigurationDataRecaptchaLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataRecaptchaLogin)base.configData;
set => base.configData = value;
}
public Fuzer(IIndexerConfigurationService configService, Utils.Clients.WebClient w, Logger l, IProtectionService ps)

View File

@ -18,13 +18,13 @@ namespace Jackett.Common.Indexers
{
public class GazelleGames : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "login.php"; } }
private string BrowseUrl { get { return SiteLink + "torrents.php"; } }
private string LoginUrl => SiteLink + "login.php";
private string BrowseUrl => SiteLink + "torrents.php";
private new ConfigurationDataCookie configData
{
get { return (ConfigurationDataCookie)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataCookie)base.configData;
set => base.configData = value;
}
public GazelleGames(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -24,8 +24,8 @@ namespace Jackett.Common.Indexers
private new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLogin)base.configData;
set => base.configData = value;
}
public GimmePeers(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -15,12 +15,12 @@ namespace Jackett.Common.Indexers
{
public class HDBitsApi : BaseWebIndexer
{
private string APIUrl { get { return SiteLink + "api/"; } }
private string APIUrl => SiteLink + "api/";
private new ConfigurationDataHDBitsApi configData
{
get { return (ConfigurationDataHDBitsApi)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataHDBitsApi)base.configData;
set => base.configData = value;
}
public HDBitsApi(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -26,8 +26,8 @@ namespace Jackett.Common.Indexers
private new ConfigurationDataBasicLoginWithEmail configData
{
get { return (ConfigurationDataBasicLoginWithEmail)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithEmail)base.configData;
set => base.configData = value;
}
public HDOlimpo(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)

View File

@ -19,13 +19,13 @@ namespace Jackett.Common.Indexers
{
public class HDSpace : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "index.php?page=login"; } }
private string SearchUrl { get { return SiteLink + "index.php?page=torrents&"; } }
private string LoginUrl => SiteLink + "index.php?page=login";
private string SearchUrl => SiteLink + "index.php?page=torrents&";
private new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLogin)base.configData;
set => base.configData = value;
}
public HDSpace(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -17,15 +17,15 @@ namespace Jackett.Common.Indexers
{
public class HDTorrents : BaseWebIndexer
{
private string SearchUrl { get { return SiteLink + "torrents.php?"; } }
private string LoginUrl { get { return SiteLink + "login.php"; } }
private string SearchUrl => SiteLink + "torrents.php?";
private string LoginUrl => SiteLink + "login.php";
private const int MAXPAGES = 3;
public override string[] AlternativeSiteLinks { get; protected set; } = new string[] { "https://hdts.ru/", "https://hd-torrents.org/", "https://hd-torrents.net/", "https://hd-torrents.me/" };
private new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLogin)base.configData;
set => base.configData = value;
}
public HDTorrents(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)
@ -92,11 +92,9 @@ namespace Jackett.Common.Indexers
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, loginPage.Cookies, true, null, LoginUrl);
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("If your browser doesn't have javascript enabled"), () =>
{
var errorMessage = "Couldn't login";
throw new ExceptionWithConfigData(errorMessage, configData);
});
await ConfigureIfOK(
result.Cookies, result.Content?.Contains("If your browser doesn't have javascript enabled") == true,
() => throw new ExceptionWithConfigData("Couldn't login", configData));
return IndexerConfigurationStatus.RequiresTesting;
}

View File

@ -17,14 +17,14 @@ namespace Jackett.Common.Indexers
{
public class Hebits : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "login.php"; } }
private string LoginPostUrl { get { return SiteLink + "takeloginAjax.php"; } }
private string SearchUrl { get { return SiteLink + "browse.php?sort=4&type=desc"; } }
private string LoginUrl => SiteLink + "login.php";
private string LoginPostUrl => SiteLink + "takeloginAjax.php";
private string SearchUrl => SiteLink + "browse.php?sort=4&type=desc";
private new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLogin)base.configData;
set => base.configData = value;
}
public Hebits(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps)

View File

@ -19,7 +19,7 @@ namespace Jackett.Common.Indexers
{
internal class HorribleSubs : BaseWebIndexer
{
private string ApiEndpoint { get { return SiteLink + "api.php"; } }
private string ApiEndpoint => SiteLink + "api.php";
public override string[] LegacySiteLinks { get; protected set; } = new string[] {
"http://horriblesubs.info/"

View File

@ -17,9 +17,9 @@ namespace Jackett.Common.Indexers
{
public class ImmortalSeed : BaseWebIndexer
{
private string BrowsePage { get { return SiteLink + "browse.php"; } }
private string LoginUrl { get { return SiteLink + "takelogin.php"; } }
private string QueryString { get { return "?do=search&keywords={0}&search_type=t_name&category=0&include_dead_torrents=no"; } }
private string BrowsePage => SiteLink + "browse.php";
private string LoginUrl => SiteLink + "takelogin.php";
private string QueryString => "?do=search&keywords={0}&search_type=t_name&category=0&include_dead_torrents=no";
public override string[] LegacySiteLinks { get; protected set; } = new string[] {
"http://immortalseed.me/",
@ -27,8 +27,8 @@ namespace Jackett.Common.Indexers
private new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLogin)base.configData;
set => base.configData = value;
}
public ImmortalSeed(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps)

View File

@ -24,20 +24,20 @@ namespace Jackett.Common.Indexers
private static readonly Regex parsePlayEpisodeRegex = new Regex("PlayEpisode\\('(?<id>\\d{1,3})(?<season>\\d{3})(?<episode>\\d{3})'\\)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex parseReleaseDetailsRegex = new Regex("Видео:\\ (?<quality>.+).\\ Размер:\\ (?<size>.+).\\ Перевод", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private string LoginUrl { get { return SiteLink + "login"; } }
private string LoginUrl => SiteLink + "login";
// http://www.lostfilm.tv/login
private string ApiUrl { get { return SiteLink + "ajaxik.php"; } }
private string ApiUrl => SiteLink + "ajaxik.php";
// http://www.lostfilm.tv/new
private string DiscoveryUrl { get { return SiteLink + "new"; } }
private string DiscoveryUrl => SiteLink + "new";
// http://www.lostfilm.tv/search?q=breaking+bad
private string SearchUrl { get { return SiteLink + "search"; } }
private string SearchUrl => SiteLink + "search";
// PlayEpisode function produce urls like this:
// https://www.lostfilm.tv/v_search.php?c=119&s=5&e=16
private string ReleaseUrl { get { return SiteLink + "v_search.php"; } }
private string ReleaseUrl => SiteLink + "v_search.php";
internal class TrackerUrlDetails
@ -63,6 +63,7 @@ namespace Jackett.Common.Indexers
episode = match.Groups["episode"].Value.TrimStart('0');
}
// TODO: see if query.GetEpisodeString() is sufficient
internal string GetEpisodeString()
{
var result = string.Empty;
@ -83,8 +84,8 @@ namespace Jackett.Common.Indexers
private new ConfigurationDataCaptchaLogin configData
{
get { return (ConfigurationDataCaptchaLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataCaptchaLogin)base.configData;
set => base.configData = value;
}
public LostFilm(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -31,10 +31,7 @@ namespace Jackett.Common.Indexers.Meta
return base.CanHandleQuery(query);
}
public override Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
return Task.FromResult(IndexerConfigurationStatus.Completed);
}
public override Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson) => Task.FromResult(IndexerConfigurationStatus.Completed);
public override async Task<IndexerResult> ResultsForQuery(TorznabQuery query)
{
@ -102,32 +99,11 @@ namespace Jackett.Common.Indexers.Meta
return result;
}
public override TorznabCapabilities TorznabCaps
{
get
{
return validIndexers.Select(i => i.TorznabCaps).Aggregate(new TorznabCapabilities(), TorznabCapabilities.Concat);
}
}
public override TorznabCapabilities TorznabCaps => validIndexers.Select(i => i.TorznabCaps).Aggregate(new TorznabCapabilities(), TorznabCapabilities.Concat);
public override bool IsConfigured
{
get
{
return Indexers != null;
}
}
public override bool IsConfigured => Indexers != null;
private IEnumerable<IIndexer> validIndexers
{
get
{
if (Indexers == null)
return null;
return Indexers.Where(i => i.IsConfigured && filterFunc(i));
}
}
private IEnumerable<IIndexer> validIndexers => Indexers?.Where(i => i.IsConfigured && filterFunc(i));
public IEnumerable<IIndexer> Indexers;

View File

@ -19,18 +19,12 @@ namespace Jackett.Common.Indexers.Meta
public class NoFallbackStrategy : IFallbackStrategy
{
public Task<IEnumerable<TorznabQuery>> FallbackQueries()
{
return Task.FromResult<IEnumerable<TorznabQuery>>(new List<TorznabQuery>());
}
public Task<IEnumerable<TorznabQuery>> FallbackQueries() => Task.FromResult<IEnumerable<TorznabQuery>>(new List<TorznabQuery>());
}
public class NoFallbackStrategyProvider : IFallbackStrategyProvider
{
public IEnumerable<IFallbackStrategy> FallbackStrategiesForQuery(TorznabQuery query)
{
return (new NoFallbackStrategy()).ToEnumerable();
}
public IEnumerable<IFallbackStrategy> FallbackStrategiesForQuery(TorznabQuery query) => (new NoFallbackStrategy()).ToEnumerable();
}
public class ImdbFallbackStrategy : IFallbackStrategy
@ -44,9 +38,8 @@ namespace Jackett.Common.Indexers.Meta
public async Task<IEnumerable<TorznabQuery>> FallbackQueries()
{
if (titles == null)
titles = (await resolver.MovieForId(query.ImdbID.ToNonNull())).Title?.ToEnumerable() ?? Enumerable.Empty<string>();
return titles.Select(t => query.CreateFallback(t));
titles ??= (await resolver.MovieForId(query.ImdbID.ToNonNull())).Title?.ToEnumerable() ?? Enumerable.Empty<string>();
return titles.Select(query.CreateFallback);
}
private readonly IImdbResolver resolver;
@ -56,10 +49,7 @@ namespace Jackett.Common.Indexers.Meta
public class ImdbFallbackStrategyProvider : IFallbackStrategyProvider
{
public ImdbFallbackStrategyProvider(IImdbResolver resolver)
{
this.resolver = resolver;
}
public ImdbFallbackStrategyProvider(IImdbResolver resolver) => this.resolver = resolver;
public IEnumerable<IFallbackStrategy> FallbackStrategiesForQuery(TorznabQuery query)
{

View File

@ -8,13 +8,7 @@ namespace Jackett.Common.Indexers.Meta
{
public class AggregateIndexer : BaseMetaIndexer
{
public override string ID
{
get
{
return "all";
}
}
public override string ID => "all";
public AggregateIndexer(IFallbackStrategyProvider fallbackStrategyProvider, IResultFilterProvider resultFilterProvider, IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
: base("AggregateSearch", "This feed includes all configured trackers", fallbackStrategyProvider, resultFilterProvider, configService, wc, l, new ConfigurationData(), ps, x => true)
{

View File

@ -30,7 +30,8 @@ namespace Jackett.Common.Indexers.Meta
long? imdbId = null;
try
{
var normalizedImdbId = string.Concat(query.ImdbID.Where(c => char.IsDigit(c)));
// Convert from try/catch to long.TryParse since we're not handling the failure
var normalizedImdbId = string.Concat(query.ImdbID.Where(char.IsDigit));
imdbId = long.Parse(normalizedImdbId);
}
catch
@ -70,11 +71,8 @@ namespace Jackett.Common.Indexers.Meta
return filteredResults;
}
private static string RemoveSpecialChars(string title)
{
// TODO improve character replacement with invalid chars
return title.Replace(":", "");
}
// TODO improve character replacement with invalid chars
private static string RemoveSpecialChars(string title) => title.Replace(":", "");
private static IEnumerable<string> GenerateTitleVariants(string title)
{
@ -94,26 +92,17 @@ namespace Jackett.Common.Indexers.Meta
public class NoFilter : IResultFilter
{
public Task<IEnumerable<ReleaseInfo>> FilterResults(IEnumerable<ReleaseInfo> results)
{
return Task.FromResult(results);
}
public Task<IEnumerable<ReleaseInfo>> FilterResults(IEnumerable<ReleaseInfo> results) => Task.FromResult(results);
}
public class NoResultFilterProvider : IResultFilterProvider
{
public IEnumerable<IResultFilter> FiltersForQuery(TorznabQuery query)
{
return (new NoFilter()).ToEnumerable();
}
public IEnumerable<IResultFilter> FiltersForQuery(TorznabQuery query) => (new NoFilter()).ToEnumerable();
}
public class ImdbTitleResultFilterProvider : IResultFilterProvider
{
public ImdbTitleResultFilterProvider(IImdbResolver resolver)
{
this.resolver = resolver;
}
public ImdbTitleResultFilterProvider(IImdbResolver resolver) => this.resolver = resolver;
public IEnumerable<IResultFilter> FiltersForQuery(TorznabQuery query)
{

View File

@ -18,13 +18,13 @@ namespace Jackett.Common.Indexers
{
public class Myanonamouse : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "takelogin.php"; } }
private string SearchUrl { get { return SiteLink + "tor/js/loadSearchJSONbasic.php"; } }
private string LoginUrl => SiteLink + "takelogin.php";
private string SearchUrl => SiteLink + "tor/js/loadSearchJSONbasic.php";
private new ConfigurationDataMyAnonamouse configData
{
get { return (ConfigurationDataMyAnonamouse)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataMyAnonamouse)base.configData;
set => base.configData = value;
}
public Myanonamouse(IIndexerConfigurationService configService, WebClient c, Logger l, IProtectionService ps)

View File

@ -18,14 +18,14 @@ namespace Jackett.Common.Indexers
{
public class NCore : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "login.php"; } }
private string SearchUrl { get { return SiteLink + "torrents.php"; } }
private string LoginUrl => SiteLink + "login.php";
private string SearchUrl => SiteLink + "torrents.php";
private readonly string[] LanguageCats = new string[] { "xvidser", "dvdser", "hdser", "xvid", "dvd", "dvd9", "hd", "mp3", "lossless", "ebook" };
private new ConfigurationDataNCore configData
{
get { return (ConfigurationDataNCore)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataNCore)base.configData;
set => base.configData = value;
}
public NCore(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -17,13 +17,13 @@ namespace Jackett.Common.Indexers
{
public class NewRealWorld : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "login.php"; } }
private string BrowseUrl { get { return SiteLink + "browse.php"; } }
private string LoginUrl => SiteLink + "login.php";
private string BrowseUrl => SiteLink + "browse.php";
private new ConfigurationDataBasicLoginWithRSSAndDisplay configData
{
get { return (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData;
set => base.configData = value;
}
public NewRealWorld(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -49,10 +49,7 @@ namespace Jackett.Common.Indexers
Score = copyFrom.Score;
}
public override object Clone()
{
return new NewpctRelease(this);
}
public override object Clone() => new NewpctRelease(this);
}
private class DownloadMatcher
@ -156,10 +153,8 @@ namespace Jackett.Common.Indexers
configData.LoadValuesFromJson(configJson);
var releases = await PerformQuery(new TorznabQuery());
await ConfigureIfOK(string.Empty, releases.Count() > 0, () =>
{
throw new Exception("Could not find releases from this URL");
});
await ConfigureIfOK(string.Empty, releases.Any(), () =>
throw new Exception("Could not find releases from this URL"));
return IndexerConfigurationStatus.Completed;
}
@ -837,13 +832,10 @@ namespace Jackett.Common.Indexers
}
}
private ReleaseType ReleaseTypeFromQuality(string quality)
{
if (quality.Trim().ToLower().StartsWith("hdtv"))
return ReleaseType.TV;
else
return ReleaseType.Movie;
}
private static ReleaseType ReleaseTypeFromQuality(string quality) =>
quality.Trim().ToLower().StartsWith("hdtv")
? ReleaseType.TV
: ReleaseType.Movie;
private NewpctRelease GetReleaseFromData(ReleaseType releaseType, string title, string detailsUrl, string quality, string language, long size, DateTime publishDate)
{

View File

@ -18,13 +18,13 @@ namespace Jackett.Common.Indexers
{
public class Partis : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "user/login/"; } }
private string SearchUrl { get { return SiteLink + "torrent/show/"; } }
private string LoginUrl => SiteLink + "user/login/";
private string SearchUrl => SiteLink + "torrent/show/";
private new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLogin)base.configData;
set => base.configData = value;
}
public Partis(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
@ -141,7 +141,7 @@ namespace Jackett.Common.Indexers
results = await RequestStringWithCookies(searchUrl, null, SearchUrl, heder);
await FollowIfRedirect(results, null, null, null, true);
/// are we logged in?
// are we logged in?
if (!results.Content.Contains("/odjava"))
{
await ApplyConfiguration(null);

View File

@ -17,16 +17,16 @@ namespace Jackett.Common.Indexers
{
public class PassThePopcorn : BaseWebIndexer
{
private string LoginUrl { get { return "https://passthepopcorn.me/ajax.php?action=login"; } }
private string indexUrl { get { return "https://passthepopcorn.me/ajax.php?action=login"; } }
private string SearchUrl { get { return "https://passthepopcorn.me/torrents.php"; } }
private string DetailURL { get { return "https://passthepopcorn.me/torrents.php?torrentid="; } }
private string LoginUrl => "https://passthepopcorn.me/ajax.php?action=login";
private string indexUrl => "https://passthepopcorn.me/ajax.php?action=login";
private string SearchUrl => "https://passthepopcorn.me/torrents.php";
private string DetailURL => "https://passthepopcorn.me/torrents.php?torrentid=";
private string AuthKey { get; set; }
private new ConfigurationDataAPILoginWithUserAndPasskeyAndFilter configData
{
get { return (ConfigurationDataAPILoginWithUserAndPasskeyAndFilter)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataAPILoginWithUserAndPasskeyAndFilter)base.configData;
set => base.configData = value;
}
public PassThePopcorn(IIndexerConfigurationService configService, Utils.Clients.WebClient c, Logger l, IProtectionService ps)

View File

@ -17,15 +17,13 @@ namespace Jackett.Common.Indexers
{
public class PiXELHD : BaseWebIndexer
{
private string LoginUrl
{ get { return SiteLink + "login.php"; } }
private string BrowseUrl
{ get { return SiteLink + "torrents.php"; } }
private string LoginUrl => SiteLink + "login.php";
private string BrowseUrl => SiteLink + "torrents.php";
private new ConfigurationDataCaptchaLogin configData
{
get { return (ConfigurationDataCaptchaLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataCaptchaLogin)base.configData;
set => base.configData = value;
}
private string input_captcha = null;

View File

@ -18,16 +18,16 @@ namespace Jackett.Common.Indexers
{
public class PirateTheNet : BaseWebIndexer
{
private string SearchUrl { get { return SiteLink + "torrentsutils.php"; } }
private string LoginUrl { get { return SiteLink + "takelogin.php"; } }
private string CaptchaUrl { get { return SiteLink + "simpleCaptcha.php?numImages=1"; } }
private string SearchUrl => SiteLink + "torrentsutils.php";
private string LoginUrl => SiteLink + "takelogin.php";
private string CaptchaUrl => SiteLink + "simpleCaptcha.php?numImages=1";
private readonly TimeZoneInfo germanyTz = TimeZoneInfo.CreateCustomTimeZone("W. Europe Standard Time", new TimeSpan(1, 0, 0), "W. Europe Standard Time", "W. Europe Standard Time");
private readonly List<string> categories = new List<string>() { "1080P", "720P", "BDRip", "BluRay", "BRRip", "DVDR", "DVDRip", "FLAC", "MP3", "MP4", "Packs", "R5", "Remux", "TVRip", "WebRip" };
private new ConfigurationDataBasicLoginWithRSSAndDisplay configData
{
get { return (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData;
set => base.configData = value;
}
public PirateTheNet(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)

View File

@ -15,9 +15,9 @@ namespace Jackett.Common.Indexers
{
public class PolishTracker : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "login"; } }
private string TorrentApiUrl { get { return SiteLink + "apitorrents"; } }
private string CDNUrl { get { return "https://cdn.pte.nu/"; } }
private string LoginUrl => SiteLink + "login";
private string TorrentApiUrl => SiteLink + "apitorrents";
private string CDNUrl => "https://cdn.pte.nu/";
public override string[] LegacySiteLinks { get; protected set; } = new string[] {
"https://polishtracker.net/",
@ -25,8 +25,8 @@ namespace Jackett.Common.Indexers
private new ConfigurationDataBasicLoginWithEmail configData
{
get { return (ConfigurationDataBasicLoginWithEmail)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithEmail)base.configData;
set => base.configData = value;
}
public PolishTracker(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -18,16 +18,16 @@ namespace Jackett.Common.Indexers
{
public class Pretome : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "takelogin.php"; } }
private string LoginReferer { get { return SiteLink + "index.php?cat=1"; } }
private string SearchUrl { get { return SiteLink + "browse.php"; } }
private string LoginUrl => SiteLink + "takelogin.php";
private string LoginReferer => SiteLink + "index.php?cat=1";
private string SearchUrl => SiteLink + "browse.php";
private readonly List<CategoryMapping> resultMapping = new List<CategoryMapping>();
private new ConfigurationDataPinNumber configData
{
get { return (ConfigurationDataPinNumber)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataPinNumber)base.configData;
set => base.configData = value;
}
public Pretome(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -16,8 +16,6 @@ namespace Jackett.Common.Indexers
protectionService: protectionService,
webClient: webClient
)
{
Type = "private";
}
=> Type = "private";
}
}

View File

@ -24,16 +24,16 @@ namespace Jackett.Common.Indexers
private Uri BaseUri
{
get { return new Uri(configData.Url.Value); }
set { configData.Url.Value = value.ToString(); }
get => new Uri(configData.Url.Value);
set => configData.Url.Value = value.ToString();
}
private string ApiEndpoint { get { return BaseUri + "pubapi_v2.php"; } }
private string ApiEndpoint => BaseUri + "pubapi_v2.php";
private new ConfigurationDataUrl configData
{
get { return (ConfigurationDataUrl)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataUrl)base.configData;
set => base.configData = value;
}
private DateTime lastTokenFetch;
@ -44,7 +44,7 @@ namespace Jackett.Common.Indexers
private readonly TimeSpan TOKEN_DURATION = TimeSpan.FromMinutes(10);
private bool HasValidToken { get { return !string.IsNullOrEmpty(token) && lastTokenFetch > DateTime.Now - TOKEN_DURATION; } }
private bool HasValidToken => !string.IsNullOrEmpty(token) && lastTokenFetch > DateTime.Now - TOKEN_DURATION;
public Rarbg(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps)
: base(name: "RARBG",
@ -145,10 +145,7 @@ namespace Jackett.Common.Indexers
return IndexerConfigurationStatus.Completed;
}
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
return await PerformQuery(query, 0);
}
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query) => await PerformQuery(query, 0);
private async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query, int attempts)
{

View File

@ -19,17 +19,17 @@ namespace Jackett.Common.Indexers
{
public class RevolutionTT : BaseWebIndexer
{
private string LandingPageURL { get { return SiteLink + "login.php"; } }
private string LoginUrl { get { return SiteLink + "takelogin.php"; } }
private string GetRSSKeyUrl { get { return SiteLink + "getrss.php"; } }
private string RSSUrl { get { return SiteLink + "rss.php?feed=dl&passkey="; } }
private string SearchUrl { get { return SiteLink + "browse.php"; } }
private string DetailsURL { get { return SiteLink + "details.php?id={0}&hit=1"; } }
private string LandingPageURL => SiteLink + "login.php";
private string LoginUrl => SiteLink + "takelogin.php";
private string GetRSSKeyUrl => SiteLink + "getrss.php";
private string RSSUrl => SiteLink + "rss.php?feed=dl&passkey=";
private string SearchUrl => SiteLink + "browse.php";
private string DetailsURL => SiteLink + "details.php?id={0}&hit=1";
private new ConfigurationDataBasicLoginWithRSS configData
{
get { return (ConfigurationDataBasicLoginWithRSS)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithRSS)base.configData;
set => base.configData = value;
}
public RevolutionTT(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps)

View File

@ -17,12 +17,12 @@ namespace Jackett.Common.Indexers
{
public class SceneHD : BaseWebIndexer
{
private string SearchUrl { get { return SiteLink + "browse.php"; } }
private string SearchUrl => SiteLink + "browse.php";
private new ConfigurationDataCookie configData
{
get { return (ConfigurationDataCookie)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataCookie)base.configData;
set => base.configData = value;
}
public SceneHD(IIndexerConfigurationService configService, WebClient c, Logger l, IProtectionService ps)

View File

@ -19,16 +19,16 @@ namespace Jackett.Common.Indexers
{
public class SceneTime : BaseWebIndexer
{
private string StartPageUrl { get { return SiteLink + "login.php"; } }
private string LoginUrl { get { return SiteLink + "takelogin.php"; } }
private string SearchUrl { get { return SiteLink + "browse.php"; } }
private string DownloadUrl { get { return SiteLink + "download.php/{0}/download.torrent"; } }
private string StartPageUrl => SiteLink + "login.php";
private string LoginUrl => SiteLink + "takelogin.php";
private string SearchUrl => SiteLink + "browse.php";
private string DownloadUrl => SiteLink + "download.php/{0}/download.torrent";
private new ConfigurationDataSceneTime configData
{
get { return (ConfigurationDataSceneTime)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataSceneTime)base.configData;
set => base.configData = value;
}
public SceneTime(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)

View File

@ -17,16 +17,16 @@ namespace Jackett.Common.Indexers
{
public class Shazbat : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "login"; } }
private string SearchUrl { get { return SiteLink + "search"; } }
private string TorrentsUrl { get { return SiteLink + "torrents"; } }
private string ShowUrl { get { return SiteLink + "show?id="; } }
private string RSSProfile { get { return SiteLink + "rss_feeds"; } }
private string LoginUrl => SiteLink + "login";
private string SearchUrl => SiteLink + "search";
private string TorrentsUrl => SiteLink + "torrents";
private string ShowUrl => SiteLink + "show?id=";
private string RSSProfile => SiteLink + "rss_feeds";
private new ConfigurationDataBasicLoginWithRSS configData
{
get { return (ConfigurationDataBasicLoginWithRSS)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithRSS)base.configData;
set => base.configData = value;
}
public Shazbat(IIndexerConfigurationService configService, WebClient c, Logger l, IProtectionService ps)
@ -62,10 +62,8 @@ namespace Jackett.Common.Indexers
var firstRequest = await RequestStringWithCookiesAndRetry(LoginUrl);
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, null, true, null, LoginUrl);
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("glyphicon-log-out"), () =>
{
throw new ExceptionWithConfigData("The username and password entered do not match.", configData);
});
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("glyphicon-log-out"),
() => throw new ExceptionWithConfigData("The username and password entered do not match.", configData));
var rssProfile = await RequestStringWithCookiesAndRetry(RSSProfile);
CQ rssDom = rssProfile.Content;

View File

@ -17,15 +17,15 @@ namespace Jackett.Common.Indexers
{
public class ShowRSS : BaseWebIndexer
{
private string SearchAllUrl { get { return SiteLink + "other/all.rss"; } }
private string SearchAllUrl => SiteLink + "other/all.rss";
public override string[] LegacySiteLinks { get; protected set; } = new string[] {
"http://showrss.info/",
};
private new ConfigurationData configData
{
get { return base.configData; }
set { base.configData = value; }
get => base.configData;
set => base.configData = value;
}
public ShowRSS(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
@ -49,18 +49,13 @@ namespace Jackett.Common.Indexers
configData.LoadValuesFromJson(configJson);
var releases = await PerformQuery(new TorznabQuery());
await ConfigureIfOK(string.Empty, releases.Count() > 0, () =>
{
throw new Exception("Could not find releases from this URL");
});
await ConfigureIfOK(string.Empty, releases.Any(),
() => throw new Exception("Could not find releases from this URL"));
return IndexerConfigurationStatus.RequiresTesting;
}
public override Task<byte[]> Download(Uri link)
{
throw new NotImplementedException();
}
public override Task<byte[]> Download(Uri link) => throw new NotImplementedException();
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{

View File

@ -18,13 +18,13 @@ namespace Jackett.Common.Indexers
{
public class SpeedCD : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "take_login.php"; } }
private string SearchUrl { get { return SiteLink + "browse.php"; } }
private string LoginUrl => SiteLink + "take_login.php";
private string SearchUrl => SiteLink + "browse.php";
private new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLogin)base.configData;
set => base.configData = value;
}
public SpeedCD(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
@ -167,6 +167,8 @@ namespace Jackett.Common.Indexers
var cat = torrentData.Find("img[class^='Tcat']").First().Parent().Attr("href").Trim().Remove(0, 5);
long.TryParse(cat, out var category);
// This fixes the mixed initializer issue, so it's just inconsistent in the code base.
// https://github.com/Jackett/Jackett/pull/7166#discussion_r376817517
var release = new ReleaseInfo();
release.Title = title;

View File

@ -18,13 +18,13 @@ namespace Jackett.Common.Indexers
{
public class Superbits : BaseWebIndexer
{
private string SearchUrl { get { return SiteLink + "api/v1/torrents"; } }
private string LoginUrl { get { return SiteLink + "api/v1/auth"; } }
private string SearchUrl => SiteLink + "api/v1/torrents";
private string LoginUrl => SiteLink + "api/v1/auth";
private new ConfigurationDataCookie configData
{
get { return (ConfigurationDataCookie)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataCookie)base.configData;
set => base.configData = value;
}
public Superbits(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)
@ -97,6 +97,8 @@ namespace Jackett.Common.Indexers
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
// And this was option one from
// https://github.com/Jackett/Jackett/pull/7166#discussion_r376817517
var releases = new List<ReleaseInfo>();
var queryCollection = new NameValueCollection();
var searchString = query.GetQueryString();

View File

@ -17,13 +17,13 @@ namespace Jackett.Common.Indexers
{
public class TVVault : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "login.php"; } }
private string BrowseUrl { get { return SiteLink + "torrents.php"; } }
private string LoginUrl => SiteLink + "login.php";
private string BrowseUrl => SiteLink + "torrents.php";
private new ConfigurationDataBasicLoginWithRSSAndDisplay configData
{
get { return (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData;
set => base.configData = value;
}
public TVVault(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
@ -58,11 +58,8 @@ namespace Jackett.Common.Indexers
};
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, null, true, null, LoginUrl, true);
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("logout.php"), () =>
{
var errorMessage = result.Content;
throw new ExceptionWithConfigData(errorMessage, configData);
});
await ConfigureIfOK(result.Cookies, result.Content?.Contains("logout.php") == true,
() => throw new ExceptionWithConfigData(result.Content, configData));
return IndexerConfigurationStatus.RequiresTesting;
}

View File

@ -19,18 +19,18 @@ namespace Jackett.Common.Indexers
public class TVstore : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "takelogin.php"; } }
private string LoginPageUrl { get { return SiteLink + "login.php?returnto=%2F"; } }
private string SearchUrl { get { return SiteLink + "torrent/br_process.php"; } }
private string DownloadUrl { get { return SiteLink + "torrent/download.php"; } }
private string BrowseUrl { get { return SiteLink + "torrent/browse.php"; } }
private string LoginUrl => SiteLink + "takelogin.php";
private string LoginPageUrl => SiteLink + "login.php?returnto=%2F";
private string SearchUrl => SiteLink + "torrent/br_process.php";
private string DownloadUrl => SiteLink + "torrent/download.php";
private string BrowseUrl => SiteLink + "torrent/browse.php";
private readonly List<SeriesDetail> series = new List<SeriesDetail>();
private readonly Regex _searchStringRegex = new Regex(@"(.+?)S0?(\d+)(E0?(\d+))?$", RegexOptions.IgnoreCase);
private new ConfigurationDataTVstore configData
{
get { return (ConfigurationDataTVstore)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataTVstore)base.configData;
set => base.configData = value;
}
public TVstore(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps)
@ -68,11 +68,8 @@ namespace Jackett.Common.Indexers
};
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, loginPage.Cookies, true, referer: SiteLink);
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("Főoldal"), () =>
{
throw new ExceptionWithConfigData("Error while trying to login with: Username: " + configData.Username.Value +
" Password: " + configData.Password.Value, configData);
});
await ConfigureIfOK(result.Cookies, result.Content?.Contains("Főoldal") == true, () => throw new ExceptionWithConfigData(
$"Error while trying to login with: Username: {configData.Username.Value} Password: {configData.Password.Value}", configData));
return IndexerConfigurationStatus.RequiresTesting;
}

View File

@ -17,13 +17,13 @@ namespace Jackett.Common.Indexers
{
public class TorrentBytes : BaseWebIndexer
{
private string BrowseUrl { get { return SiteLink + "browse.php"; } }
private string LoginUrl { get { return SiteLink + "takelogin.php"; } }
private string BrowseUrl => SiteLink + "browse.php";
private string LoginUrl => SiteLink + "takelogin.php";
private new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLogin)base.configData;
set => base.configData = value;
}
public TorrentBytes(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -18,9 +18,9 @@ namespace Jackett.Common.Indexers
{
public class TorrentDay : BaseWebIndexer
{
private string StartPageUrl { get { return SiteLink + "login.php"; } }
private string LoginUrl { get { return SiteLink + "tak3login.php"; } }
private string SearchUrl { get { return SiteLink + "t.json"; } }
private string StartPageUrl => SiteLink + "login.php";
private string LoginUrl => SiteLink + "tak3login.php";
private string SearchUrl => SiteLink + "t.json";
public override string[] LegacySiteLinks { get; protected set; } = new string[] {
"https://torrentday.com/",
@ -47,8 +47,8 @@ namespace Jackett.Common.Indexers
private new ConfigurationDataRecaptchaLogin configData
{
get { return (ConfigurationDataRecaptchaLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataRecaptchaLogin)base.configData;
set => base.configData = value;
}
public TorrentDay(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -23,13 +23,13 @@ namespace Jackett.Common.Indexers
"https://torrentheaven.myfqdn.info/",
};
private string IndexUrl { get { return SiteLink + "index.php"; } }
private string LoginCompleteUrl { get { return SiteLink + "index.php?strWebValue=account&strWebAction=login_complete&ancestry=verify"; } }
private string IndexUrl => SiteLink + "index.php";
private string LoginCompleteUrl => SiteLink + "index.php?strWebValue=account&strWebAction=login_complete&ancestry=verify";
private new ConfigurationDataCaptchaLogin configData
{
get { return (ConfigurationDataCaptchaLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataCaptchaLogin)base.configData;
set => base.configData = value;
}
public TorrentHeaven(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -23,13 +23,13 @@ namespace Jackett.Common.Indexers
"https://v4.torrentleech.org/",
};
private string LoginUrl { get { return SiteLink + "user/account/login/"; } }
private string SearchUrl { get { return SiteLink + "torrents/browse/list/"; } }
private string LoginUrl => SiteLink + "user/account/login/";
private string SearchUrl => SiteLink + "torrents/browse/list/";
private new ConfigurationDataRecaptchaLogin configData
{
get { return (ConfigurationDataRecaptchaLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataRecaptchaLogin)base.configData;
set => base.configData = value;
}
public TorrentLeech(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps)

View File

@ -17,7 +17,7 @@ namespace Jackett.Common.Indexers
{
public class TorrentNetwork : BaseWebIndexer
{
private string APIUrl { get { return SiteLink + "api/"; } }
private string APIUrl => SiteLink + "api/";
private string passkey;
private readonly Dictionary<string, string> APIHeaders = new Dictionary<string, string>()
@ -27,8 +27,8 @@ namespace Jackett.Common.Indexers
private new ConfigurationDataBasicLoginWithRSSAndDisplay configData
{
get { return (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData;
set => base.configData = value;
}
public TorrentNetwork(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -19,15 +19,15 @@ namespace Jackett.Common.Indexers
{
public class TorrentSyndikat : BaseWebIndexer
{
private string SearchUrl { get { return SiteLink + "browse.php"; } }
private string LoginUrl { get { return SiteLink + "eing2.php"; } }
private string CaptchaUrl { get { return SiteLink + "simpleCaptcha.php?numImages=1"; } }
private string SearchUrl => SiteLink + "browse.php";
private string LoginUrl => SiteLink + "eing2.php";
private string CaptchaUrl => SiteLink + "simpleCaptcha.php?numImages=1";
private readonly TimeZoneInfo germanyTz;
private new ConfigurationDataBasicLoginWithRSSAndDisplay configData
{
get { return (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData;
set => base.configData = value;
}
public TorrentSyndikat(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)
@ -121,11 +121,8 @@ namespace Jackett.Common.Indexers
var result2 = await RequestLoginAndFollowRedirect(LoginUrl, pairs, result1.Cookies, true, null, null, true);
await ConfigureIfOK(result2.Cookies, result2.Content.Contains("/logout.php"), () =>
{
var errorMessage = result2.Content;
throw new ExceptionWithConfigData(errorMessage, configData);
});
await ConfigureIfOK(result2.Cookies, result2.Content.Contains("/logout.php"),
() => throw new ExceptionWithConfigData(result2.Content, configData));
return IndexerConfigurationStatus.RequiresTesting;
}

View File

@ -20,13 +20,13 @@ namespace Jackett.Common.Indexers
{
public class Torrentech : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "index.php?act=Login&CODE=01&CookieDate=1"; } }
private string IndexUrl { get { return SiteLink + "index.php"; } }
private string LoginUrl => SiteLink + "index.php?act=Login&CODE=01&CookieDate=1";
private string IndexUrl => SiteLink + "index.php";
private new ConfigurationDataBasicLoginWithRSSAndDisplay configData
{
get { return (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData;
set => base.configData = value;
}
public Torrentech(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps)

View File

@ -17,12 +17,12 @@ namespace Jackett.Common.Indexers
public class Torrentscsv : BaseWebIndexer
{
private string ApiEndpoint { get { return SiteLink + "service/search"; } }
private string ApiEndpoint => SiteLink + "service/search";
private new ConfigurationData configData
{
get { return base.configData; }
set { base.configData = value; }
get => base.configData;
set => base.configData = value;
}
public Torrentscsv(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(
@ -68,10 +68,7 @@ namespace Jackett.Common.Indexers
return IndexerConfigurationStatus.Completed;
}
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
return await PerformQuery(query, 0);
}
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query) => await PerformQuery(query, 0);
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query, int attempts)
{

View File

@ -17,13 +17,13 @@ namespace Jackett.Common.Indexers
{
public class TransmitheNet : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "login.php"; } }
private string SearchUrl { get { return SiteLink + "torrents.php?action=basic&order_by=time&order_way=desc&search_type=0&taglist=&tags_type=0"; } }
private string LoginUrl => SiteLink + "login.php";
private string SearchUrl => SiteLink + "torrents.php?action=basic&order_by=time&order_way=desc&search_type=0&taglist=&tags_type=0";
private new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLogin)base.configData;
set => base.configData = value;
}
public TransmitheNet(IIndexerConfigurationService configService, Utils.Clients.WebClient c, Logger l, IProtectionService ps)

View File

@ -29,8 +29,8 @@ namespace Jackett.Common.Indexers
private new ConfigurationDataBasicLoginWithRSSAndDisplay configData
{
get { return (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData;
set => base.configData = value;
}
public XSpeeds(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -136,6 +136,10 @@ namespace Jackett.Common.Indexers
/// </summary>
/// <param name="configJson">Our params in Json</param>
/// <returns>Configuration state</returns>
// Warning 1998 is async method with no await calls inside
// TODO: Remove pragma by wrapping return in Task.FromResult and removing async
#pragma warning disable 1998
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
@ -322,10 +326,7 @@ namespace Jackett.Common.Indexers
public string download_link { get; set; }
public int tmdb_id { get; set; }
public override string ToString()
{
return string.Format("[XthorTorrent: id={0}, category={1}, seeders={2}, leechers={3}, name={4}, times_completed={5}, size={6}, added={7}, freeleech={8}, numfiles={9}, release_group={10}, download_link={11}, tmdb_id={12}]", id, category, seeders, leechers, name, times_completed, size, added, freeleech, numfiles, release_group, download_link, tmdb_id);
}
public override string ToString() => string.Format("[XthorTorrent: id={0}, category={1}, seeders={2}, leechers={3}, name={4}, times_completed={5}, size={6}, added={7}, freeleech={8}, numfiles={9}, release_group={10}, download_link={11}, tmdb_id={12}]", id, category, seeders, leechers, name, times_completed, size, added, freeleech, numfiles, release_group, download_link, tmdb_id);
}
/// <summary>

View File

@ -18,13 +18,13 @@ namespace Jackett.Common.Indexers
{
public class Digitalcore : BaseWebIndexer
{
private string SearchUrl { get { return SiteLink + "api/v1/torrents"; } }
private string LoginUrl { get { return SiteLink + "api/v1/auth"; } }
private string SearchUrl => SiteLink + "api/v1/torrents";
private string LoginUrl => SiteLink + "api/v1/auth";
private new ConfigurationDataCookie configData
{
get { return (ConfigurationDataCookie)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataCookie)base.configData;
set => base.configData = value;
}

View File

@ -17,13 +17,13 @@ namespace Jackett.Common.Indexers
{
public class myAmity : BaseWebIndexer
{
private string LoginUrl { get { return SiteLink + "account-login.php"; } }
private string BrowseUrl { get { return SiteLink + "torrents-search.php"; } }
private string LoginUrl => SiteLink + "account-login.php";
private string BrowseUrl => SiteLink + "torrents-search.php";
private new ConfigurationDataBasicLoginWithRSSAndDisplay configData
{
get { return (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData;
set => base.configData = value;
}
public myAmity(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -18,18 +18,16 @@ namespace Jackett.Common.Indexers
{
public class Pornolab : BaseWebIndexer
{
private string LoginUrl
{ get { return SiteLink + "forum/login.php"; } }
private string SearchUrl
{ get { return SiteLink + "forum/tracker.php"; } }
private string LoginUrl => SiteLink + "forum/login.php";
private string SearchUrl => SiteLink + "forum/tracker.php";
protected string cap_sid = null;
protected string cap_code_field = null;
private new ConfigurationDataPornolab configData
{
get { return (ConfigurationDataPornolab)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataPornolab)base.configData;
set => base.configData = value;
}
public Pornolab(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -18,18 +18,16 @@ namespace Jackett.Common.Indexers
{
public class RuTracker : BaseWebIndexer
{
private string LoginUrl
{ get { return SiteLink + "forum/login.php"; } }
private string SearchUrl
{ get { return SiteLink + "forum/tracker.php"; } }
private string LoginUrl => SiteLink + "forum/login.php";
private string SearchUrl => SiteLink + "forum/tracker.php";
protected string cap_sid = null;
protected string cap_code_field = null;
private new ConfigurationDataRutracker configData
{
get { return (ConfigurationDataRutracker)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataRutracker)base.configData;
set => base.configData = value;
}
public RuTracker(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -17,18 +17,16 @@ namespace Jackett.Common.Indexers
{
public class Toloka : BaseWebIndexer
{
private string LoginUrl
{ get { return SiteLink + "/login.php"; } }
private string SearchUrl
{ get { return SiteLink + "/tracker.php"; } }
private string LoginUrl => SiteLink + "/login.php";
private string SearchUrl => SiteLink + "/tracker.php";
protected string cap_sid = null;
protected string cap_code_field = null;
private new ConfigurationDataToloka configData
{
get { return (ConfigurationDataToloka)base.configData; }
set { base.configData = value; }
get => (ConfigurationDataToloka)base.configData;
set => base.configData = value;
}
public Toloka(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)

View File

@ -23,12 +23,12 @@ namespace Jackett.Common.Indexers
"https://yts.lt/",
};
private string ApiEndpoint { get { return SiteLink + "api/v2/list_movies.json"; } }
private string ApiEndpoint => SiteLink + "api/v2/list_movies.json";
private new ConfigurationData configData
{
get { return base.configData; }
set { base.configData = value; }
get => base.configData;
set => base.configData = value;
}
public Yts(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
@ -63,18 +63,13 @@ namespace Jackett.Common.Indexers
configData.LoadValuesFromJson(configJson);
var releases = await PerformQuery(new TorznabQuery());
await ConfigureIfOK(string.Empty, releases.Count() > 0, () =>
{
throw new Exception("Could not find releases from this URL");
});
await ConfigureIfOK(string.Empty, releases.Count() > 0,
() => throw new Exception("Could not find releases from this URL"));
return IndexerConfigurationStatus.Completed;
}
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
return await PerformQuery(query, 0);
}
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query) => await PerformQuery(query, 0);
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query, int attempts)
{

View File

@ -4,6 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Version>0.0.0</Version>
<NoWarn>NU1605</NoWarn>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>

View File

@ -6,29 +6,18 @@ namespace Jackett.Common.Models
public class CachedQueryResult
{
private readonly List<ReleaseInfo> results;
private readonly DateTime created;
private readonly string query;
public CachedQueryResult(string query, List<ReleaseInfo> results)
{
this.results = results;
created = DateTime.Now;
this.query = query;
Created = DateTime.Now;
Query = query;
}
public IReadOnlyList<ReleaseInfo> Results
{
get { return results.AsReadOnly(); }
}
public IReadOnlyList<ReleaseInfo> Results => results.AsReadOnly();
public DateTime Created
{
get { return created; }
}
public DateTime Created { get; }
public string Query
{
get { return query; }
}
public string Query { get; }
}
}

View File

@ -42,22 +42,12 @@ namespace Jackett.Common.Models.Config
public string ProxyUsername { get; set; }
public string ProxyPassword { get; set; }
public bool ProxyIsAnonymous
{
get
{
return string.IsNullOrWhiteSpace(ProxyUsername) || string.IsNullOrWhiteSpace(ProxyPassword);
}
}
public bool ProxyIsAnonymous => string.IsNullOrWhiteSpace(ProxyUsername) || string.IsNullOrWhiteSpace(ProxyPassword);
public string GetProxyAuthString()
{
if (!ProxyIsAnonymous)
{
return $"{ProxyUsername}:{ProxyPassword}";
}
return null;
}
public string GetProxyAuthString() =>
!ProxyIsAnonymous
? $"{ProxyUsername}:{ProxyPassword}"
: null;
public string GetProxyUrl(bool withCreds = false)
{
@ -138,12 +128,7 @@ namespace Jackett.Common.Models.Config
}
}
public void ConfigChanged()
{
foreach (var obs in observers)
{
obs.OnNext(this);
}
}
public void ConfigChanged() =>
observers.ForEach(obs=>obs.OnNext(this));
}
}

View File

@ -47,10 +47,7 @@ namespace Jackett.Common.Models.DTO
[DataMember]
public string proxy_password { get; set; }
public ServerConfig()
{
notices = new string[0];
}
public ServerConfig() => notices = new string[0];
public ServerConfig(IEnumerable<string> notices, Models.Config.ServerConfig config, string version, bool canRunNetCore)
{

View File

@ -5,9 +5,6 @@ namespace Jackett.Common.Models.IndexerConfig.Bespoke
public BoolItem StripRussianLetters { get; private set; }
public ConfigurationDataPornolab()
: base()
{
StripRussianLetters = new BoolItem() { Name = "Strip Russian Letters", Value = false };
}
=> StripRussianLetters = new BoolItem() { Name = "Strip Russian Letters", Value = false };
}
}

View File

@ -5,9 +5,6 @@ namespace Jackett.Common.Models.IndexerConfig.Bespoke
public BoolItem StripCyrillicLetters { get; private set; }
public ConfigurationDataToloka()
: base()
{
StripCyrillicLetters = new BoolItem() { Name = "Strip Cyrillic Letters", Value = true };
}
=> StripCyrillicLetters = new BoolItem() { Name = "Strip Cyrillic Letters", Value = true };
}
}

View File

@ -33,10 +33,7 @@ namespace Jackett.Common.Models.IndexerConfig
}
public ConfigurationData(JToken json, IProtectionService ps)
{
LoadValuesFromJson(json, ps);
}
public ConfigurationData(JToken json, IProtectionService ps) => LoadValuesFromJson(json, ps);
public void LoadValuesFromJson(JToken json, IProtectionService ps = null)
{
@ -188,11 +185,9 @@ namespace Jackett.Common.Models.IndexerConfig
return properties.ToArray();
}
public void AddDynamic(string ID, Item item)
{
dynamics[ID] = item;
}
public void AddDynamic(string ID, Item item) => dynamics[ID] = item;
// TODO Convert to TryGetValue to avoid throwing exception
public Item GetDynamic(string ID)
{
try
@ -206,15 +201,13 @@ namespace Jackett.Common.Models.IndexerConfig
}
public Item GetDynamicByName(string Name)
{
return dynamics.Values.Where(i => string.Equals(i.Name, Name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
}
=> dynamics.Values.FirstOrDefault(i => string.Equals(i.Name, Name, StringComparison.InvariantCultureIgnoreCase));
public class Item
{
public ItemType ItemType { get; set; }
public string Name { get; set; }
public string ID { get { return Name.Replace(" ", "").ToLower(); } }
public string ID => Name.Replace(" ", "").ToLower();
}
public class HiddenItem : StringItem
@ -240,10 +233,7 @@ namespace Jackett.Common.Models.IndexerConfig
public string SiteKey { get; set; }
public string Value { get; set; }
public string Cookie { get; set; }
public StringItem()
{
ItemType = ConfigurationData.ItemType.InputString;
}
public StringItem() => ItemType = ItemType.InputString;
}
public class RecaptchaItem : StringItem
@ -253,26 +243,20 @@ namespace Jackett.Common.Models.IndexerConfig
public RecaptchaItem()
{
Version = "2";
ItemType = ConfigurationData.ItemType.Recaptcha;
ItemType = ItemType.Recaptcha;
}
}
public class BoolItem : Item
{
public bool Value { get; set; }
public BoolItem()
{
ItemType = ConfigurationData.ItemType.InputBool;
}
public BoolItem() => ItemType = ItemType.InputBool;
}
public class ImageItem : Item
{
public byte[] Value { get; set; }
public ImageItem()
{
ItemType = ConfigurationData.ItemType.DisplayImage;
}
public ImageItem() => ItemType = ItemType.DisplayImage;
}
public class CheckboxItem : Item

View File

@ -2,11 +2,8 @@ namespace Jackett.Common.Models.IndexerConfig
{
public class ConfigurationDataAPIKey : ConfigurationData
{
public ConfigurationData.StringItem Key { get; private set; }
public StringItem Key { get; private set; }
public ConfigurationDataAPIKey()
{
Key = new ConfigurationData.StringItem { Name = "APIKey", Value = string.Empty };
}
public ConfigurationDataAPIKey() => Key = new StringItem { Name = "APIKey", Value = string.Empty };
}
}

View File

@ -11,14 +11,8 @@ namespace Jackett.Common.Models.IndexerConfig
public DateTime LastTokenFetchDateTime
{
get
{
return DateTimeUtil.UnixTimestampToDateTime(ParseUtil.CoerceDouble(LastTokenFetchDate.Value));
}
set
{
LastTokenFetchDate.Value = DateTimeUtil.DateTimeToUnixTimestamp(value).ToString(CultureInfo.InvariantCulture);
}
get => DateTimeUtil.UnixTimestampToDateTime(ParseUtil.CoerceDouble(LastTokenFetchDate.Value));
set => LastTokenFetchDate.Value = DateTimeUtil.DateTimeToUnixTimestamp(value).ToString(CultureInfo.InvariantCulture);
}
public ConfigurationDataLoginTokin() : base()

View File

@ -4,9 +4,6 @@ namespace Jackett.Common.Models.IndexerConfig
{
public StringItem Pin { get; private set; }
public ConfigurationDataPinNumber() : base()
{
Pin = new StringItem { Name = "Login Pin Number" };
}
public ConfigurationDataPinNumber() => Pin = new StringItem { Name = "Login Pin Number" };
}
}

View File

@ -6,14 +6,8 @@ namespace Jackett.Common.Models.IndexerConfig
{
public StringItem Url { get; private set; }
public ConfigurationDataUrl(Uri defaultUrl)
{
Url = new StringItem { Name = "Url", Value = defaultUrl.ToString() };
}
public ConfigurationDataUrl(Uri defaultUrl) => Url = new StringItem { Name = "Url", Value = defaultUrl.ToString() };
public ConfigurationDataUrl(string defaultUrl)
{
Url = new StringItem { Name = "Url", Value = defaultUrl };
}
public ConfigurationDataUrl(string defaultUrl) => Url = new StringItem { Name = "Url", Value = defaultUrl };
}
}

View File

@ -8,52 +8,22 @@ namespace Jackett.Common.Models
{
public selectorBlock this[string key]
{
get
{
throw new NotImplementedException();
}
get => throw new NotImplementedException();
set
{
base.Add(new KeyValuePair<string, selectorBlock>(key, value));
}
set => Add(new KeyValuePair<string, selectorBlock>(key, value));
}
public ICollection<string> Keys
{
get
{
throw new NotImplementedException();
}
}
public ICollection<string> Keys => throw new NotImplementedException();
public ICollection<selectorBlock> Values
{
get
{
throw new NotImplementedException();
}
}
public ICollection<selectorBlock> Values => throw new NotImplementedException();
public void Add(string key, selectorBlock value)
{
base.Add(new KeyValuePair<string, selectorBlock>(key, value));
}
public void Add(string key, selectorBlock value) => Add(new KeyValuePair<string, selectorBlock>(key, value));
public bool ContainsKey(string key)
{
throw new NotImplementedException();
}
public bool ContainsKey(string key) => throw new NotImplementedException();
public bool Remove(string key)
{
throw new NotImplementedException();
}
public bool Remove(string key) => throw new NotImplementedException();
public bool TryGetValue(string key, out selectorBlock value)
{
throw new NotImplementedException();
}
public bool TryGetValue(string key, out selectorBlock value) => throw new NotImplementedException();
}
// Cardigann yaml classes
@ -106,7 +76,7 @@ namespace Jackett.Common.Models
{
public string Type { get; set; }
public string Selector { get; set; }
public string Image { get { throw new Exception("Deprecated, please use Login.Captcha.Selector instead"); } set { throw new Exception("Deprecated, please use login/captcha/selector instead of image"); } }
public string Image { get => throw new Exception("Deprecated, please use Login.Captcha.Selector instead"); set => throw new Exception("Deprecated, please use login/captcha/selector instead of image"); }
public string Input { get; set; }
}

View File

@ -36,14 +36,9 @@ namespace Jackett.Common.Models
[JsonIgnore] // don't export the Origin to the manul search API, otherwise each result line contains a full recursive indexer JSON structure
public IIndexer Origin;
public double? Gain
{
get
{
var sizeInGB = Size / 1024.0 / 1024.0 / 1024.0;
return Seeders * sizeInGB;
}
}
private static double? GigabytesFromBytes(double? size) => size / 1024.0 / 1024.0 / 1024.0;
public double? Gain => Seeders * GigabytesFromBytes(Size);
public ReleaseInfo()
{
@ -75,10 +70,7 @@ namespace Jackett.Common.Models
UploadVolumeFactor = copyFrom.UploadVolumeFactor;
}
public virtual object Clone()
{
return new ReleaseInfo(this);
}
public virtual object Clone() => new ReleaseInfo(this);
// ex: " 3.5 gb "
public static long GetBytes(string str)
@ -103,29 +95,15 @@ namespace Jackett.Common.Models
return (long)value;
}
public static long BytesFromTB(float tb)
{
return BytesFromGB(tb * 1024f);
}
public static long BytesFromTB(float tb) => BytesFromGB(tb * 1024f);
public static long BytesFromGB(float gb)
{
return BytesFromMB(gb * 1024f);
}
public static long BytesFromGB(float gb) => BytesFromMB(gb * 1024f);
public static long BytesFromMB(float mb)
{
return BytesFromKB(mb * 1024f);
}
public static long BytesFromMB(float mb) => BytesFromKB(mb * 1024f);
public static long BytesFromKB(float kb)
{
return (long)(kb * 1024f);
}
public static long BytesFromKB(float kb) => (long)(kb * 1024f);
public override string ToString()
{
return string.Format("[ReleaseInfo: Title={0}, Guid={1}, Link={2}, Comments={3}, PublishDate={4}, Category={5}, Size={6}, Files={7}, Grabs={8}, Description={9}, RageID={10}, TVDBId={11}, Imdb={12}, TMDb={13}, Seeders={14}, Peers={15}, BannerUrl={16}, InfoHash={17}, MagnetUri={18}, MinimumRatio={19}, MinimumSeedTime={20}, DownloadVolumeFactor={21}, UploadVolumeFactor={22}, Gain={23}]", Title, Guid, Link, Comments, PublishDate, Category, Size, Files, Grabs, Description, RageID, TVDBId, Imdb, TMDb, Seeders, Peers, BannerUrl, InfoHash, MagnetUri, MinimumRatio, MinimumSeedTime, DownloadVolumeFactor, UploadVolumeFactor, Gain);
}
public override string ToString() =>
$"[ReleaseInfo: Title={Title}, Guid={Guid}, Link={Link}, Comments={Comments}, PublishDate={PublishDate}, Category={Category}, Size={Size}, Files={Files}, Grabs={Grabs}, Description={Description}, RageID={RageID}, TVDBId={TVDBId}, Imdb={Imdb}, TMDb={TMDb}, Seeders={Seeders}, Peers={Peers}, BannerUrl={BannerUrl}, InfoHash={InfoHash}, MagnetUri={MagnetUri}, MinimumRatio={MinimumRatio}, MinimumSeedTime={MinimumSeedTime}, DownloadVolumeFactor={DownloadVolumeFactor}, UploadVolumeFactor={UploadVolumeFactor}, Gain={Gain}]";
}
}

View File

@ -29,10 +29,7 @@ namespace Jackett.Common.Models
return f;
}
private XElement getTorznabElement(string name, object value)
{
return value == null ? null : new XElement(torznabNs + "attr", new XAttribute("name", name), new XAttribute("value", value));
}
private XElement getTorznabElement(string name, object value) => value == null ? null : new XElement(torznabNs + "attr", new XAttribute("name", name), new XAttribute("value", value));
public string ToXml(Uri selfAtom)
{

View File

@ -7,8 +7,8 @@ namespace Jackett.Common.Models
{
public class TorznabCapabilities
{
public int? LimitsMax { get; set; } = null;
public int? LimitsDefault { get; set; } = null;
public int? LimitsMax { get; set; }
public int? LimitsDefault { get; set; }
public bool SearchAvailable { get; set; }
@ -22,13 +22,7 @@ namespace Jackett.Common.Models
public bool SupportsImdbTVSearch { get; set; }
public bool MusicSearchAvailable
{
get
{
return (SupportedMusicSearchParamsList.Count > 0);
}
}
public bool MusicSearchAvailable => (SupportedMusicSearchParamsList.Count > 0);
public List<string> SupportedMusicSearchParamsList;
@ -83,13 +77,7 @@ namespace Jackett.Common.Models
}
}
private string SupportedMusicSearchParams
{
get
{
return string.Join(",", SupportedMusicSearchParamsList);
}
}
private string SupportedMusicSearchParams => string.Join(",", SupportedMusicSearchParamsList);
public bool SupportsCategories(int[] categories)
{
@ -153,12 +141,9 @@ namespace Jackett.Common.Models
return xdoc;
}
public string ToXml()
{
var xdoc = GetXDocument();
public string ToXml() =>
GetXDocument().Declaration + Environment.NewLine + GetXDocument();
return xdoc.Declaration.ToString() + Environment.NewLine + xdoc.ToString();
}
public static TorznabCapabilities Concat(TorznabCapabilities lhs, TorznabCapabilities rhs)
{
lhs.SearchAvailable = lhs.SearchAvailable || rhs.SearchAvailable;

View File

@ -8,6 +8,14 @@ namespace Jackett.Common.Models
public static bool QueryContainsParentCategory(int[] queryCats, ICollection<int> releaseCats)
{
//return (from releaseCat in releaseCats
// select AllCats.FirstOrDefault(c => c.ID == releaseCat)
// into cat
// where cat != null && queryCats != null
// select cat.SubCategories.Any(c => queryCats.Contains(c.ID)))
// .FirstOrDefault();
// Is equal to:
foreach (var releaseCat in releaseCats)
{
var cat = AllCats.FirstOrDefault(c => c.ID == releaseCat);
@ -20,32 +28,12 @@ namespace Jackett.Common.Models
return false;
}
public static string GetCatDesc(int newznabcat)
{
var cat = AllCats.FirstOrDefault(c => c.ID == newznabcat);
if (cat != null)
{
return cat.Name;
}
public static string GetCatDesc(int newznabcat) =>
AllCats.FirstOrDefault(c => c.ID == newznabcat)?.Name
?? string.Empty;
return string.Empty;
}
public static string NormalizeCatName(string name)
{
return name.Replace(" ", "").ToLower();
}
public static TorznabCategory GetCatByName(string name)
{
var cat = AllCats.FirstOrDefault(c => NormalizeCatName(c.Name) == NormalizeCatName(name));
if (cat != null)
{
return cat;
}
return null;
}
public static string NormalizeCatName(string name) => name.Replace(" ", "").ToLower();
public static TorznabCategory GetCatByName(string name) => AllCats.FirstOrDefault(c => NormalizeCatName(c.Name) == NormalizeCatName(name));
}
}

View File

@ -10,10 +10,7 @@ namespace Jackett.Common.Models
public List<TorznabCategory> SubCategories { get; private set; }
public TorznabCategory()
{
SubCategories = new List<TorznabCategory>();
}
public TorznabCategory() => SubCategories = new List<TorznabCategory>();
public TorznabCategory(int id, string name)
{
@ -22,36 +19,20 @@ namespace Jackett.Common.Models
SubCategories = new List<TorznabCategory>();
}
public bool Contains(TorznabCategory cat)
{
if (this == cat)
return true;
public bool Contains(TorznabCategory cat) =>
Equals(this, cat) || SubCategories.Contains(cat);
if (SubCategories.Contains(cat))
return true;
public JToken ToJson() =>
new JObject
{
["ID"] = ID,
["Name"] = Name
};
return false;
}
public override bool Equals(object obj) => (obj as TorznabCategory)?.ID == ID;
public JToken ToJson()
{
var t = new JObject();
t["ID"] = ID;
t["Name"] = Name;
return t;
}
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
return false;
return ID == ((TorznabCategory)obj).ID;
}
public override int GetHashCode()
{
return ID;
}
// Get Hash code should be calculated off read only properties.
// ID is not readonly
public override int GetHashCode() => ID;
}
}

View File

@ -31,65 +31,23 @@ namespace Jackett.Common.Models
public bool IsTest { get; set; }
public string ImdbIDShort { get { return (ImdbID != null ? ImdbID.TrimStart('t') : null); } }
public string ImdbIDShort => ImdbID?.TrimStart('t');
protected string[] QueryStringParts = null;
protected string[] QueryStringParts;
public bool IsSearch
{
get
{
return QueryType == "search";
}
}
public bool IsSearch => QueryType == "search";
public bool IsTVSearch
{
get
{
return QueryType == "tvsearch";
}
}
public bool IsTVSearch => QueryType == "tvsearch";
public bool IsMovieSearch
{
get
{
return QueryType == "movie" || (QueryType == "TorrentPotato" && !string.IsNullOrWhiteSpace(SearchTerm));
}
}
public bool IsMovieSearch => QueryType == "movie" || (QueryType == "TorrentPotato" && !string.IsNullOrWhiteSpace(SearchTerm));
public bool IsMusicSearch
{
get
{
return QueryType == "music";
}
}
public bool IsMusicSearch => QueryType == "music";
public bool IsTVRageSearch
{
get
{
return RageID != null;
}
}
public bool IsTVRageSearch => RageID != null;
public bool IsImdbQuery
{
get
{
return ImdbID != null;
}
}
public bool IsImdbQuery => ImdbID != null;
public bool HasSpecifiedCategories
{
get
{
return (Categories != null && Categories.Length > 0);
}
}
public bool HasSpecifiedCategories => (Categories != null && Categories.Length > 0);
public string SanitizedSearchTerm
{
@ -99,20 +57,20 @@ namespace Jackett.Common.Models
if (SearchTerm == null)
term = "";
var safetitle = term.Where(c => (char.IsLetterOrDigit(c)
|| char.IsWhiteSpace(c)
|| c == '-'
|| c == '.'
|| c == '_'
|| c == '('
|| c == ')'
|| c == '@'
|| c == '/'
|| c == '\''
|| c == '['
|| c == ']'
|| c == '+'
|| c == '%'
)).AsString();
|| char.IsWhiteSpace(c)
|| c == '-'
|| c == '.'
|| c == '_'
|| c == '('
|| c == ')'
|| c == '@'
|| c == '/'
|| c == '\''
|| c == '['
|| c == ']'
|| c == '+'
|| c == '%'
)).AsString();
return safetitle;
}
}
@ -169,6 +127,7 @@ namespace Jackett.Common.Models
ret.Year = Year;
if (Genre != null)
{
// Make a copied list and then don't use it?
Genre.Select(item => item.Clone()).ToList();
}
if (QueryStringParts != null && QueryStringParts.Length > 0)
@ -182,10 +141,7 @@ namespace Jackett.Common.Models
return ret;
}
public string GetQueryString()
{
return (SanitizedSearchTerm + " " + GetEpisodeSearchString()).Trim();
}
public string GetQueryString() => (SanitizedSearchTerm + " " + GetEpisodeSearchString()).Trim();
// Some trackers don't support AND logic for search terms resulting in unwanted results.
// Using this method we can AND filter it within jackett.

View File

@ -14,10 +14,7 @@ namespace Jackett.Common.Plumbing
{
private readonly RuntimeSettings _runtimeSettings;
public JackettModule(RuntimeSettings runtimeSettings)
{
_runtimeSettings = runtimeSettings;
}
public JackettModule(RuntimeSettings runtimeSettings) => _runtimeSettings = runtimeSettings;
protected override void Load(ContainerBuilder builder)
{
@ -41,10 +38,7 @@ namespace Jackett.Common.Plumbing
builder.RegisterInstance(_runtimeSettings);
builder.Register(ctx =>
{
return BuildServerConfig(ctx);
}).As<ServerConfig>().SingleInstance();
builder.Register(BuildServerConfig).As<ServerConfig>().SingleInstance();
builder.RegisterType<HttpWebClient>();
// Register the best web client for the platform or the override
@ -69,10 +63,7 @@ namespace Jackett.Common.Plumbing
}
}
private void RegisterWebClient<WebClientType>(ContainerBuilder builder)
{
builder.RegisterType<WebClientType>().As<WebClient>();
}
private void RegisterWebClient<WebClientType>(ContainerBuilder builder) => builder.RegisterType<WebClientType>().As<WebClient>();
private ServerConfig BuildServerConfig(IComponentContext ctx)
{

View File

@ -29,10 +29,7 @@ namespace Jackett.Common.Services
CreateOrMigrateSettings();
}
public string GetAppDataFolder()
{
return runtimeSettings.DataFolder;
}
public string GetAppDataFolder() => runtimeSettings.DataFolder;
public void CreateOrMigrateSettings()
{
@ -146,7 +143,7 @@ namespace Jackett.Common.Services
catch (Exception e)
{
logger.Error(e, "Error reading config file " + fullPath);
return default(T);
return default;
}
}
@ -167,16 +164,12 @@ namespace Jackett.Common.Services
}
}
public string ApplicationFolder()
{
return Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
}
public string ApplicationFolder() => Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
public string GetContentFolder()
{
// If we are debugging we can use the non copied content.
var dir = Path.Combine(ApplicationFolder(), "Content");
;
#if DEBUG
// When we are running in debug use the source files
@ -206,7 +199,6 @@ namespace Jackett.Common.Services
// If we are debugging we can use the non copied definitions.
var dir = Path.Combine(ApplicationFolder(), "Definitions");
;
#if DEBUG
// When we are running in debug use the source files
@ -222,25 +214,13 @@ namespace Jackett.Common.Services
public string GetIndexerConfigDir()
{
return Path.Combine(GetAppDataFolder(), "Indexers");
}
public string GetIndexerConfigDir() => Path.Combine(GetAppDataFolder(), "Indexers");
public string GetConfigFile()
{
return Path.Combine(GetAppDataFolder(), "config.json");
}
public string GetConfigFile() => Path.Combine(GetAppDataFolder(), "config.json");
public string GetSonarrConfigFile()
{
return Path.Combine(GetAppDataFolder(), "sonarr_api.json");
}
public string GetSonarrConfigFile() => Path.Combine(GetAppDataFolder(), "sonarr_api.json");
public string GetVersion()
{
return EnvironmentUtil.JackettVersion;
}
public string GetVersion() => EnvironmentUtil.JackettVersion;
public ServerConfig BuildServerConfig(RuntimeSettings runtimeSettings)
{
@ -269,11 +249,9 @@ namespace Jackett.Common.Services
// Check for legacy settings
var path = Path.Combine(GetAppDataFolder(), "config.json");
;
var jsonReply = new JObject();
if (File.Exists(path))
{
jsonReply = JObject.Parse(File.ReadAllText(path));
var jsonReply = JObject.Parse(File.ReadAllText(path));
config.Port = (int)jsonReply["port"];
config.AllowExternal = (bool)jsonReply["public"];
}

View File

@ -141,10 +141,7 @@ namespace Jackett.Common.Services
}
}
private string GetIndexerConfigFilePath(IIndexer indexer)
{
return Path.Combine(configService.GetIndexerConfigDir(), indexer.ID + ".json");
}
private string GetIndexerConfigFilePath(IIndexer indexer) => Path.Combine(configService.GetIndexerConfigDir(), indexer.ID + ".json");
private readonly IConfigurationService configService;
private readonly Logger logger;

View File

@ -208,10 +208,7 @@ namespace Jackett.Common.Services
throw new Exception("Unknown indexer: " + name);
}
public IEnumerable<IIndexer> GetAllIndexers()
{
return indexers.Values.OrderBy(_ => _.DisplayName);
}
public IEnumerable<IIndexer> GetAllIndexers() => indexers.Values.OrderBy(_ => _.DisplayName);
public async Task TestIndexer(string name)
{

Some files were not shown because too many files have changed in this diff Show More