hebits: migrate to yml (#13380)

This commit is contained in:
ilike2burnthing 2022-07-20 09:13:19 +01:00 committed by GitHub
parent c8c9b7e8a0
commit f314668979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 169 additions and 180 deletions

View File

@ -0,0 +1,169 @@
---
id: hebits
name: Hebits
description: "The Israeli Tracker"
language: he-IL
type: private
encoding: UTF-8
links:
- https://hebits.net/
caps:
categorymappings:
- {id: 1, cat: Movies, desc: "סרטים (Movies)"}
- {id: 2, cat: TV, desc: "סדרות (TV)"}
- {id: 3, cat: TV/Other, desc: "הצגות והופעות (Theater)"}
- {id: 4, cat: PC/0day, desc: "תוכנות (Apps)"}
- {id: 5, cat: PC/Games, desc: "משחקים (Games)"}
- {id: 6, cat: Audio, desc: "מוזיקה (Music)"}
- {id: 7, cat: Books, desc: "ספרים (Books)"}
- {id: 8, cat: Movies/Other, desc: "חבילות סרטים (Movies Packs)"}
- {id: 9, cat: XXX, desc: "פורנו (Porn)"}
- {id: 10, cat: Other, desc: "שונות (Other)"}
modes:
search: [q]
tv-search: [q, season, ep, imdbid]
movie-search: [q, imdbid]
music-search: [q]
book-search: [q]
settings:
- name: cookie
type: text
label: Cookie
- name: info
type: info
label: How to get the Cookie
default: "<ol><li>Login to this tracker with your browser<li>Open the <b>DevTools</b> panel by pressing <b>F12</b><li>Select the <b>Network</b> tab<li>Click on the <b>Doc</b> button (Chrome Browser) or <b>HTML</b> button (FireFox)<li>Refresh the page by pressing <b>F5</b><li>Click on the first row entry<li>Select the <b>Headers</b> tab on the Right panel<li>Find <b>'cookie:'</b> in the <b>Request Headers</b> section<li><b>Select</b> and <b>Copy</b> the whole cookie string <i>(everything after 'cookie: ')</i> and <b>Paste</b> here.</ol>"
- name: freeleech
type: checkbox
label: Search freeleech only
default: false
- name: sort
type: select
label: Sort requested from site
default: time
options:
time: created
seeders: seeders
size: size
- name: type
type: select
label: Order requested from site
default: desc
options:
desc: desc
asc: asc
login:
method: cookie
inputs:
cookie: "{{ .Config.cookie }}"
test:
path: torrents.php
search:
paths:
- path: torrents.php
inputs:
searchstr: "{{ if .Query.IMDBID }}{{ .Query.IMDBID }}{{ else }}{{ .Keywords }}{{ end }}"
order_by: "{{ .Config.sort }}"
order_way: "{{ .Config.type }}"
imdbgt: 0
imdblt: 10
# 1 freeleech, 2 neutral, 3 50%, 4 2x, 5 3x, 9 75%, 11 only perks, 0 normal
freetorrent: "{{ if .Config.freeleech }}1{{ else }}{{ end }}"
action: advanced
searchsubmit: 1
$raw: "{{ range .Categories }}filter_cat[{{.}}]=1&{{end}}"
rows:
selector: .torrent
fields:
category:
selector: .tooltip
case:
"div[class*=\"movies\"]": 1
"div[class*=\"tv\"]": 2
"div[class*=\"theater\"]": 3
"div[class*=\"software\"]": 4
"div[class*=\"games\"]": 5
"div[class*=\"music\"]": 6
"div[class*=\"books\"]": 7
"div[class*=\"packs\"]": 8
"div[class*=\"porno\"]": 9
"div[class*=\"other\"]": 10
title_notenglish:
selector: .torrent_info:not(:contains("a")):not(:contains("e")):not(:contains("i")):not(:contains("o")):not(:contains("u")):not(:contains("y"))
optional: true
filters:
# space out the book language at the end of the title
# everything within the outermost quotes below is right to left
- name: re_replace
args: ["(אנגלית)$", " - אנגלית"] # English
- name: re_replace
args: ["(עברית)$", " - עברית"] # Hebrew
title_english:
selector: .torrent_info
optional: true
filters:
- name: append
args: "א" # catch English only results
- name: regexp
args: "(.+?[a-zA-Z0-9\\]\\)\\}])[א-ת].*" # remove Hebrew labels from end of title, account for titles ending in letters, numbers, and brackets
title:
text: "{{ if .Result.title_notenglish }}{{ .Result.title_notenglish }}{{ else }}{{ .Result.title_english }}{{ end }}"
details:
selector: a[href*="torrentid"]
attribute: href
magnet:
selector: a[href^="magnet"]
attribute: href
optional: true
download:
selector: a[href^="torrents.php?action=download"]
attribute: href
poster:
selector: a[data-cover^="/images/"]
attribute: data-cover
files:
selector: td:nth-child(3)
date:
selector: td:nth-child(4) span
attribute: title
filters:
- name: append
args: " +02:00" # IST
- name: dateparse
args: "02/01/2006, 15:04 -07:00"
size:
selector: td:nth-child(5)
grabs:
selector: td:nth-child(6)
seeders:
selector: td:nth-child(7)
leechers:
selector: td:nth-child(8)
downloadvolumefactor:
case:
"strong.tl_notice[title*=\"חצי פריליץ'\"]": 0.5 # 50%
"strong.tl_notice[title*=\"75% פריליץ'!\"]": 0.25 # 75%
"strong.tl_notice[title*=\"נטרלי\"]": 0 # neutral
"strong.tl_notice[title*=\"פריליץ'\"]": 0 # freeleech
"*": 1
uploadvolumefactor:
case:
"strong.tl_notice[title*=\"העלאה משולשת\"]": 3 # 3x
"strong.tl_notice[title*=\"העלאה כפולה\"]": 2 # 2x
"strong.tl_notice[title*=\"נטרלי\"]": 0 # neutral
"*": 1
minimumratio:
text: 1.0
minimumseedtime:
# 7 days (as seconds = 7 x 24 x 60 x 60)
text: 604800
description:
selector: div.tags
# Gazelle

View File

@ -1,180 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using AngleSharp.Html.Parser;
using Jackett.Common.Helpers;
using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Newtonsoft.Json.Linq;
using NLog;
namespace Jackett.Common.Indexers
{
[ExcludeFromCodeCoverage]
public class Hebits : BaseWebIndexer
{
private string SearchUrl => SiteLink + "torrents.php?order_way=desc&order_by=time";
private new ConfigurationDataCookie configData => (ConfigurationDataCookie)base.configData;
public Hebits(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l,
IProtectionService ps, ICacheService cs)
: base(id: "hebits",
name: "Hebits",
description: "The Israeli Tracker",
link: "https://hebits.net/",
caps: new TorznabCapabilities
{
TvSearchParams = new List<TvSearchParam>
{
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep
},
MovieSearchParams = new List<MovieSearchParam>
{
MovieSearchParam.Q
},
MusicSearchParams = new List<MusicSearchParam>
{
MusicSearchParam.Q
},
BookSearchParams = new List<BookSearchParam>
{
BookSearchParam.Q
}
},
configService: configService,
client: wc,
logger: l,
p: ps,
cacheService: cs,
configData: new ConfigurationDataCookie())
{
Encoding = Encoding.GetEncoding("UTF-8");
Language = "he-IL";
Type = "private";
AddCategoryMapping(1, TorznabCatType.Movies, "סרטים (Movies)");
AddCategoryMapping(2, TorznabCatType.TV, "סדרות (TV)");
AddCategoryMapping(3, TorznabCatType.TVOther, "הצגות והופעות (Theater)");
AddCategoryMapping(4, TorznabCatType.PC, "תוכנות (Apps)");
AddCategoryMapping(5, TorznabCatType.Console, "משחקים (Games)");
AddCategoryMapping(6, TorznabCatType.Audio, "מוזיקה (Music)");
AddCategoryMapping(7, TorznabCatType.Books, "ספרים (Books)");
AddCategoryMapping(8, TorznabCatType.MoviesOther, "חבילות סרטים (Movies Packs)");
AddCategoryMapping(9, TorznabCatType.XXX, "פורנו (Porn)");
AddCategoryMapping(10, TorznabCatType.Other, "שונות (Other)");
}
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
LoadValuesFromJson(configJson);
CookieHeader = configData.Cookie.Value;
try
{
var results = await PerformQuery(new TorznabQuery());
if (!results.Any())
throw new Exception("Found 0 results in the tracker");
IsConfigured = true;
SaveConfig();
return IndexerConfigurationStatus.Completed;
}
catch (Exception e)
{
IsConfigured = false;
throw new Exception("Your cookie did not work: " + e.Message);
}
}
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
var searchUrl = SearchUrl;
if (!string.IsNullOrWhiteSpace(searchString))
searchUrl += "&action=advanced&searchsubmit=1&filelist=" + WebUtilityHelpers.UrlEncode(searchString, Encoding);
var cats = MapTorznabCapsToTrackers(query);
if (cats.Count > 0)
searchUrl = cats.Aggregate(searchUrl, (url, cat) => $"{url}&filter_cat[{cat}]=1");
var response = await RequestWithCookiesAsync(searchUrl);
try
{
var parser = new HtmlParser();
var dom = parser.ParseDocument(response.ContentString);
var rows = dom.QuerySelectorAll("table#torrent_table > tbody > tr.torrent");
foreach (var row in rows)
{
var release = new ReleaseInfo
{
MinimumRatio = 1.0,
MinimumSeedTime = 604800 // 168 hours
};
var qCat = row.QuerySelector("div[class*=\"cats_\"]");
var catStr = qCat.GetAttribute("class").Split('_')[1];
release.Category = catStr switch
{
"movies" => MapTrackerCatToNewznab("1"),
"tv" => MapTrackerCatToNewznab("2"),
"theater" => MapTrackerCatToNewznab("3"),
"software" => MapTrackerCatToNewznab("4"),
"games" => MapTrackerCatToNewznab("5"),
"music" => MapTrackerCatToNewznab("6"),
"books" => MapTrackerCatToNewznab("7"),
"moviespacks" => MapTrackerCatToNewznab("8"),
"porno" => MapTrackerCatToNewznab("9"),
"other" => MapTrackerCatToNewznab("10"),
_ => throw new Exception("Error parsing category! Unknown cat=" + catStr),
};
var qTitle = row.QuerySelector("div.torrent_info");
release.Title = qTitle.TextContent.Trim();
var qDetailsLink = row.QuerySelector("a.torrent_name");
// I don't understand, I correctly build the poster as
// https://hebits.net/images/oRbJr/3776T8DeNsKbyUM3tsV0LBY_v_JfdfmkhShh_LguTP.jpg
// yet the dashboard shows a broken icon symbol! No idea why this does not work.
//if (!string.IsNullOrEmpty(qDetailsLink.GetAttribute("data-cover")))
//{
// release.Poster = new Uri(SiteLink.TrimEnd('/') + qDetailsLink.GetAttribute("data-cover"));
// logger.Debug("poster=" + release.Poster);
//}
release.Details = new Uri(SiteLink + qDetailsLink.GetAttribute("href"));
release.Link = new Uri(SiteLink + row.QuerySelector("a[href^=\"torrents.php?action=download&id=\"]").GetAttribute("href"));
release.Guid = release.Link;
var qDate = row.QuerySelector("span.time").GetAttribute("title");
release.PublishDate = DateTime.ParseExact(qDate, "dd/MM/yyyy, HH:mm", CultureInfo.InvariantCulture);
var qSize = row.QuerySelector("td:nth-last-child(4)").TextContent.Trim();
release.Size = ReleaseInfo.GetBytes(qSize);
release.Seeders = ParseUtil.CoerceInt(row.QuerySelector("td:nth-last-child(2)").TextContent.Trim());
release.Peers = release.Seeders + ParseUtil.CoerceInt(row.QuerySelector("td:nth-last-child(1)").TextContent.Trim());
release.Files = ParseUtil.CoerceInt(row.QuerySelector("td:nth-last-child(6)").TextContent.Trim());
release.Grabs = ParseUtil.CoerceInt(row.QuerySelector("td:nth-last-child(3)").TextContent.Trim());
release.DownloadVolumeFactor = release.Title.Contains("פריליץ")
? 0
: release.Title.Contains("חצי פריליץ")
? 0.5
: release.Title.Contains("75% פריליץ")
? 0.25
: 1;
release.UploadVolumeFactor = release.Title.Contains("העלאה משולשת")
? 3
: release.Title.Contains("העלאה כפולה")
? 2
: 1;
releases.Add(release);
}
}
catch (Exception ex)
{
OnParseError(response.ContentString, ex);
}
return releases;
}
}
}