mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Change indexers to use new api
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using CsQuery;
|
||||
using Jackett.Models;
|
||||
using Jackett.Services;
|
||||
using Jackett.Utils;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
@@ -16,7 +17,7 @@ using System.Web;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class BitMeTV : IIndexer
|
||||
public class BitMeTV : BaseIndexer, IIndexer
|
||||
{
|
||||
class BmtvConfig : ConfigurationData
|
||||
{
|
||||
@@ -42,24 +43,28 @@ namespace Jackett.Indexers
|
||||
}
|
||||
}
|
||||
|
||||
static string BaseUrl = "http://www.bitmetv.org";
|
||||
static string LoginUrl = BaseUrl + "/login.php";
|
||||
static string LoginPost = BaseUrl + "/takelogin.php";
|
||||
static string CaptchaUrl = BaseUrl + "/visual.php";
|
||||
static string SearchUrl = BaseUrl + "/browse.php";
|
||||
private readonly string LoginUrl = "";
|
||||
private readonly string LoginPost = "";
|
||||
private readonly string CaptchaUrl = "";
|
||||
private readonly string SearchUrl = "";
|
||||
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
Logger logger;
|
||||
|
||||
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IIndexer, string, Exception> OnResultParsingError;
|
||||
|
||||
public BitMeTV(Logger l)
|
||||
public BitMeTV(IIndexerManagerService i, Logger l) :
|
||||
base(name: "BitMeTV",
|
||||
description: "TV Episode specialty tracker",
|
||||
link: new Uri("http://www.bitmetv.org"),
|
||||
rageid: true,
|
||||
manager: i,
|
||||
logger: l)
|
||||
{
|
||||
logger = l;
|
||||
IsConfigured = false;
|
||||
LoginUrl = SiteLink + "/login.php";
|
||||
LoginPost = SiteLink + "/takelogin.php";
|
||||
CaptchaUrl = SiteLink + "/visual.php";
|
||||
SearchUrl = SiteLink + "/browse.php";
|
||||
|
||||
cookies = new CookieContainer();
|
||||
handler = new HttpClientHandler
|
||||
{
|
||||
@@ -70,16 +75,6 @@ namespace Jackett.Indexers
|
||||
client = new HttpClient(handler);
|
||||
}
|
||||
|
||||
public string DisplayName { get { return "BitMeTV"; } }
|
||||
|
||||
public string DisplayDescription { get { return "TV Episode specialty tracker"; } }
|
||||
|
||||
public Uri SiteLink { get { return new Uri(BaseUrl); } }
|
||||
|
||||
public bool RequiresRageIDLookupDisabled { get { return true; } }
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
public async Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
await client.GetAsync(LoginUrl);
|
||||
@@ -119,17 +114,14 @@ namespace Jackett.Indexers
|
||||
{
|
||||
var configSaveData = new JObject();
|
||||
cookies.DumpToJson(SiteLink, configSaveData);
|
||||
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested(this, configSaveData);
|
||||
|
||||
SaveConfig(configSaveData);
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
cookies.FillFromJson(new Uri(BaseUrl), jsonConfig, logger);
|
||||
cookies.FillFromJson(SiteLink, jsonConfig, logger);
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
@@ -155,7 +147,7 @@ namespace Jackett.Indexers
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Comments = new Uri(BaseUrl + "/" + qLink.Attr("href"));
|
||||
release.Comments = new Uri(SiteLink + "/" + qLink.Attr("href"));
|
||||
release.Guid = release.Comments;
|
||||
release.Title = qLink.Attr("title");
|
||||
release.Description = release.Title;
|
||||
@@ -169,7 +161,7 @@ namespace Jackett.Indexers
|
||||
var date = DateTime.ParseExact(formattedTimeString, "dddd MMMM d yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
|
||||
release.PublishDate = DateTime.SpecifyKind(date, DateTimeKind.Utc).ToLocalTime();
|
||||
|
||||
release.Link = new Uri(BaseUrl + "/" + row.ChildElements.ElementAt(2).Cq().Children("a.index").Attr("href"));
|
||||
release.Link = new Uri(SiteLink + "/" + row.ChildElements.ElementAt(2).Cq().Children("a.index").Attr("href"));
|
||||
|
||||
var sizeCol = row.ChildElements.ElementAt(6);
|
||||
var sizeVal = ParseUtil.CoerceFloat(sizeCol.ChildNodes[0].NodeValue);
|
||||
@@ -187,8 +179,7 @@ namespace Jackett.Indexers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
OnParseError(results, ex);
|
||||
}
|
||||
|
||||
return releases.ToArray();
|
||||
|
Reference in New Issue
Block a user