2020-02-09 02:35:16 +00:00
|
|
|
using System;
|
2017-10-29 06:21:18 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
2020-03-05 06:45:27 +00:00
|
|
|
using System.Linq;
|
2017-10-29 06:21:18 +00:00
|
|
|
using System.Text;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Threading.Tasks;
|
2020-02-29 18:52:35 +00:00
|
|
|
using AngleSharp.Html.Parser;
|
2018-03-10 08:05:56 +00:00
|
|
|
using Jackett.Common.Helpers;
|
|
|
|
using Jackett.Common.Models;
|
|
|
|
using Jackett.Common.Models.IndexerConfig;
|
|
|
|
using Jackett.Common.Services.Interfaces;
|
|
|
|
using Jackett.Common.Utils;
|
2016-07-27 04:08:06 +00:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using NLog;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2018-03-10 08:05:56 +00:00
|
|
|
namespace Jackett.Common.Indexers
|
2016-07-27 04:08:06 +00:00
|
|
|
{
|
2017-07-10 20:58:44 +00:00
|
|
|
public class Hebits : BaseWebIndexer
|
2016-07-27 04:08:06 +00:00
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
private string LoginPostUrl => SiteLink + "takeloginAjax.php";
|
|
|
|
private string SearchUrl => SiteLink + "browse.php?sort=4&type=desc";
|
2016-07-27 04:08:06 +00:00
|
|
|
|
2017-10-29 06:21:18 +00:00
|
|
|
private new ConfigurationDataBasicLogin configData
|
2016-07-27 04:08:06 +00:00
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
get => (ConfigurationDataBasicLogin)base.configData;
|
|
|
|
set => base.configData = value;
|
2016-07-27 04:08:06 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 09:42:03 +00:00
|
|
|
public Hebits(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps)
|
2016-07-27 04:08:06 +00:00
|
|
|
: base(name: "Hebits",
|
2020-03-05 06:45:27 +00:00
|
|
|
description: "The Israeli Tracker",
|
|
|
|
link: "https://hebits.net/",
|
|
|
|
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
|
|
|
configService: configService,
|
|
|
|
client: wc,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
|
|
|
downloadBase: "https://hebits.net/",
|
|
|
|
configData: new ConfigurationDataBasicLogin())
|
2016-07-27 04:08:06 +00:00
|
|
|
{
|
2016-12-06 13:56:47 +00:00
|
|
|
Encoding = Encoding.GetEncoding("windows-1255");
|
2016-12-09 17:20:58 +00:00
|
|
|
Language = "he-il";
|
2017-01-27 15:57:32 +00:00
|
|
|
Type = "private";
|
2016-07-27 04:08:06 +00:00
|
|
|
AddCategoryMapping(19, TorznabCatType.MoviesSD);
|
|
|
|
AddCategoryMapping(25, TorznabCatType.MoviesOther); // Israeli Content
|
|
|
|
AddCategoryMapping(20, TorznabCatType.MoviesDVD);
|
|
|
|
AddCategoryMapping(36, TorznabCatType.MoviesBluRay);
|
|
|
|
AddCategoryMapping(27, TorznabCatType.MoviesHD);
|
|
|
|
AddCategoryMapping(7, TorznabCatType.TVSD); // Israeli SDTV
|
|
|
|
AddCategoryMapping(24, TorznabCatType.TVSD); // English SDTV
|
|
|
|
AddCategoryMapping(1, TorznabCatType.TVHD); // Israel HDTV
|
|
|
|
AddCategoryMapping(37, TorznabCatType.TVHD); // Israel HDTV
|
|
|
|
}
|
|
|
|
|
2017-06-28 05:31:38 +00:00
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2016-07-27 04:08:06 +00:00
|
|
|
{
|
2017-01-02 20:39:28 +00:00
|
|
|
LoadValuesFromJson(configJson);
|
2020-03-05 06:45:27 +00:00
|
|
|
var pairs = new Dictionary<string, string>
|
|
|
|
{
|
|
|
|
{"username", configData.Username.Value},
|
|
|
|
{"password", configData.Password.Value}
|
2016-07-27 04:08:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Get inital cookies
|
|
|
|
CookieHeader = string.Empty;
|
|
|
|
var result = await RequestLoginAndFollowRedirect(LoginPostUrl, pairs, CookieHeader, true, null, SiteLink);
|
2020-03-05 06:45:27 +00:00
|
|
|
await ConfigureIfOK(
|
|
|
|
result.Cookies, result.Content?.Contains("OK") == true, () =>
|
|
|
|
{
|
|
|
|
var parser = new HtmlParser();
|
|
|
|
var dom = parser.ParseDocument(result.Content);
|
|
|
|
var errorMessage = dom.TextContent.Trim();
|
|
|
|
errorMessage += " attempts left. Please check your credentials.";
|
|
|
|
throw new ExceptionWithConfigData(errorMessage, configData);
|
|
|
|
});
|
2016-07-27 04:08:06 +00:00
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
}
|
|
|
|
|
2017-07-03 05:15:47 +00:00
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2016-07-27 04:08:06 +00:00
|
|
|
{
|
|
|
|
var releases = new List<ReleaseInfo>();
|
|
|
|
var searchString = query.GetQueryString();
|
|
|
|
var searchUrl = SearchUrl;
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchString))
|
2018-02-12 15:30:51 +00:00
|
|
|
searchUrl += "&search=" + WebUtilityHelpers.UrlEncode(searchString, Encoding);
|
2016-07-27 04:08:06 +00:00
|
|
|
var cats = MapTorznabCapsToTrackers(query);
|
|
|
|
if (cats.Count > 0)
|
2020-03-05 06:45:27 +00:00
|
|
|
searchUrl = cats.Aggregate(searchUrl, (url, cat) => $"{url}&c{cat}=1");
|
2016-12-06 13:56:47 +00:00
|
|
|
var response = await RequestStringWithCookies(searchUrl);
|
2016-07-27 04:08:06 +00:00
|
|
|
try
|
|
|
|
{
|
2020-02-29 18:52:35 +00:00
|
|
|
var parser = new HtmlParser();
|
|
|
|
var dom = parser.ParseDocument(response.Content);
|
|
|
|
var rows = dom.QuerySelectorAll(".browse > div > div");
|
|
|
|
foreach (var row in rows)
|
2016-07-27 04:08:06 +00:00
|
|
|
{
|
|
|
|
var release = new ReleaseInfo();
|
|
|
|
release.MinimumRatio = 1;
|
2020-01-11 18:07:19 +00:00
|
|
|
release.MinimumSeedTime = 172800; // 48 hours
|
2020-02-29 18:52:35 +00:00
|
|
|
var qTitle = row.QuerySelector(".bTitle");
|
|
|
|
var titleParts = qTitle.TextContent.Split('/');
|
2020-03-05 06:45:27 +00:00
|
|
|
release.Title = titleParts.Length >= 2 ? titleParts[1].Trim() : titleParts[0].Trim();
|
2020-02-29 18:52:35 +00:00
|
|
|
var qDetailsLink = qTitle.QuerySelector("a[href^=\"details.php\"]");
|
|
|
|
release.Comments = new Uri(SiteLink + qDetailsLink.GetAttribute("href"));
|
|
|
|
release.Link = new Uri(SiteLink + row.QuerySelector("a[href^=\"download.php\"]").GetAttribute("href"));
|
2016-07-27 04:08:06 +00:00
|
|
|
release.Guid = release.Link;
|
2020-02-29 18:52:35 +00:00
|
|
|
var dateString = row.QuerySelector("div:last-child").TextContent.Trim();
|
2020-03-05 06:45:27 +00:00
|
|
|
var match = Regex.Match(dateString, @"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}");
|
2016-07-27 04:08:06 +00:00
|
|
|
if (match.Success)
|
|
|
|
release.PublishDate = DateTime.ParseExact(match.Value, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
|
2020-03-05 06:45:27 +00:00
|
|
|
var sizeStr = row.QuerySelector(".bSize").TextContent.Trim();
|
2016-07-27 04:08:06 +00:00
|
|
|
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
2020-02-29 18:52:35 +00:00
|
|
|
release.Seeders = ParseUtil.CoerceInt(row.QuerySelector(".bUping").TextContent.Trim());
|
|
|
|
release.Peers = release.Seeders + ParseUtil.CoerceInt(row.QuerySelector(".bDowning").TextContent.Trim());
|
2020-03-05 06:45:27 +00:00
|
|
|
var files = row.QuerySelector("div.bFiles").ChildNodes.Last().TextContent.Trim();
|
2016-10-27 07:35:31 +00:00
|
|
|
release.Files = ParseUtil.CoerceInt(files);
|
2020-03-05 06:45:27 +00:00
|
|
|
var grabs = row.QuerySelector("div.bFinish").ChildNodes.Last().TextContent.Trim();
|
2016-10-27 07:35:31 +00:00
|
|
|
release.Grabs = ParseUtil.CoerceInt(grabs);
|
2020-03-05 06:45:27 +00:00
|
|
|
release.DownloadVolumeFactor = row.QuerySelector("img[src=\"/pic/free.jpg\"]") != null ? 0 : 1;
|
2020-02-29 18:52:35 +00:00
|
|
|
if (row.QuerySelector("img[src=\"/pic/triple.jpg\"]") != null)
|
2016-10-27 07:35:31 +00:00
|
|
|
release.UploadVolumeFactor = 3;
|
2020-02-29 18:52:35 +00:00
|
|
|
else if (row.QuerySelector("img[src=\"/pic/double.jpg\"]") != null)
|
2017-04-15 08:45:10 +00:00
|
|
|
release.UploadVolumeFactor = 2;
|
2016-10-27 07:35:31 +00:00
|
|
|
else
|
|
|
|
release.UploadVolumeFactor = 1;
|
2016-07-27 04:08:06 +00:00
|
|
|
releases.Add(release);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2016-12-06 13:56:47 +00:00
|
|
|
OnParseError(response.Content, ex);
|
2016-07-27 04:08:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|