mirror of
https://github.com/Jackett/Jackett
synced 2025-03-09 05:16:55 +00:00
anylibria: add guid and code clean up (#9885)
This commit is contained in:
parent
05380e3519
commit
af4864b9a9
1 changed files with 20 additions and 24 deletions
|
@ -2,23 +2,16 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AngleSharp.Dom;
|
|
||||||
using AngleSharp.Html.Parser;
|
|
||||||
using AngleSharp.Html.Dom;
|
|
||||||
using Jackett.Common.Models;
|
using Jackett.Common.Models;
|
||||||
using Jackett.Common.Models.IndexerConfig.Bespoke;
|
using Jackett.Common.Models.IndexerConfig.Bespoke;
|
||||||
using Jackett.Common.Services.Interfaces;
|
using Jackett.Common.Services.Interfaces;
|
||||||
using Jackett.Common.Utils;
|
using Jackett.Common.Utils;
|
||||||
using Jackett.Common.Utils.Clients;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace Jackett.Common.Indexers
|
namespace Jackett.Common.Indexers
|
||||||
{
|
{
|
||||||
|
@ -44,11 +37,8 @@ namespace Jackett.Common.Indexers
|
||||||
// Configure the category mappings
|
// Configure the category mappings
|
||||||
AddCategoryMapping(1, TorznabCatType.TVAnime, "Anime");
|
AddCategoryMapping(1, TorznabCatType.TVAnime, "Anime");
|
||||||
}
|
}
|
||||||
private ConfigurationDataAniLibria Configuration
|
|
||||||
{
|
private ConfigurationDataAniLibria Configuration => (ConfigurationDataAniLibria)configData;
|
||||||
get => (ConfigurationDataAniLibria)configData;
|
|
||||||
set => configData = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||||
{
|
{
|
||||||
|
@ -75,7 +65,7 @@ namespace Jackett.Common.Indexers
|
||||||
{ "filter", "names,poster.url,code,torrents.list,season.year" },
|
{ "filter", "names,poster.url,code,torrents.list,season.year" },
|
||||||
};
|
};
|
||||||
var response = await RequestWithCookiesAndRetryAsync(Configuration.ApiLink.Value + "/searchTitles?" + queryParameters.GetQueryString());
|
var response = await RequestWithCookiesAndRetryAsync(Configuration.ApiLink.Value + "/searchTitles?" + queryParameters.GetQueryString());
|
||||||
if (response.Status != System.Net.HttpStatusCode.OK)
|
if (response.Status != HttpStatusCode.OK)
|
||||||
throw new WebException($"AniLibria search returned unexpected result. Expected 200 OK but got {response.Status}.", WebExceptionStatus.ProtocolError);
|
throw new WebException($"AniLibria search returned unexpected result. Expected 200 OK but got {response.Status}.", WebExceptionStatus.ProtocolError);
|
||||||
|
|
||||||
var results = ParseApiResults(response.ContentString);
|
var results = ParseApiResults(response.ContentString);
|
||||||
|
@ -90,7 +80,7 @@ namespace Jackett.Common.Indexers
|
||||||
{ "filter", "names,poster.url,code,torrents.list,season.year" },
|
{ "filter", "names,poster.url,code,torrents.list,season.year" },
|
||||||
};
|
};
|
||||||
var response = await RequestWithCookiesAndRetryAsync(Configuration.ApiLink.Value + "/getUpdates?" + queryParameters.GetQueryString());
|
var response = await RequestWithCookiesAndRetryAsync(Configuration.ApiLink.Value + "/getUpdates?" + queryParameters.GetQueryString());
|
||||||
if (response.Status != System.Net.HttpStatusCode.OK)
|
if (response.Status != HttpStatusCode.OK)
|
||||||
throw new WebException($"AniLibria search returned unexpected result. Expected 200 OK but got {response.Status}.", WebExceptionStatus.ProtocolError);
|
throw new WebException($"AniLibria search returned unexpected result. Expected 200 OK but got {response.Status}.", WebExceptionStatus.ProtocolError);
|
||||||
|
|
||||||
return ParseApiResults(response.ContentString);
|
return ParseApiResults(response.ContentString);
|
||||||
|
@ -109,13 +99,18 @@ namespace Jackett.Common.Indexers
|
||||||
{
|
{
|
||||||
var releases = new List<ReleaseInfo>();
|
var releases = new List<ReleaseInfo>();
|
||||||
foreach (dynamic r in JArray.Parse(json)) {
|
foreach (dynamic r in JArray.Parse(json)) {
|
||||||
var baseRelease = new ReleaseInfo();
|
var baseRelease = new ReleaseInfo
|
||||||
baseRelease.Title = composeTitle(r);
|
{
|
||||||
baseRelease.BannerUrl = new Uri(Configuration.StaticLink.Value + r.poster.url);
|
Title = composeTitle(r),
|
||||||
baseRelease.Comments = new Uri(SiteLink + "/release/" + r.code + ".html");
|
BannerUrl = new Uri(Configuration.StaticLink.Value + r.poster.url),
|
||||||
baseRelease.DownloadVolumeFactor = 0;
|
Comments = new Uri(SiteLink + "/release/" + r.code + ".html"),
|
||||||
baseRelease.UploadVolumeFactor = 1;
|
DownloadVolumeFactor = 0,
|
||||||
baseRelease.Category = new int[]{ TorznabCatType.TVAnime.ID };
|
UploadVolumeFactor = 1,
|
||||||
|
Category = new []
|
||||||
|
{
|
||||||
|
TorznabCatType.TVAnime.ID
|
||||||
|
}
|
||||||
|
};
|
||||||
foreach (var t in r.torrents.list) {
|
foreach (var t in r.torrents.list) {
|
||||||
var release = (ReleaseInfo)baseRelease.Clone();
|
var release = (ReleaseInfo)baseRelease.Clone();
|
||||||
release.Title += " [" + t.quality["string"] + "] - " + t.series["string"];
|
release.Title += " [" + t.quality["string"] + "] - " + t.series["string"];
|
||||||
|
@ -124,7 +119,8 @@ namespace Jackett.Common.Indexers
|
||||||
release.Peers = t.leechers + t.seeders;
|
release.Peers = t.leechers + t.seeders;
|
||||||
release.Grabs = t.downloads;
|
release.Grabs = t.downloads;
|
||||||
release.Link = new Uri(SiteLink + t.url);
|
release.Link = new Uri(SiteLink + t.url);
|
||||||
release.PublishDate = new System.DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc).AddSeconds(Convert.ToDouble(t.uploaded_timestamp)).ToLocalTime();
|
release.Guid = new Uri(SiteLink + t.url);
|
||||||
|
release.PublishDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(Convert.ToDouble(t.uploaded_timestamp)).ToLocalTime();
|
||||||
releases.Add(release);
|
releases.Add(release);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue