1
0
Fork 0
mirror of https://github.com/Jackett/Jackett synced 2025-02-24 15:21:06 +00:00

Add Hardbay tracker

This commit is contained in:
kaso17 2017-01-17 17:49:43 +01:00
parent cf4b3eb2c1
commit 61a7bb4d10
3 changed files with 148 additions and 0 deletions

View file

@ -56,6 +56,7 @@ Developer note: The software implements the [Torznab](https://github.com/Sonarr/
* Ghost City
* GODS
* Gormogon
* Hardbay
* HD4Free
* HD-Space
* HD-Torrents

View file

@ -0,0 +1,146 @@
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Jackett.Utils.Clients;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Jackett.Models.IndexerConfig;
using System.Collections.Specialized;
using Newtonsoft.Json;
using System.Globalization;
namespace Jackett.Indexers
{
public class Hardbay : BaseIndexer, IIndexer
{
private string SearchUrl { get { return SiteLink + "api/v1/torrents"; } }
private string LoginUrl { get { return SiteLink + "api/v1/auth"; } }
new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
}
public Hardbay(IIndexerManagerService i, Logger l, IWebClient w, IProtectionService ps)
: base(name: "Hardbay",
description: null,
link: "https://hardbay.club/",
caps: new TorznabCapabilities(),
manager: i,
client: w,
logger: l,
p: ps,
configData: new ConfigurationDataBasicLogin())
{
Encoding = Encoding.GetEncoding("UTF-8");
Language = "en-us";
AddCategoryMapping(1, TorznabCatType.Audio);
AddCategoryMapping(2, TorznabCatType.AudioLossless);
}
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
LoadValuesFromJson(configJson);
var queryCollection = new NameValueCollection();
queryCollection.Add("username", configData.Username.Value);
queryCollection.Add("password", configData.Password.Value);
var loginUrl = LoginUrl + "?" + queryCollection.GetQueryString();
var loginResult = await RequestStringWithCookies(loginUrl, null, SiteLink);
await ConfigureIfOK(loginResult.Cookies, loginResult.Content.Contains("\"user\""), () =>
{
throw new ExceptionWithConfigData(loginResult.Content, configData);
});
return IndexerConfigurationStatus.RequiresTesting;
}
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
List<ReleaseInfo> releases = new List<ReleaseInfo>();
var queryCollection = new NameValueCollection();
var searchString = query.GetQueryString();
var searchUrl = SearchUrl;
queryCollection.Add("extendedSearch", "false");
queryCollection.Add("hideOld", "false");
queryCollection.Add("index", "0");
queryCollection.Add("limit", "100");
queryCollection.Add("order", "desc");
queryCollection.Add("page", "search");
queryCollection.Add("searchText", searchString);
queryCollection.Add("sort", "d");
/*foreach (var cat in MapTorznabCapsToTrackers(query))
queryCollection.Add("categories[]", cat);
*/
searchUrl += "?" + queryCollection.GetQueryString();
var results = await RequestStringWithCookies(searchUrl, null, SiteLink);
try
{
//var json = JArray.Parse(results.Content);
dynamic json = JsonConvert.DeserializeObject<dynamic>(results.Content);
foreach (var row in json)
{
var release = new ReleaseInfo();
var descriptions = new List<string>();
var tags = new List<string>();
release.MinimumRatio = 0.5;
release.MinimumSeedTime = 0;
release.Title = row.name;
release.Category = TorznabCatType.Audio.ID;
release.Size = row.size;
release.Seeders = row.seeders;
release.Peers = row.leechers + release.Seeders;
release.PublishDate = DateTime.ParseExact(row.added.ToString() + " +01:00", "yyyy-MM-dd HH:mm:ss zzz", CultureInfo.InvariantCulture);
release.Files = row.numfiles;
release.Grabs = row.times_completed;
release.Comments = new Uri(SiteLink + "torrent/" + row.id.ToString() + "/");
release.Link = new Uri(SiteLink + "api/v1/torrents/download/" + row.id.ToString());
if (row.frileech == 1)
release.DownloadVolumeFactor = 0;
else
release.DownloadVolumeFactor = 0.33;
release.UploadVolumeFactor = 1;
if ((int)row.p2p == 1)
tags.Add("P2P");
if ((int)row.pack == 1)
tags.Add("Pack");
if ((int)row.reqid != 0)
tags.Add("Archive");
if ((int)row.flac != 0)
{
tags.Add("FLAC");
release.Category = TorznabCatType.AudioLossless.ID;
}
if (tags.Count > 0)
descriptions.Add("Tags: " + string.Join(", ", tags));
release.Description = string.Join("<br>\n", descriptions);
releases.Add(release);
}
}
catch (Exception ex)
{
OnParseError(results.Content, ex);
}
return releases;
}
}
}

View file

@ -165,6 +165,7 @@
<Compile Include="Controllers\TorznabController.cs" />
<Compile Include="Controllers\DownloadController.cs" />
<Compile Include="Engine.cs" />
<Compile Include="Indexers\Hardbay.cs" />
<Compile Include="Indexers\Superbits.cs" />
<Compile Include="Indexers\rutracker.cs" />
<Compile Include="Indexers\Abstract\GazelleTracker.cs" />