2017-10-29 06:21:18 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using CsQuery;
|
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
|
|
|
|
{
|
|
|
|
|
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"; } }
|
|
|
|
|
|
2017-10-29 06:21:18 +00:00
|
|
|
|
private new ConfigurationDataBasicLogin configData
|
2016-07-27 04:08:06 +00:00
|
|
|
|
{
|
|
|
|
|
get { return (ConfigurationDataBasicLogin)base.configData; }
|
|
|
|
|
set { base.configData = value; }
|
|
|
|
|
}
|
|
|
|
|
|
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",
|
|
|
|
|
description: "The Israeli Tracker",
|
|
|
|
|
link: "https://hebits.net/",
|
|
|
|
|
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
2017-07-10 20:58:44 +00:00
|
|
|
|
configService: configService,
|
2016-07-27 04:08:06 +00:00
|
|
|
|
client: wc,
|
|
|
|
|
logger: l,
|
|
|
|
|
p: ps,
|
|
|
|
|
downloadBase: "https://hebits.net/",
|
|
|
|
|
configData: new ConfigurationDataBasicLogin())
|
|
|
|
|
{
|
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);
|
2016-07-27 04:08:06 +00:00
|
|
|
|
var pairs = new Dictionary<string, string> {
|
|
|
|
|
{ "username", configData.Username.Value },
|
|
|
|
|
{ "password", configData.Password.Value }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Get inital cookies
|
|
|
|
|
CookieHeader = string.Empty;
|
|
|
|
|
var result = await RequestLoginAndFollowRedirect(LoginPostUrl, pairs, CookieHeader, true, null, SiteLink);
|
|
|
|
|
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("OK"), () =>
|
|
|
|
|
{
|
|
|
|
|
CQ dom = result.Content;
|
2018-10-30 14:56:22 +00:00
|
|
|
|
var errorMessage = dom.Text().Trim();
|
|
|
|
|
errorMessage += " attempts left. Please check your credentials.";
|
2016-07-27 04:08:06 +00:00
|
|
|
|
throw new ExceptionWithConfigData(errorMessage, configData);
|
|
|
|
|
});
|
|
|
|
|
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
|
|
|
|
}
|
2018-02-12 15:30:51 +00:00
|
|
|
|
string.Format(SearchUrl, WebUtilityHelpers.UrlEncode(searchString, Encoding));
|
2016-07-27 04:08:06 +00:00
|
|
|
|
|
|
|
|
|
var cats = MapTorznabCapsToTrackers(query);
|
|
|
|
|
if (cats.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var cat in cats)
|
|
|
|
|
{
|
|
|
|
|
searchUrl += "&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
|
|
|
|
|
{
|
2016-12-06 13:56:47 +00:00
|
|
|
|
CQ dom = response.Content;
|
2016-07-27 04:08:06 +00:00
|
|
|
|
|
|
|
|
|
CQ qRows = dom[".browse > div > div"];
|
|
|
|
|
|
|
|
|
|
foreach (var row in qRows)
|
|
|
|
|
{
|
|
|
|
|
var release = new ReleaseInfo();
|
|
|
|
|
|
|
|
|
|
var qRow = row.Cq();
|
|
|
|
|
|
|
|
|
|
var debug = qRow.Html();
|
|
|
|
|
|
|
|
|
|
release.MinimumRatio = 1;
|
2020-01-11 18:07:19 +00:00
|
|
|
|
release.MinimumSeedTime = 172800; // 48 hours
|
2016-07-27 04:08:06 +00:00
|
|
|
|
|
2019-09-30 22:38:20 +00:00
|
|
|
|
var qTitle = qRow.Find(".bTitle");
|
|
|
|
|
var titleParts = qTitle.Text().Split('/');
|
2017-10-29 06:21:18 +00:00
|
|
|
|
if (titleParts.Length >= 2)
|
2016-09-11 17:52:51 +00:00
|
|
|
|
release.Title = titleParts[1].Trim();
|
|
|
|
|
else
|
|
|
|
|
release.Title = titleParts[0].Trim();
|
|
|
|
|
|
2019-09-30 22:38:20 +00:00
|
|
|
|
var qDetailsLink = qTitle.Find("a[href^=\"details.php\"]");
|
2016-11-20 09:22:17 +00:00
|
|
|
|
release.Comments = new Uri(SiteLink + qDetailsLink.Attr("href"));
|
2018-05-13 16:23:40 +00:00
|
|
|
|
release.Link = new Uri(SiteLink + qRow.Find("a[href^=\"download.php\"]").Attr("href"));
|
2016-07-27 04:08:06 +00:00
|
|
|
|
release.Guid = release.Link;
|
|
|
|
|
|
|
|
|
|
var dateString = qRow.Find("div:last-child").Text().Trim();
|
|
|
|
|
var pattern = "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}";
|
|
|
|
|
var match = Regex.Match(dateString, pattern);
|
|
|
|
|
if (match.Success)
|
|
|
|
|
{
|
|
|
|
|
release.PublishDate = DateTime.ParseExact(match.Value, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sizeStr = qRow.Find(".bSize").Text();
|
|
|
|
|
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
|
|
|
|
release.Seeders = ParseUtil.CoerceInt(qRow.Find(".bUping").Text().Trim());
|
|
|
|
|
release.Peers = release.Seeders + ParseUtil.CoerceInt(qRow.Find(".bDowning").Text().Trim());
|
|
|
|
|
|
2016-10-27 07:35:31 +00:00
|
|
|
|
var files = qRow.Find("div.bFiles").Get(0).LastChild.ToString();
|
|
|
|
|
release.Files = ParseUtil.CoerceInt(files);
|
|
|
|
|
|
|
|
|
|
var grabs = qRow.Find("div.bFinish").Get(0).LastChild.ToString();
|
|
|
|
|
release.Grabs = ParseUtil.CoerceInt(grabs);
|
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
|
if (qRow.Find("img[src=\"/pic/free.jpg\"]").Length >= 1)
|
|
|
|
|
release.DownloadVolumeFactor = 0;
|
2016-10-27 07:35:31 +00:00
|
|
|
|
else
|
|
|
|
|
release.DownloadVolumeFactor = 1;
|
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
|
if (qRow.Find("img[src=\"/pic/triple.jpg\"]").Length >= 1)
|
2016-10-27 07:35:31 +00:00
|
|
|
|
release.UploadVolumeFactor = 3;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
else if (qRow.Find("img[src=\"/pic/double.jpg\"]").Length >= 1)
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|