Jackett/src/Jackett.Common/Indexers/BeyondHD.cs

182 lines
8.6 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using CsQuery;
using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
2015-07-13 02:01:02 +00:00
using Newtonsoft.Json.Linq;
2015-07-19 00:27:41 +00:00
using NLog;
2015-07-13 02:01:02 +00:00
namespace Jackett.Common.Indexers
2015-07-13 02:01:02 +00:00
{
public class BeyondHD : BaseWebIndexer
2015-07-13 02:01:02 +00:00
{
2015-08-11 01:59:11 +00:00
private string SearchUrl { get { return SiteLink + "browse.php?searchin=title&incldead=0&"; } }
2015-07-13 02:01:02 +00:00
private new ConfigurationDataLoginLink configData
{
2016-11-30 17:33:09 +00:00
get { return (ConfigurationDataLoginLink)base.configData; }
set { base.configData = value; }
}
public BeyondHD(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)
: base(name: "BeyondHD",
description: "Without BeyondHD, your HDTV is just a TV",
link: "https://beyond-hd.me/",
2015-08-23 00:02:41 +00:00
caps: new TorznabCapabilities(),
configService: configService,
client: w,
logger: l,
2015-08-07 19:09:13 +00:00
p: ps,
2016-11-30 17:33:09 +00:00
configData: new ConfigurationDataLoginLink())
2015-07-13 02:01:02 +00:00
{
Encoding = Encoding.UTF8;
2016-12-09 17:20:58 +00:00
Language = "en-us";
Type = "private";
2016-11-30 17:33:09 +00:00
configData.DisplayText.Value = "Go to the general tab of your BeyondHD user profile and create/copy the Login Link.";
AddCategoryMapping(37, TorznabCatType.MoviesBluRay, "Movie / Blu-ray");
AddCategoryMapping(71, TorznabCatType.Movies3D, "Movie / 3D");
AddCategoryMapping(83, TorznabCatType.Movies3D, "FraMeSToR 3D");
AddCategoryMapping(77, TorznabCatType.MoviesHD, "Movie / 1080p/i");
AddCategoryMapping(102, TorznabCatType.MoviesUHD, "Movie / 4K Disk");
AddCategoryMapping(94, TorznabCatType.MoviesUHD, "Movie / 4K Other");
AddCategoryMapping(103, TorznabCatType.MoviesUHD, "Movie / 4K Remux");
AddCategoryMapping(78, TorznabCatType.MoviesHD, "Movie / 720p");
AddCategoryMapping(54, TorznabCatType.MoviesHD, "Movie / MP4");
AddCategoryMapping(17, TorznabCatType.MoviesHD, "Movie / Remux");
AddCategoryMapping(38, TorznabCatType.MoviesHD, "Movie / WEB-DL");
AddCategoryMapping(106, TorznabCatType.MoviesHD, "Internal / BHDStudio 1080p");
AddCategoryMapping(105, TorznabCatType.MoviesHD, "Internal / BHDStudio 720p");
AddCategoryMapping(50, TorznabCatType.MoviesHD, "Internal / FraMeSToR 1080p");
AddCategoryMapping(75, TorznabCatType.MoviesHD, "Internal / FraMeSToR 720p");
AddCategoryMapping(49, TorznabCatType.MoviesHD, "Internal / FraMeSToR REMUX");
AddCategoryMapping(101, TorznabCatType.MoviesHD, "Internal / FraMeSToR 4K REMUX");
AddCategoryMapping(61, TorznabCatType.MoviesHD, "Internal / HDX REMUX");
AddCategoryMapping(86, TorznabCatType.MoviesHD, "Internal / SC4R");
AddCategoryMapping(95, TorznabCatType.MoviesHD, "Nightripper 1080p");
AddCategoryMapping(96, TorznabCatType.MoviesHD, "Nightripper 720p");
AddCategoryMapping(98, TorznabCatType.MoviesHD, "Nightripper MicroHD");
AddCategoryMapping(104, TorznabCatType.TVUHD, "TV Show / 4K");
AddCategoryMapping(40, TorznabCatType.TVHD, "TV Show / Blu-ray");
AddCategoryMapping(44, TorznabCatType.TVHD, "TV Show / Encodes");
AddCategoryMapping(48, TorznabCatType.TVHD, "TV Show / HDTV");
AddCategoryMapping(89, TorznabCatType.TVHD, "TV Show / Packs");
AddCategoryMapping(46, TorznabCatType.TVHD, "TV Show / Remux");
AddCategoryMapping(99, TorznabCatType.TVHD, "TV Show / Sports");
AddCategoryMapping(100, TorznabCatType.TVHD, "TV Show / Sports / WEB-DL");
AddCategoryMapping(45, TorznabCatType.TVHD, "TV Show / WEB-DL");
AddCategoryMapping(97, TorznabCatType.TVHD, "Nightripper TV Show Encodes");
AddCategoryMapping(36, TorznabCatType.AudioLossless, "Music / Lossless");
AddCategoryMapping(69, TorznabCatType.AudioMP3, "Music / MP3");
AddCategoryMapping(55, TorznabCatType.AudioVideo, "Music / 1080p/i");
AddCategoryMapping(56, TorznabCatType.AudioVideo, "Music / 720p");
AddCategoryMapping(42, TorznabCatType.AudioVideo, "Music / Blu-ray");
2015-07-13 02:01:02 +00:00
}
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
2015-07-13 02:01:02 +00:00
{
LoadValuesFromJson(configJson);
2016-11-30 17:33:09 +00:00
var result = await RequestStringWithCookies(configData.LoginLink.Value);
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("Welcome Back"), () =>
2015-07-13 02:01:02 +00:00
{
var errorMessage = result.Content;
throw new ExceptionWithConfigData(errorMessage, configData);
});
return IndexerConfigurationStatus.RequiresTesting;
2015-07-13 02:01:02 +00:00
}
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
2015-07-13 02:01:02 +00:00
{
List<ReleaseInfo> releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
2015-08-11 01:59:11 +00:00
var searchUrl = SearchUrl;
var queryCollection = new NameValueCollection();
if (!string.IsNullOrWhiteSpace(searchString))
{
Regex ReplaceRegex = new Regex("[^a-zA-Z0-9]+");
searchString = "%" + ReplaceRegex.Replace(searchString, "%") + "%";
searchString = Regex.Replace(searchString, @"(%\d{3,4})[ip](%)", "$1$2"); // remove i/p from resolution tags (see #835)
queryCollection.Add("search", searchString);
2015-08-11 01:59:11 +00:00
}
foreach (var cat in MapTorznabCapsToTrackers(query))
{
queryCollection.Add("c" + cat, "1");
}
searchUrl += queryCollection.GetQueryString();
var results = await RequestStringWithCookiesAndRetry(searchUrl);
2015-07-28 19:22:23 +00:00
await FollowIfRedirect(results);
try
{
CQ dom = results.Content;
var rows = dom["table.torrenttable > tbody > tr.browse_color"];
foreach (var row in rows)
2015-07-13 02:01:02 +00:00
{
var release = new ReleaseInfo();
release.MinimumRatio = 1;
release.MinimumSeedTime = 172800;
var qRow = row.Cq();
var catStr = row.ChildElements.ElementAt(0).FirstElementChild.GetAttribute("href").Split('=')[1];
release.Category = MapTrackerCatToNewznab(catStr);
2015-08-11 01:59:11 +00:00
var qLink = row.ChildElements.ElementAt(2).FirstChild.Cq();
2015-07-19 17:18:54 +00:00
release.Link = new Uri(SiteLink + "/" + qLink.Attr("href"));
var torrentId = qLink.Attr("href").Split('=').Last();
var descCol = row.ChildElements.ElementAt(3);
var qCommentLink = descCol.FirstChild.Cq();
release.Title = qCommentLink.Text();
2015-07-19 17:18:54 +00:00
release.Comments = new Uri(SiteLink + "/" + qCommentLink.Attr("href"));
release.Guid = release.Comments;
release.Link = new Uri($"{SiteLink}download.php?torrent={torrentId}");
var dateStr = descCol.ChildElements.Last().Cq().Text().Split('|').Last().ToLowerInvariant().Replace("ago.", "").Trim();
release.PublishDate = DateTimeUtil.FromTimeAgo(dateStr);
var sizeStr = row.ChildElements.ElementAt(7).Cq().Text();
release.Size = ReleaseInfo.GetBytes(sizeStr);
release.Seeders = ParseUtil.CoerceInt(row.ChildElements.ElementAt(9).Cq().Text());
release.Peers = ParseUtil.CoerceInt(row.ChildElements.ElementAt(10).Cq().Text()) + release.Seeders;
var files = qRow.Find("td:nth-child(6)").Text();
release.Files = ParseUtil.CoerceInt(files);
var grabs = qRow.Find("td:nth-child(9) > a").Get(0).FirstChild.ToString();
release.Grabs = ParseUtil.CoerceInt(grabs);
2018-09-04 13:30:16 +00:00
release.DownloadVolumeFactor = 1;
release.UploadVolumeFactor = 1;
releases.Add(release);
2015-07-13 02:01:02 +00:00
}
}
catch (Exception ex)
{
OnParseError(results.Content, ex);
}
return releases;
2015-07-13 02:01:02 +00:00
}
}
}