milkie: cosmetic changes (#8301)

This commit is contained in:
Diego Heras
2020-04-22 01:19:53 +02:00
committed by GitHub
parent 416db0a8fc
commit 8d60c60743

View File

@@ -19,22 +19,18 @@ namespace Jackett.Common.Indexers
{ {
private string TorrentsEndpoint => SiteLink + "api/v1/torrents"; private string TorrentsEndpoint => SiteLink + "api/v1/torrents";
private new ConfigurationDataAPIKey configData private new ConfigurationDataAPIKey configData => (ConfigurationDataAPIKey)base.configData;
{
get => (ConfigurationDataAPIKey)base.configData;
set => base.configData = value;
}
public Milkie(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) public Milkie(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
: base(name: "Milkie", : base("Milkie",
description: "Milkie.cc (ME) is private torrent tracker for 0day / general", description: "Milkie.cc (ME) is private torrent tracker for 0day / general",
link: "https://milkie.cc/", link: "https://milkie.cc/",
caps: new TorznabCapabilities(), caps: new TorznabCapabilities(),
configService: configService, configService: configService,
client: wc, client: wc,
logger: l, logger: l,
p: ps, p: ps,
configData: new ConfigurationDataAPIKey()) configData: new ConfigurationDataAPIKey())
{ {
Encoding = Encoding.UTF8; Encoding = Encoding.UTF8;
Language = "en-us"; Language = "en-us";
@@ -63,8 +59,7 @@ namespace Jackett.Common.Indexers
try try
{ {
var results = await PerformQuery(new TorznabQuery()); var results = await PerformQuery(new TorznabQuery());
if (!results.Any())
if (results.Count() == 0)
throw new Exception("Testing returned no results!"); throw new Exception("Testing returned no results!");
IsConfigured = true; IsConfigured = true;
@@ -80,24 +75,23 @@ namespace Jackett.Common.Indexers
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query) protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{ {
var queryParams = new NameValueCollection var qc = new NameValueCollection
{ {
{ "ps", "100" } { "ps", "100" }
}; };
if (!string.IsNullOrWhiteSpace(query.SearchTerm)) if (!string.IsNullOrWhiteSpace(query.SearchTerm))
{ qc.Add("query", query.SearchTerm);
queryParams.Add("query", query.SearchTerm);
}
if (query.HasSpecifiedCategories) if (query.HasSpecifiedCategories)
{ qc.Add("categories", string.Join(",", MapTorznabCapsToTrackers(query)));
queryParams.Add("categories", string.Join(",", MapTorznabCapsToTrackers(query)));
}
var endpoint = TorrentsEndpoint + "?" + queryParams.GetQueryString(); var endpoint = TorrentsEndpoint + "?" + qc.GetQueryString();
var headers = new Dictionary<string, string>() { { "x-milkie-auth", configData.Key.Value } }; var headers = new Dictionary<string, string>
var jsonResponse = await RequestStringWithCookies(endpoint, null, null, headers); {
{ "x-milkie-auth", configData.Key.Value }
};
var jsonResponse = await RequestStringWithCookies(endpoint, headers: headers);
var releases = new List<ReleaseInfo>(); var releases = new List<ReleaseInfo>();
@@ -114,6 +108,7 @@ namespace Jackett.Common.Indexers
{ {
var link = new Uri($"{TorrentsEndpoint}/{torrent.Id}/torrent?{dlQueryParams.GetQueryString()}"); var link = new Uri($"{TorrentsEndpoint}/{torrent.Id}/torrent?{dlQueryParams.GetQueryString()}");
var comments = new Uri($"{SiteLink}browse/{torrent.Id}"); var comments = new Uri($"{SiteLink}browse/{torrent.Id}");
var publishDate = DateTimeUtil.FromUnknown(torrent.CreatedAt);
var release = new ReleaseInfo() var release = new ReleaseInfo()
{ {
@@ -121,16 +116,16 @@ namespace Jackett.Common.Indexers
Link = link, Link = link,
Comments = comments, Comments = comments,
Guid = comments, Guid = comments,
Size = torrent.Size, PublishDate = publishDate,
Category = MapTrackerCatToNewznab(torrent.Category.ToString()), Category = MapTrackerCatToNewznab(torrent.Category.ToString()),
Size = torrent.Size,
Seeders = torrent.Seeders, Seeders = torrent.Seeders,
Peers = torrent.Seeders + torrent.PartialSeeders + torrent.Leechers, Peers = torrent.Seeders + torrent.PartialSeeders + torrent.Leechers,
Grabs = torrent.Downloaded, Grabs = torrent.Downloaded,
UploadVolumeFactor = 1, UploadVolumeFactor = 1,
DownloadVolumeFactor = 0, DownloadVolumeFactor = 0,
MinimumRatio = 1, MinimumRatio = 1,
MinimumSeedTime = 172800, MinimumSeedTime = 172800 // 48 hours
PublishDate = DateTimeUtil.FromUnknown(torrent.CreatedAt)
}; };
releases.Add(release); releases.Add(release);