mirror of https://github.com/Jackett/Jackett
Implemented pretome
This commit is contained in:
parent
55e0297f81
commit
17d6ee69ff
|
@ -33,6 +33,7 @@ Download in the [Releases page](https://github.com/zone117x/Jackett/releases)
|
|||
* [HD-Torrents.org](https://hd-torrents.org/)
|
||||
* [IPTorrents](https://iptorrents.com/)
|
||||
* [MoreThan.tv](https://morethan.tv/)
|
||||
* [pretome](https://pretome.info)
|
||||
* [PrivateHD](https://privatehd.to/)
|
||||
* [RARBG](https://rarbg.com)
|
||||
* [SceneAccess](https://sceneaccess.eu/login)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
|
@ -0,0 +1,190 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Jackett.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Jackett.Utils.Clients;
|
||||
using Jackett.Services;
|
||||
using NLog;
|
||||
using Jackett.Utils;
|
||||
using CsQuery;
|
||||
using System.Web;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class Pretome : BaseIndexer, IIndexer
|
||||
{
|
||||
|
||||
class PretomeConfiguration : ConfigurationDataBasicLogin
|
||||
{
|
||||
public StringItem Pin { get; private set; }
|
||||
|
||||
public PretomeConfiguration() : base()
|
||||
{
|
||||
Pin = new StringItem { Name = "Login Pin Number" };
|
||||
}
|
||||
|
||||
public override Item[] GetItems()
|
||||
{
|
||||
return new Item[] { Pin, Username, Password };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private readonly string LoginUrl = "";
|
||||
private readonly string LoginReferer = "";
|
||||
private readonly string SearchUrl = "";
|
||||
private string cookieHeader = "";
|
||||
|
||||
private IWebClient webclient;
|
||||
|
||||
public Pretome(IIndexerManagerService i, IWebClient wc, Logger l)
|
||||
: base(name: "PrivateHD",
|
||||
description: "BitTorrent site for High Quality, High Definition (HD) movies and TV Shows",
|
||||
link: new Uri("https://pretome.info"),
|
||||
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
|
||||
manager: i,
|
||||
logger: l)
|
||||
{
|
||||
LoginUrl = SiteLink + "takelogin.php";
|
||||
LoginReferer = SiteLink + "index.php?cat=1";
|
||||
SearchUrl = SiteLink + "browse.php?tags=&st=1&tf=all&cat%5B%5D=7&search={0}";
|
||||
webclient = wc;
|
||||
}
|
||||
|
||||
public Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
var config = new PretomeConfiguration();
|
||||
return Task.FromResult<ConfigurationData>(config);
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var config = new PretomeConfiguration();
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
var loginPage = await webclient.GetString(new WebRequest()
|
||||
{
|
||||
Url = LoginUrl,
|
||||
Type = RequestType.GET
|
||||
});
|
||||
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "returnto", "%2F" },
|
||||
{ "login_pin", config.Pin.Value },
|
||||
{ "username", config.Username.Value },
|
||||
{ "password", config.Password.Value },
|
||||
{ "login", "Login" }
|
||||
};
|
||||
|
||||
|
||||
// Send Post
|
||||
var loginPost = await webclient.GetString(new WebRequest()
|
||||
{
|
||||
Url = LoginUrl,
|
||||
PostData = pairs,
|
||||
Referer = LoginReferer,
|
||||
Type = RequestType.POST,
|
||||
Cookies = loginPage.Cookies
|
||||
});
|
||||
|
||||
if (loginPost.RedirectingTo == null)
|
||||
{
|
||||
throw new ExceptionWithConfigData("Login failed. Did you use the PIN number that pretome emailed you?", (ConfigurationData)config);
|
||||
}
|
||||
|
||||
// Get result from redirect
|
||||
var loginResult = await webclient.GetString(new WebRequest()
|
||||
{
|
||||
Url = loginPost.RedirectingTo,
|
||||
Type = RequestType.GET,
|
||||
Cookies = loginPost.Cookies
|
||||
});
|
||||
|
||||
if (!loginResult.Content.Contains("logout.php"))
|
||||
{
|
||||
throw new ExceptionWithConfigData("Failed", (ConfigurationData)config);
|
||||
}
|
||||
else
|
||||
{
|
||||
cookieHeader = loginPost.Cookies;
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["cookies"] = cookieHeader;
|
||||
SaveConfig(configSaveData);
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
cookieHeader = (string)jsonConfig["cookies"];
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
public async Task<byte[]> Download(Uri link)
|
||||
{
|
||||
var response = await webclient.GetBytes(new WebRequest()
|
||||
{
|
||||
Url = link.ToString(),
|
||||
Cookies = cookieHeader
|
||||
});
|
||||
return response.Content;
|
||||
}
|
||||
|
||||
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
||||
|
||||
var searchString = query.SanitizedSearchTerm + " " + query.GetEpisodeSearchString();
|
||||
var episodeSearchUrl = string.Format(SearchUrl, HttpUtility.UrlEncode(searchString));
|
||||
|
||||
var response = await webclient.GetString(new WebRequest()
|
||||
{
|
||||
Url = episodeSearchUrl,
|
||||
Referer = SiteLink.ToString(),
|
||||
Cookies = cookieHeader
|
||||
});
|
||||
var results = response.Content;
|
||||
|
||||
try
|
||||
{
|
||||
CQ dom = results;
|
||||
var rows = dom["table > tbody > tr.browse"];
|
||||
foreach (var row in rows)
|
||||
{
|
||||
CQ qRow = row.Cq();
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
|
||||
var qLink = row.ChildElements.ElementAt(1).Cq().Find("a").First();
|
||||
release.Title = qLink.Text().Trim();
|
||||
release.Comments = new Uri(SiteLink + qLink.Attr("href"));
|
||||
release.Guid = release.Comments;
|
||||
|
||||
var qDownload = row.ChildElements.ElementAt(2).Cq().Find("a").First();
|
||||
release.Link = new Uri(SiteLink + qDownload.Attr("href"));
|
||||
|
||||
var dateStr = row.ChildElements.ElementAt(5).Cq().Text();
|
||||
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).InnerText);
|
||||
release.Peers = ParseUtil.CoerceInt(row.ChildElements.ElementAt(10).InnerText) + release.Seeders;
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnParseError(results, ex);
|
||||
}
|
||||
return releases.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -158,6 +158,7 @@
|
|||
<Compile Include="Indexers\BakaBT.cs" />
|
||||
<Compile Include="Indexers\BaseIndexer.cs" />
|
||||
<Compile Include="Indexers\BB.cs" />
|
||||
<Compile Include="Indexers\Pretome.cs" />
|
||||
<Compile Include="Indexers\PrivateHD.cs" />
|
||||
<Compile Include="Indexers\SpeedCD.cs" />
|
||||
<Compile Include="Models\TorznabCapabilities.cs" />
|
||||
|
@ -292,6 +293,9 @@
|
|||
<Content Include="Content\logos\hdtorrents.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\logos\pretome.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\logos\privatehd.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
using System;
|
||||
using Jackett.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jackett.Models
|
||||
|
@ -53,22 +55,25 @@ namespace Jackett.Models
|
|||
};
|
||||
}
|
||||
|
||||
// ex: " 3.5 gb "
|
||||
public static long GetBytes(string str)
|
||||
{
|
||||
var valStr = new string(str.Where(c => char.IsDigit(c) || c == '.').ToArray());
|
||||
var unit = new string(str.Where(char.IsLetter).ToArray());
|
||||
var val = ParseUtil.CoerceFloat(valStr);
|
||||
return GetBytes(unit, val);
|
||||
}
|
||||
|
||||
public static long GetBytes(string unit, float value)
|
||||
{
|
||||
switch (unit.ToLower())
|
||||
{
|
||||
case "kb":
|
||||
case "kib":
|
||||
return BytesFromKB(value);
|
||||
case "mb":
|
||||
case "mib":
|
||||
return BytesFromMB(value);
|
||||
case "gb":
|
||||
case "gib":
|
||||
return BytesFromGB(value);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
unit = unit.Replace("i", "").ToLowerInvariant();
|
||||
if (unit.Contains("kb"))
|
||||
return BytesFromKB(value);
|
||||
if (unit.Contains("mb"))
|
||||
return BytesFromMB(value);
|
||||
if (unit.Contains("gb"))
|
||||
return BytesFromGB(value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static long BytesFromGB(float gb)
|
||||
|
|
Loading…
Reference in New Issue