2020-02-09 02:35:16 +00:00
|
|
|
using System;
|
2017-04-15 08:45:10 +00:00
|
|
|
using System.Collections.Generic;
|
2017-10-29 06:50:47 +00:00
|
|
|
using System.Collections.Specialized;
|
|
|
|
using System.Globalization;
|
2019-01-15 12:44:35 +00:00
|
|
|
using System.Linq;
|
2017-04-15 08:45:10 +00:00
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
2018-03-10 08:05:56 +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;
|
2017-04-15 08:45:10 +00:00
|
|
|
using Newtonsoft.Json;
|
2017-10-29 06:50:47 +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
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2017-07-10 20:58:44 +00:00
|
|
|
public class Superbits : BaseWebIndexer
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
private string SearchUrl => SiteLink + "api/v1/torrents";
|
|
|
|
private string LoginUrl => SiteLink + "api/v1/auth";
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2019-01-15 12:44:35 +00:00
|
|
|
private new ConfigurationDataCookie configData
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
get => (ConfigurationDataCookie)base.configData;
|
|
|
|
set => base.configData = value;
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 09:42:03 +00:00
|
|
|
public Superbits(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)
|
2017-04-15 08:45:10 +00:00
|
|
|
: base(name: "Superbits",
|
2017-10-01 09:26:07 +00:00
|
|
|
description: "SuperBits is a SWEDISH Private Torrent Tracker for MOVIES / TV / GENERAL",
|
2017-04-15 08:45:10 +00:00
|
|
|
link: "https://superbits.org/",
|
|
|
|
caps: new TorznabCapabilities(),
|
2017-07-10 20:58:44 +00:00
|
|
|
configService: configService,
|
2017-04-15 08:45:10 +00:00
|
|
|
client: w,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
2019-01-18 10:17:00 +00:00
|
|
|
configData: new ConfigurationDataCookie())
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2017-11-05 09:42:03 +00:00
|
|
|
Encoding = Encoding.UTF8;
|
2017-04-15 08:45:10 +00:00
|
|
|
Language = "sv-sw";
|
|
|
|
Type = "private";
|
|
|
|
|
2019-05-11 03:27:25 +00:00
|
|
|
TorznabCaps.SupportsImdbMovieSearch = true;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
|
|
|
AddCategoryMapping(1, TorznabCatType.MoviesDVD, "DVD-R Swesub");
|
|
|
|
AddCategoryMapping(2, TorznabCatType.TV, "DVD-R TV");
|
|
|
|
AddCategoryMapping(3, TorznabCatType.BooksEbook, "eBok");
|
|
|
|
AddCategoryMapping(4, TorznabCatType.MoviesHD, "Film 1080");
|
|
|
|
AddCategoryMapping(5, TorznabCatType.Movies3D, "Film 3D");
|
|
|
|
AddCategoryMapping(6, TorznabCatType.MoviesHD, "Film 720");
|
|
|
|
AddCategoryMapping(7, TorznabCatType.MoviesBluRay, "Film Bluray");
|
|
|
|
AddCategoryMapping(8, TorznabCatType.TV, "Svensk TV");
|
|
|
|
AddCategoryMapping(9, TorznabCatType.AudioAudiobook, "Ljudböcker");
|
|
|
|
AddCategoryMapping(10, TorznabCatType.AudioVideo, "Musikvideos");
|
|
|
|
AddCategoryMapping(11, TorznabCatType.BooksMagazines, "E-tidningar");
|
|
|
|
AddCategoryMapping(12, TorznabCatType.Audio, "Musik");
|
|
|
|
AddCategoryMapping(13, TorznabCatType.Other, "Omslag");
|
|
|
|
AddCategoryMapping(14, TorznabCatType.Other, "Övrigt");
|
|
|
|
AddCategoryMapping(15, TorznabCatType.PCGames, "PC-Spel");
|
|
|
|
AddCategoryMapping(16, TorznabCatType.PC0day, "Program");
|
|
|
|
AddCategoryMapping(17, TorznabCatType.ConsolePS3, "PS3");
|
|
|
|
AddCategoryMapping(18, TorznabCatType.TV, "TV");
|
|
|
|
AddCategoryMapping(19, TorznabCatType.ConsoleWii, "Wii");
|
|
|
|
AddCategoryMapping(20, TorznabCatType.ConsoleXbox, "Xbox");
|
|
|
|
AddCategoryMapping(21, TorznabCatType.MoviesOther, "Xvid");
|
|
|
|
AddCategoryMapping(22, TorznabCatType.XXX, "XXX");
|
2018-01-24 22:38:00 +00:00
|
|
|
AddCategoryMapping(24, TorznabCatType.MoviesUHD, "Film 4K");
|
2018-02-07 04:49:43 +00:00
|
|
|
AddCategoryMapping(26, TorznabCatType.TV, "TV DK");
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
|
|
|
|
2017-06-28 05:31:38 +00:00
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
|
|
|
LoadValuesFromJson(configJson);
|
|
|
|
|
2019-01-15 12:44:35 +00:00
|
|
|
// TODO: implement captcha
|
|
|
|
CookieHeader = configData.Cookie.Value;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var results = await PerformQuery(new TorznabQuery());
|
|
|
|
if (results.Count() == 0)
|
|
|
|
{
|
|
|
|
throw new Exception("Your cookie did not work");
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2019-01-15 12:44:35 +00:00
|
|
|
IsConfigured = true;
|
|
|
|
SaveConfig();
|
|
|
|
return IndexerConfigurationStatus.Completed;
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2019-01-15 12:44:35 +00:00
|
|
|
IsConfigured = false;
|
|
|
|
throw new Exception("Your cookie did not work: " + e.Message);
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 05:15:47 +00:00
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
// And this was option one from
|
|
|
|
// https://github.com/Jackett/Jackett/pull/7166#discussion_r376817517
|
2020-02-10 22:16:19 +00:00
|
|
|
var releases = new List<ReleaseInfo>();
|
2017-04-15 08:45:10 +00:00
|
|
|
var queryCollection = new NameValueCollection();
|
|
|
|
var searchString = query.GetQueryString();
|
|
|
|
var searchUrl = SearchUrl;
|
|
|
|
|
|
|
|
queryCollection.Add("extendedSearch", "false");
|
|
|
|
queryCollection.Add("freeleech", "false");
|
|
|
|
queryCollection.Add("index", "0");
|
|
|
|
queryCollection.Add("limit", "100");
|
|
|
|
queryCollection.Add("order", "desc");
|
|
|
|
queryCollection.Add("page", "search");
|
|
|
|
if (query.ImdbID != null)
|
|
|
|
queryCollection.Add("searchText", query.ImdbID);
|
|
|
|
else
|
|
|
|
queryCollection.Add("searchText", searchString);
|
|
|
|
queryCollection.Add("sort", "d");
|
|
|
|
queryCollection.Add("section", "all");
|
|
|
|
queryCollection.Add("stereoscopic", "false");
|
|
|
|
queryCollection.Add("sweaudio", "false");
|
|
|
|
queryCollection.Add("swesub", "false");
|
|
|
|
queryCollection.Add("watchview", "false");
|
|
|
|
|
|
|
|
searchUrl += "?" + queryCollection.GetQueryString();
|
2017-05-16 05:34:34 +00:00
|
|
|
foreach (var cat in MapTorznabCapsToTrackers(query))
|
|
|
|
searchUrl += "&categories[]=" + cat;
|
2017-04-15 08:45:10 +00:00
|
|
|
var results = await RequestStringWithCookies(searchUrl, null, SiteLink);
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
//var json = JArray.Parse(results.Content);
|
|
|
|
dynamic json = JsonConvert.DeserializeObject<dynamic>(results.Content);
|
2018-01-13 15:21:02 +00:00
|
|
|
foreach (var row in json ?? System.Linq.Enumerable.Empty<dynamic>())
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
|
|
|
var release = new ReleaseInfo();
|
|
|
|
var descriptions = new List<string>();
|
|
|
|
var tags = new List<string>();
|
|
|
|
|
|
|
|
release.MinimumRatio = 1.1;
|
2020-01-11 18:07:19 +00:00
|
|
|
release.MinimumSeedTime = 172800; // 48 hours
|
2017-04-15 08:45:10 +00:00
|
|
|
release.Title = row.name;
|
|
|
|
release.Category = MapTrackerCatToNewznab(row.category.ToString());
|
|
|
|
release.Size = row.size;
|
|
|
|
release.Seeders = row.seeders;
|
|
|
|
release.Peers = row.leechers + release.Seeders;
|
|
|
|
release.PublishDate = DateTime.ParseExact(row.added.ToString() + " +01:00", "yyyy-MM-dd HH:mm:ss zzz", CultureInfo.InvariantCulture);
|
|
|
|
release.Files = row.numfiles;
|
|
|
|
release.Grabs = row.times_completed;
|
|
|
|
|
|
|
|
release.Comments = new Uri(SiteLink + "torrent/" + row.id.ToString() + "/");
|
2018-01-05 17:08:05 +00:00
|
|
|
release.Guid = release.Comments;
|
2017-04-15 08:45:10 +00:00
|
|
|
release.Link = new Uri(SiteLink + "api/v1/torrents/download/" + row.id.ToString());
|
|
|
|
|
|
|
|
if (row.frileech == 1)
|
|
|
|
release.DownloadVolumeFactor = 0;
|
|
|
|
else
|
|
|
|
release.DownloadVolumeFactor = 1;
|
|
|
|
release.UploadVolumeFactor = 1;
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(row.customcover.ToString()))
|
|
|
|
release.BannerUrl = new Uri(SiteLink + row.customcover);
|
|
|
|
|
|
|
|
if (row.imdbid2 != null && row.imdbid2.ToString().StartsWith("tt"))
|
2017-10-29 06:50:47 +00:00
|
|
|
{
|
2017-04-15 08:45:10 +00:00
|
|
|
release.Imdb = ParseUtil.CoerceLong(row.imdbid2.ToString().Substring(2));
|
|
|
|
descriptions.Add("Title: " + row.title);
|
|
|
|
descriptions.Add("Year: " + row.year);
|
|
|
|
descriptions.Add("Genres: " + row.genres);
|
|
|
|
descriptions.Add("Tagline: " + row.tagline);
|
|
|
|
descriptions.Add("Cast: " + row.cast);
|
|
|
|
descriptions.Add("Rating: " + row.rating);
|
|
|
|
descriptions.Add("Plot: " + row.plot);
|
|
|
|
|
|
|
|
release.BannerUrl = new Uri(SiteLink + "img/imdb/" + row.imdbid2 + ".jpg");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((int)row.p2p == 1)
|
|
|
|
tags.Add("P2P");
|
|
|
|
if ((int)row.pack == 1)
|
|
|
|
tags.Add("Pack");
|
|
|
|
if ((int)row.reqid != 0)
|
|
|
|
tags.Add("Request");
|
|
|
|
if ((int)row.sweaudio != 0)
|
|
|
|
tags.Add("Swedish audio");
|
|
|
|
if ((int)row.swesub != 0)
|
|
|
|
tags.Add("Swedish subtitles");
|
|
|
|
|
|
|
|
if (tags.Count > 0)
|
|
|
|
descriptions.Add("Tags: " + string.Join(", ", tags));
|
|
|
|
|
|
|
|
var preDate = row.preDate.ToString();
|
|
|
|
if (!string.IsNullOrWhiteSpace(preDate) && preDate != "1970-01-01 01:00:00")
|
|
|
|
descriptions.Add("PRE: " + preDate);
|
|
|
|
|
|
|
|
descriptions.Add("Section: " + row.section);
|
|
|
|
|
|
|
|
release.Description = string.Join("<br>\n", descriptions);
|
|
|
|
|
|
|
|
releases.Add(release);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
OnParseError(results.Content, ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
}
|
2017-10-01 09:26:07 +00:00
|
|
|
}
|