2020-02-09 18:08:34 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Specialized;
|
2020-05-03 23:35:52 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2020-02-09 18:08:34 +00:00
|
|
|
using System.Globalization;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
2019-12-15 16:49:46 +00:00
|
|
|
using AngleSharp.Html.Parser;
|
2019-12-11 03:34:32 +00:00
|
|
|
using Jackett.Common.Models;
|
|
|
|
using Jackett.Common.Models.IndexerConfig;
|
|
|
|
using Jackett.Common.Services.Interfaces;
|
|
|
|
using Jackett.Common.Utils;
|
|
|
|
using Jackett.Common.Utils.Clients;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using NLog;
|
|
|
|
|
|
|
|
namespace Jackett.Common.Indexers
|
|
|
|
{
|
2020-05-03 23:35:52 +00:00
|
|
|
[ExcludeFromCodeCoverage]
|
2019-12-11 03:34:32 +00:00
|
|
|
public class Partis : BaseWebIndexer
|
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
private string LoginUrl => SiteLink + "user/login/";
|
|
|
|
private string SearchUrl => SiteLink + "torrent/show/";
|
2019-12-11 03:34:32 +00:00
|
|
|
|
|
|
|
private new ConfigurationDataBasicLogin configData
|
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
get => (ConfigurationDataBasicLogin)base.configData;
|
|
|
|
set => base.configData = value;
|
2019-12-11 03:34:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Partis(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
2020-05-11 19:59:28 +00:00
|
|
|
: base(id: "partis",
|
|
|
|
name: "Partis",
|
2019-12-11 03:34:32 +00:00
|
|
|
description: "Partis is a SLOVENIAN Private Torrent Tracker",
|
|
|
|
link: "https://www.partis.si/",
|
2020-10-18 17:26:22 +00:00
|
|
|
caps: new TorznabCapabilities{
|
|
|
|
MovieSearchParams = new List<MovieSearchParam> { MovieSearchParam.Q }
|
|
|
|
},
|
2019-12-11 03:34:32 +00:00
|
|
|
configService: configService,
|
|
|
|
client: wc,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
|
|
|
configData: new ConfigurationDataBasicLogin())
|
|
|
|
{
|
|
|
|
Encoding = Encoding.UTF8;
|
|
|
|
Language = "sl-sl";
|
|
|
|
Type = "private";
|
|
|
|
|
|
|
|
// Blu Ray
|
|
|
|
AddCategoryMapping(40, TorznabCatType.MoviesBluRay, "Blu-Ray 1080p/i");
|
|
|
|
AddCategoryMapping(42, TorznabCatType.MoviesBluRay, "Blu-Ray 720p/i");
|
|
|
|
AddCategoryMapping(43, TorznabCatType.MoviesBluRay, "Blu-Ray B-Disc");
|
|
|
|
AddCategoryMapping(41, TorznabCatType.MoviesBluRay, "Blu-Ray 3D");
|
|
|
|
AddCategoryMapping(44, TorznabCatType.MoviesBluRay, "Blu-Ray Remux");
|
|
|
|
AddCategoryMapping(45, TorznabCatType.MoviesBluRay, "Blu-Ray Remux/Disc");
|
|
|
|
|
|
|
|
// UHD
|
|
|
|
AddCategoryMapping(32, TorznabCatType.MoviesUHD, "UHD 4K Disc");
|
|
|
|
AddCategoryMapping(55, TorznabCatType.MoviesUHD, "UHD 4K Remux");
|
|
|
|
|
|
|
|
// HD
|
|
|
|
AddCategoryMapping(20, TorznabCatType.MoviesHD, "HD");
|
|
|
|
AddCategoryMapping(4, TorznabCatType.MoviesSD, "DVD-R");
|
|
|
|
AddCategoryMapping(7, TorznabCatType.MoviesSD, "XviD");
|
|
|
|
AddCategoryMapping(12, TorznabCatType.MoviesSD, "Anime");
|
|
|
|
AddCategoryMapping(30, TorznabCatType.MoviesSD, "Risanke");
|
|
|
|
AddCategoryMapping(15, TorznabCatType.MoviesSD, "Sport");
|
|
|
|
|
|
|
|
// TV Show
|
|
|
|
AddCategoryMapping(53, TorznabCatType.TVWEBDL, "TV WEB-DL");
|
|
|
|
AddCategoryMapping(60, TorznabCatType.TVSD, "TV-XviD");
|
|
|
|
AddCategoryMapping(38, TorznabCatType.TVSD, "SD-TV");
|
|
|
|
AddCategoryMapping(51, TorznabCatType.TVHD, "TV 1080p/i");
|
|
|
|
AddCategoryMapping(52, TorznabCatType.TVHD, "TV 720p/i");
|
|
|
|
|
|
|
|
AddCategoryMapping(54, TorznabCatType.MoviesSD, "WEBRip");
|
|
|
|
AddCategoryMapping(59, TorznabCatType.MoviesWEBDL, "WEB-DL");
|
|
|
|
AddCategoryMapping(24, TorznabCatType.TVDocumentary, "Dokumentarci");
|
|
|
|
|
|
|
|
// Games
|
|
|
|
AddCategoryMapping(10, TorznabCatType.PCGames, "PC igre/ISO");
|
|
|
|
AddCategoryMapping(11, TorznabCatType.PCGames, "PC igre/Rips/Repack");
|
|
|
|
AddCategoryMapping(64, TorznabCatType.PCGames, "PC igre/Update & Patch");
|
|
|
|
|
|
|
|
// Music
|
|
|
|
AddCategoryMapping(46, TorznabCatType.AudioLossless, "Glasba/Flac");
|
|
|
|
AddCategoryMapping(8, TorznabCatType.AudioOther, "Glasba/Ostalo");
|
|
|
|
AddCategoryMapping(47, TorznabCatType.AudioMP3, "Glasba/Mp3");
|
|
|
|
AddCategoryMapping(8, TorznabCatType.AudioVideo, "Music DVD");
|
|
|
|
AddCategoryMapping(8, TorznabCatType.AudioVideo, "Videospoti");
|
|
|
|
AddCategoryMapping(21, TorznabCatType.AudioAudiobook, "AudioBook");
|
|
|
|
AddCategoryMapping(3, TorznabCatType.BooksEbook, "eKnjige");
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
|
|
|
{
|
|
|
|
LoadValuesFromJson(configJson);
|
|
|
|
|
|
|
|
var pairs = new Dictionary<string, string>
|
|
|
|
{
|
|
|
|
{ "user[username]", configData.Username.Value },
|
|
|
|
{ "user[password]", configData.Password.Value }
|
|
|
|
};
|
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, string.Empty, false, null, null, true);
|
2020-06-09 17:36:57 +00:00
|
|
|
await ConfigureIfOK(result.Cookies, result.ContentString != null && result.ContentString.Contains("/odjava"), () =>
|
2019-12-11 03:34:32 +00:00
|
|
|
{
|
2020-02-29 20:30:07 +00:00
|
|
|
var parser = new HtmlParser();
|
2020-06-09 17:36:57 +00:00
|
|
|
var dom = parser.ParseDocument(result.ContentString);
|
2020-02-29 20:30:07 +00:00
|
|
|
var errorMessage = dom.QuerySelector("div.obvet > span.najvecji").TextContent.Trim(); // Prijava ni uspela! obvestilo
|
2019-12-11 03:34:32 +00:00
|
|
|
throw new ExceptionWithConfigData(errorMessage, configData);
|
|
|
|
});
|
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
|
|
|
{
|
|
|
|
var releases = new List<ReleaseInfo>(); //List of releases initialization
|
|
|
|
var searchString = query.GetQueryString(); //get search string from query
|
|
|
|
|
2020-06-10 21:22:29 +00:00
|
|
|
WebResult results = null;
|
2019-12-11 03:34:32 +00:00
|
|
|
var queryCollection = new NameValueCollection();
|
2020-02-10 22:16:19 +00:00
|
|
|
var catList = MapTorznabCapsToTrackers(query); // map categories from query to indexer specific
|
|
|
|
var categ = string.Join(",", catList);
|
2019-12-11 03:34:32 +00:00
|
|
|
|
|
|
|
//create GET request - search URI
|
|
|
|
queryCollection.Add("offset", "0");
|
|
|
|
queryCollection.Add("keyword", searchString);
|
|
|
|
queryCollection.Add("category", categ.TrimStart(','));
|
|
|
|
queryCollection.Add("option", "");
|
|
|
|
queryCollection.Add("ns", "true");
|
|
|
|
|
|
|
|
//concatenate base search url with query
|
|
|
|
var searchUrl = SearchUrl + "?" + queryCollection.GetQueryString();
|
|
|
|
|
|
|
|
// log search URL
|
2019-12-15 16:49:46 +00:00
|
|
|
logger.Info(string.Format("Searh URL Partis_: {0}", searchUrl));
|
2019-12-11 03:34:32 +00:00
|
|
|
|
|
|
|
// add necessary headers
|
2020-06-11 15:09:27 +00:00
|
|
|
var header = new Dictionary<string, string>
|
2019-12-11 03:34:32 +00:00
|
|
|
{
|
|
|
|
{ "X-requested-with", "XMLHttpRequest" }
|
|
|
|
};
|
|
|
|
|
|
|
|
//get results and follow redirect
|
2020-09-21 16:39:47 +00:00
|
|
|
results = await RequestWithCookiesAsync(searchUrl, referer: SearchUrl, headers: header);
|
2019-12-11 03:34:32 +00:00
|
|
|
await FollowIfRedirect(results, null, null, null, true);
|
|
|
|
|
2020-02-25 16:08:03 +00:00
|
|
|
// are we logged in?
|
2020-06-09 17:36:57 +00:00
|
|
|
if (!results.ContentString.Contains("/odjava"))
|
2019-12-11 03:34:32 +00:00
|
|
|
{
|
|
|
|
await ApplyConfiguration(null);
|
|
|
|
}
|
2019-12-15 16:49:46 +00:00
|
|
|
// another request with specific query - NEEDED for succesful response - return data
|
2020-09-21 16:39:47 +00:00
|
|
|
results = await RequestWithCookiesAsync(
|
2020-06-11 15:09:27 +00:00
|
|
|
SiteLink + "brskaj/?rs=false&offset=0", referer: SearchUrl, headers: header);
|
2019-12-11 03:34:32 +00:00
|
|
|
await FollowIfRedirect(results, null, null, null, true);
|
|
|
|
|
|
|
|
// parse results
|
|
|
|
try
|
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var RowsSelector = "div.list > div[name=\"torrrow\"]";
|
2019-12-11 03:34:32 +00:00
|
|
|
|
|
|
|
var ResultParser = new HtmlParser();
|
2020-06-09 17:36:57 +00:00
|
|
|
var SearchResultDocument = ResultParser.ParseDocument(results.ContentString);
|
2019-12-11 03:34:32 +00:00
|
|
|
var Rows = SearchResultDocument.QuerySelectorAll(RowsSelector);
|
|
|
|
foreach (var Row in Rows)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// initialize REleaseInfo
|
|
|
|
var release = new ReleaseInfo
|
|
|
|
{
|
|
|
|
MinimumRatio = 1,
|
|
|
|
MinimumSeedTime = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
// Get Category
|
|
|
|
var catega = Row.QuerySelector("div.likona div").GetAttribute("alt");
|
|
|
|
release.Category = MapTrackerCatDescToNewznab(catega);
|
|
|
|
|
|
|
|
var qDetailsLink = Row.QuerySelector("div.listeklink a");
|
|
|
|
|
|
|
|
// Title and torrent link
|
|
|
|
release.Title = qDetailsLink.TextContent;
|
|
|
|
release.Comments = new Uri(SiteLink + qDetailsLink.GetAttribute("href").TrimStart('/'));
|
|
|
|
release.Guid = release.Comments;
|
|
|
|
|
|
|
|
// Date of torrent creation
|
|
|
|
var liopis = Row.QuerySelector("div.listeklink div span.middle");
|
2020-02-10 22:16:19 +00:00
|
|
|
var ind = liopis.TextContent.IndexOf("Naloženo:");
|
|
|
|
var reldate = liopis.TextContent.Substring(ind + 10, 22);
|
2019-12-11 03:34:32 +00:00
|
|
|
release.PublishDate = DateTime.ParseExact(reldate, "dd.MM.yyyy ob HH:mm:ss", CultureInfo.InvariantCulture);
|
|
|
|
|
|
|
|
// Is freeleech?
|
|
|
|
var checkIfFree = (Row.QuerySelector("div.listeklink div.liopisl img[title=\"freeleech\"]") != null) ? true : false;
|
|
|
|
|
|
|
|
// Download link
|
|
|
|
var qDownloadLink = Row.QuerySelector("div.data3t a").GetAttribute("href");
|
|
|
|
release.Link = new Uri(SiteLink + qDownloadLink.TrimStart('/'));
|
|
|
|
|
|
|
|
// Various data - size, seeders, leechers, download count
|
|
|
|
var sel = Row.QuerySelectorAll("div.datat");
|
|
|
|
var size = sel[0].TextContent;
|
|
|
|
release.Size = ReleaseInfo.GetBytes(size);
|
|
|
|
|
|
|
|
release.Seeders = ParseUtil.CoerceInt(sel[1].TextContent);
|
|
|
|
release.Peers = ParseUtil.CoerceInt(sel[2].TextContent) + release.Seeders;
|
|
|
|
release.Grabs = ParseUtil.CoerceLong(sel[3].TextContent);
|
|
|
|
|
|
|
|
// Set download/upload factor
|
|
|
|
release.DownloadVolumeFactor = checkIfFree ? 0 : 1;
|
|
|
|
release.UploadVolumeFactor = 1;
|
|
|
|
|
|
|
|
// Add current release to List
|
|
|
|
releases.Add(release);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2020-05-11 19:59:28 +00:00
|
|
|
logger.Error(string.Format("{0}: Error while parsing row '{1}':\n\n{2}", Id, Row.OuterHtml, ex));
|
2019-12-11 03:34:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2020-06-09 17:36:57 +00:00
|
|
|
OnParseError(results.ContentString, ex);
|
2019-12-11 03:34:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|