2020-02-09 02:35:16 +00:00
|
|
|
using System;
|
2017-10-29 06:50:47 +00:00
|
|
|
using System.Collections.Generic;
|
2018-06-07 16:33:44 +00:00
|
|
|
using System.Collections.Specialized;
|
2020-05-03 23:35:52 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2017-10-29 06:50:47 +00:00
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Threading.Tasks;
|
2020-02-29 23:07:41 +00:00
|
|
|
using AngleSharp.Html.Parser;
|
2018-03-10 08:05:56 +00:00
|
|
|
using Jackett.Common.Models;
|
2019-03-29 03:32:35 +00:00
|
|
|
using Jackett.Common.Models.IndexerConfig.Bespoke;
|
2018-03-10 08:05:56 +00:00
|
|
|
using Jackett.Common.Services.Interfaces;
|
|
|
|
using Jackett.Common.Utils;
|
|
|
|
using Jackett.Common.Utils.Clients;
|
2015-07-12 21:43:00 +00:00
|
|
|
using Newtonsoft.Json.Linq;
|
2015-07-19 00:27:41 +00:00
|
|
|
using NLog;
|
2015-07-12 21:43:00 +00:00
|
|
|
|
2018-03-10 08:05:56 +00:00
|
|
|
namespace Jackett.Common.Indexers
|
2015-07-12 21:43:00 +00:00
|
|
|
{
|
2020-05-03 23:35:52 +00:00
|
|
|
[ExcludeFromCodeCoverage]
|
2017-07-10 20:58:44 +00:00
|
|
|
public class SceneTime : BaseWebIndexer
|
2015-07-12 21:43:00 +00:00
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
private string SearchUrl => SiteLink + "browse.php";
|
|
|
|
private string DownloadUrl => SiteLink + "download.php/{0}/download.torrent";
|
2015-07-12 21:43:00 +00:00
|
|
|
|
2020-04-26 19:24:05 +00:00
|
|
|
private new ConfigurationDataSceneTime configData => (ConfigurationDataSceneTime)base.configData;
|
2015-08-03 21:38:45 +00:00
|
|
|
|
2020-12-11 22:14:21 +00:00
|
|
|
public SceneTime(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps,
|
|
|
|
ICacheService cs)
|
2020-05-11 19:59:28 +00:00
|
|
|
: base(id: "scenetime",
|
|
|
|
name: "SceneTime",
|
2020-04-26 19:24:05 +00:00
|
|
|
description: "Always on time",
|
|
|
|
link: "https://www.scenetime.com/",
|
2020-10-20 00:38:27 +00:00
|
|
|
caps: new TorznabCapabilities
|
|
|
|
{
|
2020-10-18 20:47:36 +00:00
|
|
|
TvSearchParams = new List<TvSearchParam>
|
|
|
|
{
|
|
|
|
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep
|
|
|
|
},
|
|
|
|
MovieSearchParams = new List<MovieSearchParam>
|
|
|
|
{
|
|
|
|
MovieSearchParam.Q
|
2020-10-20 00:38:27 +00:00
|
|
|
},
|
|
|
|
MusicSearchParams = new List<MusicSearchParam>
|
|
|
|
{
|
|
|
|
MusicSearchParam.Q
|
|
|
|
},
|
|
|
|
BookSearchParams = new List<BookSearchParam>
|
|
|
|
{
|
|
|
|
BookSearchParam.Q
|
2020-10-18 20:47:36 +00:00
|
|
|
}
|
2020-10-18 17:26:22 +00:00
|
|
|
},
|
2020-04-26 19:24:05 +00:00
|
|
|
configService: configService,
|
|
|
|
client: w,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
2020-12-11 22:14:21 +00:00
|
|
|
cacheService: cs,
|
2020-04-26 19:24:05 +00:00
|
|
|
configData: new ConfigurationDataSceneTime())
|
2015-07-12 21:43:00 +00:00
|
|
|
{
|
2016-12-06 13:56:47 +00:00
|
|
|
Encoding = Encoding.GetEncoding("iso-8859-1");
|
2021-09-08 01:02:29 +00:00
|
|
|
Language = "en-US";
|
2017-01-27 15:57:32 +00:00
|
|
|
Type = "private";
|
2016-12-06 13:56:47 +00:00
|
|
|
|
2020-10-15 04:20:26 +00:00
|
|
|
AddCategoryMapping(10, TorznabCatType.XXX, "Movies Adult");
|
|
|
|
AddCategoryMapping(47, TorznabCatType.Movies, "Movie Packs");
|
|
|
|
AddCategoryMapping(57, TorznabCatType.MoviesSD, "Movies SD");
|
|
|
|
AddCategoryMapping(59, TorznabCatType.MoviesHD, "Movies HD");
|
|
|
|
AddCategoryMapping(64, TorznabCatType.Movies3D, "Movies 3D");
|
|
|
|
AddCategoryMapping(82, TorznabCatType.MoviesOther, "Movies CAM-TS");
|
|
|
|
AddCategoryMapping(16, TorznabCatType.MoviesUHD, "Movies UHD");
|
|
|
|
AddCategoryMapping(2, TorznabCatType.TVUHD, "TV UHD");
|
|
|
|
AddCategoryMapping(43, TorznabCatType.TV, "TV Packs");
|
|
|
|
AddCategoryMapping(9, TorznabCatType.TVHD, "TV HD");
|
|
|
|
AddCategoryMapping(77, TorznabCatType.TVSD, "TV SD");
|
|
|
|
AddCategoryMapping(6, TorznabCatType.PCGames, "Games PC ISO");
|
2020-10-28 19:00:48 +00:00
|
|
|
AddCategoryMapping(48, TorznabCatType.ConsoleXBox, "Games XBOX");
|
2020-10-15 04:20:26 +00:00
|
|
|
AddCategoryMapping(51, TorznabCatType.ConsoleWii, "Games Wii");
|
|
|
|
AddCategoryMapping(55, TorznabCatType.ConsoleNDS, "Games Nintendo DS");
|
|
|
|
AddCategoryMapping(12, TorznabCatType.ConsolePS4, "Games/PS");
|
|
|
|
AddCategoryMapping(15, TorznabCatType.ConsoleOther, "Games Dreamcast");
|
|
|
|
AddCategoryMapping(52, TorznabCatType.PCMac, "Mac/Linux");
|
|
|
|
AddCategoryMapping(53, TorznabCatType.PC0day, "Apps");
|
2020-10-28 19:00:48 +00:00
|
|
|
AddCategoryMapping(24, TorznabCatType.PCMobileOther, "Mobile Apps");
|
2020-10-15 04:20:26 +00:00
|
|
|
AddCategoryMapping(7, TorznabCatType.Books, "Books and Magazines");
|
|
|
|
AddCategoryMapping(65, TorznabCatType.BooksComics, "Books Comic");
|
|
|
|
AddCategoryMapping(4, TorznabCatType.Audio, "Music");
|
|
|
|
AddCategoryMapping(116, TorznabCatType.Audio, "Music Pack");
|
2015-07-12 21:43:00 +00:00
|
|
|
}
|
|
|
|
|
2017-06-28 05:31:38 +00:00
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2015-07-12 21:43:00 +00:00
|
|
|
{
|
2017-01-02 20:39:28 +00:00
|
|
|
LoadValuesFromJson(configJson);
|
2015-07-12 21:43:00 +00:00
|
|
|
|
2020-11-05 02:19:09 +00:00
|
|
|
CookieHeader = configData.Cookie.Value;
|
|
|
|
try
|
2016-09-29 19:09:20 +00:00
|
|
|
{
|
2020-11-05 02:19:09 +00:00
|
|
|
var results = await PerformQuery(new TorznabQuery());
|
|
|
|
if (!results.Any())
|
|
|
|
throw new Exception("Found 0 results in the tracker");
|
2016-09-29 19:09:20 +00:00
|
|
|
|
2020-11-05 02:19:09 +00:00
|
|
|
IsConfigured = true;
|
|
|
|
SaveConfig();
|
|
|
|
return IndexerConfigurationStatus.Completed;
|
2016-09-29 19:09:20 +00:00
|
|
|
}
|
2020-11-05 02:19:09 +00:00
|
|
|
catch (Exception e)
|
2015-07-12 21:43:00 +00:00
|
|
|
{
|
2020-11-05 02:19:09 +00:00
|
|
|
IsConfigured = false;
|
|
|
|
throw new Exception("Your cookie did not work: " + e.Message);
|
|
|
|
}
|
2015-07-12 21:43:00 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 05:15:47 +00:00
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2015-07-12 21:43:00 +00:00
|
|
|
{
|
2020-03-03 20:16:11 +00:00
|
|
|
var qParams = new NameValueCollection
|
|
|
|
{
|
|
|
|
{"cata", "yes"},
|
|
|
|
{"sec", "jax"}
|
|
|
|
};
|
2017-10-29 06:50:47 +00:00
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
var catList = MapTorznabCapsToTrackers(query);
|
|
|
|
foreach (var cat in catList)
|
2016-02-13 05:55:23 +00:00
|
|
|
qParams.Add("c" + cat, "1");
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(query.SanitizedSearchTerm))
|
|
|
|
qParams.Add("search", query.GetQueryString());
|
|
|
|
|
2019-03-29 03:32:35 +00:00
|
|
|
// If Only Freeleech Enabled
|
|
|
|
if (configData.Freeleech.Value)
|
|
|
|
qParams.Add("freeleech", "on");
|
2020-03-03 20:16:11 +00:00
|
|
|
|
2018-06-07 16:33:44 +00:00
|
|
|
var searchUrl = SearchUrl + "?" + qParams.GetQueryString();
|
2020-09-21 16:39:47 +00:00
|
|
|
var results = await RequestWithCookiesAsync(searchUrl);
|
2020-05-09 13:41:35 +00:00
|
|
|
|
|
|
|
// response without results (the message is misleading)
|
2020-06-09 17:36:57 +00:00
|
|
|
if (results.ContentString?.Contains("slow down geek!!!") == true)
|
2020-05-09 13:41:35 +00:00
|
|
|
return new List<ReleaseInfo>();
|
|
|
|
|
|
|
|
// not logged in
|
2020-06-09 17:36:57 +00:00
|
|
|
if (results.ContentString == null || !results.ContentString.Contains("/logout.php"))
|
2020-04-26 19:24:05 +00:00
|
|
|
throw new Exception("The user is not logged in. It is possible that the cookie has expired or you " +
|
|
|
|
"made a mistake when copying it. Please check the settings.");
|
|
|
|
|
2020-06-09 17:36:57 +00:00
|
|
|
return ParseResponse(query, results.ContentString);
|
2015-07-12 21:43:00 +00:00
|
|
|
}
|
|
|
|
|
2020-03-03 20:16:11 +00:00
|
|
|
private List<ReleaseInfo> ParseResponse(TorznabQuery query, string htmlResponse)
|
2015-07-12 21:43:00 +00:00
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var releases = new List<ReleaseInfo>();
|
2015-07-12 21:43:00 +00:00
|
|
|
|
2015-07-18 20:35:02 +00:00
|
|
|
try
|
|
|
|
{
|
2020-02-29 23:07:41 +00:00
|
|
|
var parser = new HtmlParser();
|
|
|
|
var dom = parser.ParseDocument(htmlResponse);
|
2016-02-13 05:55:23 +00:00
|
|
|
|
2020-03-03 20:16:11 +00:00
|
|
|
var table = dom.QuerySelector("table.movehere");
|
|
|
|
if (table == null)
|
|
|
|
return releases; // no results
|
|
|
|
|
|
|
|
var headerColumns = table.QuerySelectorAll("tbody > tr > td.cat_Head")
|
|
|
|
.Select(x => x.TextContent).ToList();
|
2020-02-10 22:16:19 +00:00
|
|
|
var categoryIndex = headerColumns.FindIndex(x => x.Equals("Type"));
|
|
|
|
var nameIndex = headerColumns.FindIndex(x => x.Equals("Name"));
|
|
|
|
var sizeIndex = headerColumns.FindIndex(x => x.Equals("Size"));
|
|
|
|
var seedersIndex = headerColumns.FindIndex(x => x.Equals("Seeders"));
|
|
|
|
var leechersIndex = headerColumns.FindIndex(x => x.Equals("Leechers"));
|
2016-02-13 05:55:23 +00:00
|
|
|
|
2020-02-29 23:07:41 +00:00
|
|
|
var rows = dom.QuerySelectorAll("tr.browse");
|
2015-07-18 20:35:02 +00:00
|
|
|
foreach (var row in rows)
|
2015-07-12 21:43:00 +00:00
|
|
|
{
|
2020-03-26 22:15:28 +00:00
|
|
|
// TODO convert to initializer
|
2015-07-18 20:35:02 +00:00
|
|
|
var release = new ReleaseInfo();
|
2020-12-07 04:22:39 +00:00
|
|
|
release.MinimumRatio = 1;
|
2020-10-15 04:20:26 +00:00
|
|
|
release.MinimumSeedTime = 259200; // 72 hours
|
2015-07-18 20:35:02 +00:00
|
|
|
|
2021-03-21 20:08:39 +00:00
|
|
|
var catId = "82"; // default
|
2020-02-29 23:07:41 +00:00
|
|
|
var qCatLink = row.Children[categoryIndex].QuerySelector("a");
|
|
|
|
if (qCatLink != null)
|
2017-10-29 06:50:47 +00:00
|
|
|
{
|
2021-03-21 20:08:39 +00:00
|
|
|
catId = new Regex(@"\?cat=(\d*)").Match(qCatLink.GetAttribute("href")).Groups[1].ToString().Trim();
|
2017-09-01 15:46:24 +00:00
|
|
|
}
|
2021-03-21 20:08:39 +00:00
|
|
|
release.Category = MapTrackerCatToNewznab(catId);
|
2016-02-13 05:55:23 +00:00
|
|
|
|
2020-02-29 23:07:41 +00:00
|
|
|
var qDescCol = row.Children[nameIndex];
|
|
|
|
var qLink = qDescCol.QuerySelector("a");
|
|
|
|
release.Title = qLink.TextContent;
|
2017-04-15 08:45:10 +00:00
|
|
|
if (!query.MatchQueryStringAND(release.Title))
|
2016-10-25 06:46:06 +00:00
|
|
|
continue;
|
|
|
|
|
2020-11-08 02:11:27 +00:00
|
|
|
release.Details = new Uri(SiteLink + "/" + qLink.GetAttribute("href"));
|
|
|
|
release.Guid = release.Details;
|
2020-03-03 20:16:11 +00:00
|
|
|
|
2020-02-29 23:07:41 +00:00
|
|
|
var torrentId = qLink.GetAttribute("href").Split('=')[1];
|
2015-07-18 20:35:02 +00:00
|
|
|
release.Link = new Uri(string.Format(DownloadUrl, torrentId));
|
|
|
|
|
2020-02-29 23:07:41 +00:00
|
|
|
release.PublishDate = DateTimeUtil.FromTimeAgo(qDescCol.ChildNodes.Last().TextContent);
|
2015-07-18 20:35:02 +00:00
|
|
|
|
2020-02-29 23:07:41 +00:00
|
|
|
var sizeStr = row.Children[sizeIndex].TextContent;
|
2015-07-26 03:53:53 +00:00
|
|
|
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
2015-07-18 20:35:02 +00:00
|
|
|
|
2020-02-29 23:07:41 +00:00
|
|
|
release.Seeders = ParseUtil.CoerceInt(row.Children[seedersIndex].TextContent.Trim());
|
|
|
|
release.Peers = ParseUtil.CoerceInt(row.Children[leechersIndex].TextContent.Trim()) + release.Seeders;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-02-29 23:07:41 +00:00
|
|
|
release.DownloadVolumeFactor = row.QuerySelector("font > b:contains(Freeleech)") != null ? 0 : 1;
|
2016-10-27 07:35:31 +00:00
|
|
|
release.UploadVolumeFactor = 1;
|
|
|
|
|
2015-07-18 20:35:02 +00:00
|
|
|
releases.Add(release);
|
2015-07-12 21:43:00 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-18 20:35:02 +00:00
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2016-02-13 05:55:23 +00:00
|
|
|
OnParseError(htmlResponse, ex);
|
2015-07-18 20:35:02 +00:00
|
|
|
}
|
2016-02-13 05:55:23 +00:00
|
|
|
|
2015-07-28 23:10:04 +00:00
|
|
|
return releases;
|
2015-07-12 21:43:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|