From 6e61f386441e7aa7499e1d2491a5c9eaaf06e5a5 Mon Sep 17 00:00:00 2001 From: Ellmout Date: Sat, 21 Oct 2017 11:05:08 +0200 Subject: [PATCH] Convert ArcheTorrent from C# to Definition file (#1987) * Merge ArcheTorrent from C# to Definition files * Merge ArcheTorrent from C# to Definition files (forgot csproj file) --- src/Jackett/Definitions/archetorrent.yml | 135 +++++++++++++++ src/Jackett/Indexers/ArcheTorrent.cs | 204 ----------------------- src/Jackett/Jackett.csproj | 6 +- 3 files changed, 136 insertions(+), 209 deletions(-) create mode 100644 src/Jackett/Definitions/archetorrent.yml delete mode 100644 src/Jackett/Indexers/ArcheTorrent.cs diff --git a/src/Jackett/Definitions/archetorrent.yml b/src/Jackett/Definitions/archetorrent.yml new file mode 100644 index 000000000..257f19cc3 --- /dev/null +++ b/src/Jackett/Definitions/archetorrent.yml @@ -0,0 +1,135 @@ +--- + site: archetorrent + name: ArcheTorrent + description: "ArcheTorrent is a FRENCH Private Torrent Tracker" + language: fr-fr + type: private + encoding: UTF-8 + links: + - https://archetorrent.com + + caps: + categorymappings: + - {id: 18, cat: PC, desc: "Applications: PC"} + - {id: 19, cat: PC/Mac, desc: "Applications: Mac"} + - {id: 54, cat: PC, desc: "Applications: linux"} + - {id: 56, cat: XXX/Other, desc: "Autres: ebook xxx"} + - {id: 36, cat: Books, desc: "Autres: E-Books"} + - {id: 37, cat: Other, desc: "Autres: Images"} + - {id: 38, cat: PC/Phone-Other, desc: "Autres: Telephone-mobile"} + - {id: 47, cat: Movies, desc: "Films: Animé"} + - {id: 1, cat: Movies/DVD, desc: "Films: DVD"} + - {id: 2, cat: Movies/SD, desc: "Films: Dvdrip"} + - {id: 68, cat: Movies, desc: "Films: TAT Releases"} + - {id: 70, cat: Movies/HD, desc: "Films: UHD 4K"} + - {id: 69, cat: Movies, desc: "Films: Retro"} + - {id: 3, cat: Movies/HD, desc: "Films: HD1080"} + - {id: 42, cat: Movies/HD, desc: "Films: HD720"} + - {id: 4, cat: Movies, desc: "Films: Cam/Ts"} + - {id: 22, cat: Movies/BluRay, desc: "Films: bluray"} + - {id: 23, cat: Movies/3D, desc: "Films: 3D"} + - {id: 24, cat: Movies/Foreign, desc: "Films: VOSTFR"} + - {id: 25, cat: XXX, desc: "Films: Adulte"} + - {id: 48, cat: TV/Documentary, desc: "Films: Documentaire"} + - {id: 49, cat: Movies/Other, desc: "Films: Spectacle"} + - {id: 51, cat: Movies/SD, desc: "Films: R5"} + - {id: 52, cat: Movies/SD, desc: "Films: bdrip"} + - {id: 53, cat: Movies/SD, desc: "Films: brrip"} + - {id: 55, cat: Movies/DVD, desc: "Films: dvd-pack"} + - {id: 57, cat: Movies, desc: "Films: manga"} + - {id: 59, cat: Movies/WEBDL, desc: "Films: Webrip"} + - {id: 63, cat: Movies/SD, desc: "Films: M-HD"} + - {id: 10, cat: PC/Games, desc: "Jeux: PC"} + - {id: 11, cat: Console/Other, desc: "Jeux: PS2"} + - {id: 43, cat: Console/PS3, desc: "Jeux: PS3"} + - {id: 12, cat: Console/PSP, desc: "Jeux: PSP"} + - {id: 14, cat: Console/Xbox 360, desc: "Jeux: Xbox360"} + - {id: 44, cat: Console/Wii, desc: "Jeux: Wii"} + - {id: 45, cat: Console/NDS, desc: "Jeux: DS"} + - {id: 27, cat: Audio/Video, desc: "Musique: Clip Video"} + - {id: 62, cat: TV/SD, desc: "Serie tv: TV BDRip"} + - {id: 5, cat: TV/SD, desc: "Serie tv: Dvdrip"} + - {id: 41, cat: TV/HD, desc: "Serie tv: Hd"} + - {id: 60, cat: TV/SD, desc: "Serie tv: pack série tv"} + - {id: 64, cat: TV/FOREIGN, desc: "Serie tv: vostfr"} + - {id: 65, cat: TV/HD, desc: "Serie tv: Série tv 720P"} + - {id: 66, cat: TV/HD, desc: "Serie tv: Série tv 1080P"} + - {id: 67, cat: TV/HD, desc: "Serie tv: Série tv PackHD"} + - {id: 73, cat: TV/Anime, desc: "Serie tv: Anime "} + - {id: 72, cat: TV/Sport, desc: "Sport: sport"} + - {id: 61, cat: TV/SD, desc: "Tv: DVDRip"} + + modes: + search: [q] + tv-search: [q, season, ep] + + login: + path: account-login.php + method: post + inputs: + username: "{{ .Config.username }}" + password: "{{ .Config.password }}" + error: + - selector: form:contains("Erreur") + message: + selector: form + remove: table + test: + path: torrents-search.php + + search: + path: torrents-search.php + inputs: + $raw: "{{range .Categories}}c{{.}}=1&{{end}}" + search: "{{ .Query.Keywords }}" + incldead: "1" + + rows: + selector: table.ttable_headinner > tbody > tr[class^="t-row"] + fields: + download: + selector: a[href^="torrents-details.php?id="] + attribute: href + filters: + - name: replace + args: ["torrents-details.php", "download.php"] + date: + selector: td:nth-child(2) a + attribute: onmouseover + filters: + - name: regexp + args: "Poster le: (.*?)
" + - name: dateparse + args: "02-01-2006" + title: + selector: a[href^="torrents-details.php?id="] + filters: + - name: replace + args: [" - (Nouveau!)", ""] + category: + selector: a[href^="torrents.php?cat="] + attribute: href + filters: + - name: querystring + args: cat + details: + selector: a[href^="torrents-details.php?id="] + attribute: href + banner: + selector: img.rounded-img + attribute: src + size: + selector: td:nth-child(5) + grabs: + selector: td:nth-child(8) font b + seeders: + selector: td:nth-child(6) font b + leechers: + selector: td:nth-child(7) font b + downloadvolumefactor: + case: + img[title="freeleech"]: "0" + "*": "1" + uploadvolumefactor: + case: + "*": "1" \ No newline at end of file diff --git a/src/Jackett/Indexers/ArcheTorrent.cs b/src/Jackett/Indexers/ArcheTorrent.cs deleted file mode 100644 index 0cb2d7045..000000000 --- a/src/Jackett/Indexers/ArcheTorrent.cs +++ /dev/null @@ -1,204 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using AngleSharp.Parser.Html; -using Newtonsoft.Json.Linq; -using NLog; -using Jackett.Models; -using Jackett.Models.IndexerConfig; -using Jackett.Services; -using Jackett.Utils; -using Jackett.Utils.Clients; - -namespace Jackett.Indexers -{ - class ArcheTorrent : BaseWebIndexer - { - string LoginUrl { get { return SiteLink + "account-login.php"; } } - string BrowseUrl { get { return SiteLink + "torrents-search.php"; } } - string DownloadUrl { get { return SiteLink + "download.php"; } } - - new ConfigurationDataBasicLogin configData - { - get { return (ConfigurationDataBasicLogin)base.configData; } - set { base.configData = value; } - } - - public ArcheTorrent(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) - : base(name: "Arche Torrent", - description: "French Torrent Tracker", - link: "https://www.archetorrent.com/", - configService: configService, - logger: logger, - p: protectionService, - client: webClient, - configData: new ConfigurationDataBasicLogin() - ) - { - Encoding = Encoding.GetEncoding("UTF-8"); - Language = "fr-fr"; - Type = "private"; - - AddCategoryMapping (18, TorznabCatType.PC, "Applications: PC"); - AddCategoryMapping (19, TorznabCatType.PCMac, "Applications: Mac"); - AddCategoryMapping (54, TorznabCatType.PC, "Applications: linux"); - AddCategoryMapping (56, TorznabCatType.XXXOther, "Autres: ebook xxx"); - AddCategoryMapping (36, TorznabCatType.Books, "Autres: E-Books"); - AddCategoryMapping (37, TorznabCatType.Other, "Autres: Images"); - AddCategoryMapping (38, TorznabCatType.PCPhoneOther, "Autres: Telephone-mobile"); - AddCategoryMapping (47, TorznabCatType.Movies, "Films: Animé"); - AddCategoryMapping (1, TorznabCatType.MoviesDVD, "Films: DVD"); - AddCategoryMapping (2, TorznabCatType.MoviesSD, "Films: Dvdrip"); - AddCategoryMapping (68, TorznabCatType.Movies, "Films: TAT Releases"); - AddCategoryMapping (70, TorznabCatType.MoviesHD, "Films: UHD 4K"); - AddCategoryMapping (69, TorznabCatType.Movies, "Films: Retro"); - AddCategoryMapping (3, TorznabCatType.MoviesHD, "Films: HD1080"); - AddCategoryMapping (42, TorznabCatType.MoviesHD, "Films: HD720"); - AddCategoryMapping (4, TorznabCatType.Movies, "Films: Cam/Ts"); - AddCategoryMapping (22, TorznabCatType.MoviesBluRay, "Films: bluray"); - AddCategoryMapping (23, TorznabCatType.Movies3D, "Films: 3D"); - AddCategoryMapping (24, TorznabCatType.MoviesForeign, "Films: VOSTFR"); - AddCategoryMapping (25, TorznabCatType.XXX, "Films: Adulte"); - AddCategoryMapping (48, TorznabCatType.TVDocumentary, "Films: Documentaire"); - AddCategoryMapping (49, TorznabCatType.MoviesOther, "Films: Spectacle"); - AddCategoryMapping (51, TorznabCatType.MoviesSD, "Films: R5"); - AddCategoryMapping (52, TorznabCatType.MoviesSD, "Films: bdrip"); - AddCategoryMapping (53, TorznabCatType.MoviesSD, "Films: brrip"); - AddCategoryMapping (55, TorznabCatType.MoviesDVD, "Films: dvd-pack"); - AddCategoryMapping (57, TorznabCatType.Movies, "Films: manga"); - AddCategoryMapping (59, TorznabCatType.MoviesWEBDL, "Films: Webrip"); - AddCategoryMapping (63, TorznabCatType.MoviesSD, "Films: M-HD"); - AddCategoryMapping (10, TorznabCatType.PCGames, "Jeux: PC"); - AddCategoryMapping (11, TorznabCatType.ConsoleOther, "Jeux: PS2"); - AddCategoryMapping (43, TorznabCatType.ConsolePS3, "Jeux: PS3"); - AddCategoryMapping (12, TorznabCatType.ConsolePSP, "Jeux: PSP"); - AddCategoryMapping (14, TorznabCatType.ConsoleXbox360, "Jeux: Xbox360"); - AddCategoryMapping (44, TorznabCatType.ConsoleWii, "Jeux: Wii"); - AddCategoryMapping (45, TorznabCatType.ConsoleNDS, "Jeux: DS"); - AddCategoryMapping (27, TorznabCatType.AudioVideo, "Musique: Clip Video"); - AddCategoryMapping (62, TorznabCatType.TVSD, "Serie tv: TV BDRip"); - AddCategoryMapping (5, TorznabCatType.TVSD, "Serie tv: Dvdrip"); - AddCategoryMapping (41, TorznabCatType.TVHD, "Serie tv: Hd"); - AddCategoryMapping (60, TorznabCatType.TVSD, "Serie tv: pack série tv"); - AddCategoryMapping (64, TorznabCatType.TVFOREIGN, "Serie tv: vostfr"); - AddCategoryMapping (65, TorznabCatType.TVHD, "Serie tv: Série tv 720P"); - AddCategoryMapping (66, TorznabCatType.TVHD, "Serie tv: Série tv 1080P"); - AddCategoryMapping (67, TorznabCatType.TVHD, "Serie tv: Série tv PackHD"); - AddCategoryMapping (73, TorznabCatType.TVAnime, "Serie tv: Anime "); - AddCategoryMapping (72, TorznabCatType.TVSport, "Sport: sport"); - AddCategoryMapping (61, TorznabCatType.TVSD, "Tv: DVDRip"); - } - - public override async Task ApplyConfiguration(JToken configJson) - { - configData.LoadValuesFromJson(configJson); - - var pairs = new Dictionary - { - { "username", configData.Username.Value }, - { "password", configData.Password.Value } - }; - - var result = await PostDataWithCookies(LoginUrl, pairs); - - await ConfigureIfOK(result.Cookies, result.Cookies != null, () => - { - var errorMessage = result.Content; - throw new ExceptionWithConfigData(errorMessage, configData); - }); - - return IndexerConfigurationStatus.RequiresTesting; - } - - protected override async Task> PerformQuery(TorznabQuery query) - { - var releases = new List(); - var searchString = query.GetQueryString(); - - var arraySearchString = searchString.Split(' '); - searchString = ""; - foreach (var subSearchString in arraySearchString) - { - searchString += "+" + subSearchString + " "; - } - searchString = searchString.Trim (); - - var queryCollection = new Dictionary(); - queryCollection.Add ("search", searchString); - queryCollection.Add ("cat", "0"); - queryCollection.Add ("incldead", "0"); - queryCollection.Add ("freeleech", "0"); - queryCollection.Add ("lang", "0"); - - var searchUrl = BrowseUrl + "?" + queryCollection.GetQueryString (); - - var results = await RequestStringWithCookies (searchUrl); - - try - { - var bannerRe = new Regex("src=(.*?)>"); - var dateRe = new Regex("Poster le: (.*?)
Heure: (.*?)
"); - - var RowsSelector = "table.ttable_headinner tr.t-row"; - var SearchResultParser = new HtmlParser(); - var SearchResultDocument = SearchResultParser.Parse(results.Content); - var Rows = SearchResultDocument.QuerySelectorAll(RowsSelector); - var lastDate = DateTime.Now; - - foreach (var Row in Rows) - { - var release = new ReleaseInfo(); - release.MinimumRatio = 1; - release.MinimumSeedTime = 0; - - var category = Row.QuerySelector("td:nth-child(1) a"); - var title = Row.QuerySelector("td:nth-child(2) a b"); - - var link = Row.QuerySelector("td:nth-child(2) a"); - var mouseover = link.GetAttribute("onMouseover"); - var Size = Row.QuerySelector("td:nth-child(5)"); - var Grabs = Row.QuerySelector("td:nth-child(8) font b"); - var Seeders = Row.QuerySelector("td:nth-child(6) font b"); - var Leechers = Row.QuerySelector("td:nth-child(7) font b"); - var categoryId = category.GetAttribute("href").Split('=').Last(); - var torrentId = link.GetAttribute ("href").Split ('&').First ().Split ('=').Last (); - - release.Title = title.TextContent; - release.Category = MapTrackerCatToNewznab(categoryId); - release.Comments = new Uri(SiteLink + link.GetAttribute("href")); - release.Link = new Uri(DownloadUrl + "?id=" + torrentId); - release.Guid = release.Link; - release.Size = ReleaseInfo.GetBytes(Size.TextContent); - release.Seeders = ParseUtil.CoerceInt(Seeders.TextContent); - release.Peers = ParseUtil.CoerceInt(Leechers.TextContent) + release.Seeders; - release.Grabs = ParseUtil.CoerceLong(Grabs.TextContent); - - var bannerReMatch = bannerRe.Match(mouseover); - if (bannerReMatch.Success) - release.BannerUrl = new Uri(bannerReMatch.Groups[1].Value); - - var dateReMatch = dateRe.Match(mouseover); - if (dateReMatch.Success) - { - var dateStr = dateReMatch.Groups[1].Value + " " + dateReMatch.Groups[2].Value; - var dateTime = DateTime.ParseExact(dateStr, "dd-MM-yyyy HH:mm", CultureInfo.InvariantCulture); - release.PublishDate = dateTime.ToLocalTime(); - } - - releases.Add(release); - } - } - catch (Exception ex) - { - OnParseError(results.Content, ex); - } - - return releases; - } - - } -} diff --git a/src/Jackett/Jackett.csproj b/src/Jackett/Jackett.csproj index e17519739..0710851a3 100644 --- a/src/Jackett/Jackett.csproj +++ b/src/Jackett/Jackett.csproj @@ -178,7 +178,6 @@ - @@ -589,10 +588,7 @@ - - - - +