mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
parent
9f066f7a6b
commit
7921dd3f96
@ -1,67 +0,0 @@
|
|||||||
{
|
|
||||||
"code": "SUCCESSFUL",
|
|
||||||
"http_code": 200,
|
|
||||||
"limit": "2",
|
|
||||||
"offset": 0,
|
|
||||||
"results": [
|
|
||||||
{
|
|
||||||
"air_date": "20150623",
|
|
||||||
"anonymous": 1,
|
|
||||||
"codec": "x264",
|
|
||||||
"container": "MKV",
|
|
||||||
"created_at": "2015-06-25 04:13:44",
|
|
||||||
"download": "https://titansof.tv/api/torrents/19445/download?apikey=abc",
|
|
||||||
"ecommentUrl": "https://titansof.tv/series/287053/episode/5453241#comments",
|
|
||||||
"episode": "S02E04",
|
|
||||||
"episodeUrl": "https://titansof.tv/series/287053/episode/5453241",
|
|
||||||
"episode_id": "5453241",
|
|
||||||
"id": "19445",
|
|
||||||
"language": "en",
|
|
||||||
"leechers": 5,
|
|
||||||
"network": "truTV",
|
|
||||||
"origin": "Scene",
|
|
||||||
"release_name": "Series.Title.S02E04.720p.HDTV.x264-W4F",
|
|
||||||
"resolution": "720p",
|
|
||||||
"season": "",
|
|
||||||
"season_id": 0,
|
|
||||||
"seeders": 2,
|
|
||||||
"series": "Series Title",
|
|
||||||
"series_id": "287053",
|
|
||||||
"size": 435402993,
|
|
||||||
"snatched": 0,
|
|
||||||
"source": "HDTV",
|
|
||||||
"updated_at": "2015-06-25 04:13:44",
|
|
||||||
"user_id": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"air_date": "20150624",
|
|
||||||
"anonymous": 1,
|
|
||||||
"codec": "x264",
|
|
||||||
"container": "MKV",
|
|
||||||
"created_at": "2015-06-25 04:11:59",
|
|
||||||
"download": "https://titansof.tv/api/torrents/19444/download?apikey=abc",
|
|
||||||
"ecommentUrl": "https://titansof.tv/series/75382/episode/5443517#comments",
|
|
||||||
"episode": "S21E10",
|
|
||||||
"episodeUrl": "https://titansof.tv/series/75382/episode/5443517",
|
|
||||||
"episode_id": "5443517",
|
|
||||||
"id": "19444",
|
|
||||||
"language": "en",
|
|
||||||
"leechers": 0,
|
|
||||||
"network": "FX",
|
|
||||||
"origin": "User",
|
|
||||||
"release_name": "Series.Title.S21E10.720p.HDTV.x264-KOENiG",
|
|
||||||
"resolution": "720p",
|
|
||||||
"season": "",
|
|
||||||
"season_id": 0,
|
|
||||||
"seeders": 1,
|
|
||||||
"series": "Series Title",
|
|
||||||
"series_id": "75382",
|
|
||||||
"size": 949968933,
|
|
||||||
"snatched": 0,
|
|
||||||
"source": "HDTV",
|
|
||||||
"updated_at": "2015-06-25 04:11:59",
|
|
||||||
"user_id": 0
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"total": 18546
|
|
||||||
}
|
|
@ -1,157 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using FluentAssertions;
|
|
||||||
using Moq;
|
|
||||||
using NUnit.Framework;
|
|
||||||
using NzbDrone.Common.Http;
|
|
||||||
using NzbDrone.Core.Indexers;
|
|
||||||
using NzbDrone.Core.Indexers.TitansOfTv;
|
|
||||||
using NzbDrone.Core.Parser.Model;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
|
||||||
using NzbDrone.Test.Common;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.IndexerTests.TitansOfTvTests
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public class TitansOfTvFixture : CoreTest<TitansOfTv>
|
|
||||||
{
|
|
||||||
[SetUp]
|
|
||||||
public void Setup()
|
|
||||||
{
|
|
||||||
Subject.Definition = new IndexerDefinition
|
|
||||||
{
|
|
||||||
Name = "TitansOfTV",
|
|
||||||
Settings = new TitansOfTvSettings { ApiKey = "abc", BaseUrl = "https://titansof.tv/api" }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_parse_recent_feed_from_TitansOfTv()
|
|
||||||
{
|
|
||||||
var recentFeed = ReadAllText(@"Files/Indexers/TitansOfTv/RecentFeed.json");
|
|
||||||
|
|
||||||
Mocker.GetMock<IHttpClient>()
|
|
||||||
.Setup(o => o.Execute(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET)))
|
|
||||||
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), recentFeed));
|
|
||||||
|
|
||||||
var releases = Subject.FetchRecent();
|
|
||||||
|
|
||||||
releases.Should().HaveCount(2);
|
|
||||||
releases.First().Should().BeOfType<TorrentInfo>();
|
|
||||||
|
|
||||||
var torrentInfo = releases.First() as TorrentInfo;
|
|
||||||
|
|
||||||
torrentInfo.Guid.Should().Be("ToTV-19445");
|
|
||||||
torrentInfo.Title.Should().Be("Series.Title.S02E04.720p.HDTV.x264-W4F");
|
|
||||||
torrentInfo.DownloadProtocol.Should().Be(DownloadProtocol.Torrent);
|
|
||||||
torrentInfo.DownloadUrl.Should().Be("https://titansof.tv/api/torrents/19445/download?apikey=abc");
|
|
||||||
torrentInfo.InfoUrl.Should().Be("https://titansof.tv/series/287053/episode/5453241");
|
|
||||||
torrentInfo.CommentUrl.Should().BeNullOrEmpty();
|
|
||||||
torrentInfo.Indexer.Should().Be(Subject.Definition.Name);
|
|
||||||
torrentInfo.PublishDate.Should().Be(DateTime.Parse("2015-06-25 04:13:44"));
|
|
||||||
torrentInfo.Size.Should().Be(435402993);
|
|
||||||
torrentInfo.InfoHash.Should().BeNullOrEmpty();
|
|
||||||
torrentInfo.TvdbId.Should().Be(0);
|
|
||||||
torrentInfo.TvRageId.Should().Be(0);
|
|
||||||
torrentInfo.MagnetUrl.Should().BeNullOrEmpty();
|
|
||||||
torrentInfo.Peers.Should().Be(2+5);
|
|
||||||
torrentInfo.Seeders.Should().Be(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void VerifyBackOff()
|
|
||||||
{
|
|
||||||
Mocker.GetMock<IIndexerStatusService>()
|
|
||||||
.Verify(v => v.RecordFailure(It.IsAny<int>(), It.IsAny<TimeSpan>()), Times.Once());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_back_off_on_bad_request()
|
|
||||||
{
|
|
||||||
Mocker.GetMock<IHttpClient>()
|
|
||||||
.Setup(v => v.Execute(It.IsAny<HttpRequest>()))
|
|
||||||
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0], System.Net.HttpStatusCode.BadRequest));
|
|
||||||
|
|
||||||
var results = Subject.FetchRecent();
|
|
||||||
|
|
||||||
results.Should().BeEmpty();
|
|
||||||
|
|
||||||
VerifyBackOff();
|
|
||||||
|
|
||||||
ExceptionVerification.ExpectedWarns(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_back_off_and_report_api_key_invalid()
|
|
||||||
{
|
|
||||||
Mocker.GetMock<IHttpClient>()
|
|
||||||
.Setup(v => v.Execute(It.IsAny<HttpRequest>()))
|
|
||||||
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0], System.Net.HttpStatusCode.Unauthorized));
|
|
||||||
|
|
||||||
var results = Subject.FetchRecent();
|
|
||||||
|
|
||||||
results.Should().BeEmpty();
|
|
||||||
|
|
||||||
results.Should().BeEmpty();
|
|
||||||
|
|
||||||
VerifyBackOff();
|
|
||||||
|
|
||||||
ExceptionVerification.ExpectedWarns(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_back_off_on_unknown_method()
|
|
||||||
{
|
|
||||||
Mocker.GetMock<IHttpClient>()
|
|
||||||
.Setup(v => v.Execute(It.IsAny<HttpRequest>()))
|
|
||||||
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0], System.Net.HttpStatusCode.NotFound));
|
|
||||||
|
|
||||||
var results = Subject.FetchRecent();
|
|
||||||
|
|
||||||
results.Should().BeEmpty();
|
|
||||||
|
|
||||||
VerifyBackOff();
|
|
||||||
|
|
||||||
ExceptionVerification.ExpectedWarns(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_back_off_api_limit_reached()
|
|
||||||
{
|
|
||||||
Mocker.GetMock<IHttpClient>()
|
|
||||||
.Setup(v => v.Execute(It.IsAny<HttpRequest>()))
|
|
||||||
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0], System.Net.HttpStatusCode.ServiceUnavailable));
|
|
||||||
|
|
||||||
var results = Subject.FetchRecent();
|
|
||||||
|
|
||||||
results.Should().BeEmpty();
|
|
||||||
|
|
||||||
VerifyBackOff();
|
|
||||||
|
|
||||||
ExceptionVerification.ExpectedWarns(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_replace_https_http_as_needed()
|
|
||||||
{
|
|
||||||
var recentFeed = ReadAllText(@"Files/Indexers/TitansOfTv/RecentFeed.json");
|
|
||||||
|
|
||||||
(Subject.Definition.Settings as TitansOfTvSettings).BaseUrl = "http://titansof.tv/api/torrents";
|
|
||||||
|
|
||||||
recentFeed = recentFeed.Replace("http:", "https:");
|
|
||||||
|
|
||||||
Mocker.GetMock<IHttpClient>()
|
|
||||||
.Setup(o => o.Execute(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET)))
|
|
||||||
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), recentFeed));
|
|
||||||
|
|
||||||
var releases = Subject.FetchRecent();
|
|
||||||
|
|
||||||
releases.Should().HaveCount(2);
|
|
||||||
releases.First().Should().BeOfType<TorrentInfo>();
|
|
||||||
|
|
||||||
var torrentInfo = releases.First() as TorrentInfo;
|
|
||||||
|
|
||||||
torrentInfo.DownloadUrl.Should().Be("http://titansof.tv/api/torrents/19445/download?apikey=abc");
|
|
||||||
torrentInfo.InfoUrl.Should().Be("http://titansof.tv/series/287053/episode/5453241");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -223,7 +223,6 @@
|
|||||||
<Compile Include="IndexerTests\IndexerStatusServiceFixture.cs" />
|
<Compile Include="IndexerTests\IndexerStatusServiceFixture.cs" />
|
||||||
<Compile Include="IndexerTests\IntegrationTests\IndexerIntegrationTests.cs" />
|
<Compile Include="IndexerTests\IntegrationTests\IndexerIntegrationTests.cs" />
|
||||||
<Compile Include="IndexerTests\RarbgTests\RarbgFixture.cs" />
|
<Compile Include="IndexerTests\RarbgTests\RarbgFixture.cs" />
|
||||||
<Compile Include="IndexerTests\TitansOfTvTests\TitansOfTvFixture.cs" />
|
|
||||||
<Compile Include="IndexerTests\TorrentRssIndexerTests\TorrentRssParserFactoryFixture.cs" />
|
<Compile Include="IndexerTests\TorrentRssIndexerTests\TorrentRssParserFactoryFixture.cs" />
|
||||||
<Compile Include="IndexerTests\TorrentRssIndexerTests\TorrentRssSettingsDetectorFixture.cs" />
|
<Compile Include="IndexerTests\TorrentRssIndexerTests\TorrentRssSettingsDetectorFixture.cs" />
|
||||||
<Compile Include="IndexerTests\TorznabTests\TorznabFixture.cs" />
|
<Compile Include="IndexerTests\TorznabTests\TorznabFixture.cs" />
|
||||||
@ -509,9 +508,6 @@
|
|||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Files\Indexers\TitansOfTv\RecentFeed.json">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Include="Files\TestArchive.tar.gz">
|
<None Include="Files\TestArchive.tar.gz">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
using FluentMigrator;
|
||||||
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Migration
|
||||||
|
{
|
||||||
|
[Migration(98)]
|
||||||
|
public class remove_titans_of_tv : NzbDroneMigrationBase
|
||||||
|
{
|
||||||
|
protected override void MainDbUpgrade()
|
||||||
|
{
|
||||||
|
Delete.FromTable("Indexers").Row(new { Implementation = "TitansOfTv" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,37 +0,0 @@
|
|||||||
using System;
|
|
||||||
using NLog;
|
|
||||||
using NzbDrone.Common.Http;
|
|
||||||
using NzbDrone.Core.Configuration;
|
|
||||||
using NzbDrone.Core.Parser;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers.TitansOfTv
|
|
||||||
{
|
|
||||||
public class TitansOfTv : HttpIndexerBase<TitansOfTvSettings>
|
|
||||||
{
|
|
||||||
public TitansOfTv(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
|
|
||||||
: base(httpClient, indexerStatusService, configService, parsingService, logger)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Name
|
|
||||||
{
|
|
||||||
get { return "Titans of TV"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override DownloadProtocol Protocol { get { return DownloadProtocol.Torrent; } }
|
|
||||||
public override bool SupportsRss { get { return true; } }
|
|
||||||
public override bool SupportsSearch { get { return true; } }
|
|
||||||
public override int PageSize { get { return 100; } }
|
|
||||||
|
|
||||||
public override IIndexerRequestGenerator GetRequestGenerator()
|
|
||||||
{
|
|
||||||
return new TitansOfTvRequestGenerator() { Settings = Settings, PageSize = PageSize };
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IParseIndexerResponse GetParser()
|
|
||||||
{
|
|
||||||
return new TitansOfTvParser();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers.TitansOfTv
|
|
||||||
{
|
|
||||||
public class TitansOfTvApiResult
|
|
||||||
{
|
|
||||||
public string code { get; set; }
|
|
||||||
public int http_code { get; set; }
|
|
||||||
public int total { get; set; }
|
|
||||||
public int offset { get; set; }
|
|
||||||
public int limit { get; set; }
|
|
||||||
public List<TitansOfTvTorrent> results { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TitansOfTvTorrent
|
|
||||||
{
|
|
||||||
public string id { get; set; }
|
|
||||||
public string series_id { get; set; }
|
|
||||||
public string episode_id { get; set; }
|
|
||||||
public string season_id { get; set; }
|
|
||||||
public int? seeders { get; set; }
|
|
||||||
public int? leechers { get; set; }
|
|
||||||
public long size { get; set; }
|
|
||||||
public int? snatched { get; set; }
|
|
||||||
public int user_id { get; set; }
|
|
||||||
public string anonymous { get; set; }
|
|
||||||
public string container { get; set; }
|
|
||||||
public string codec { get; set; }
|
|
||||||
public string source { get; set; }
|
|
||||||
public string resolution { get; set; }
|
|
||||||
public string origin { get; set; }
|
|
||||||
public string language { get; set; }
|
|
||||||
public string release_name { get; set; }
|
|
||||||
public string tracker_updated_at { get; set; }
|
|
||||||
public DateTime created_at { get; set; }
|
|
||||||
public DateTime updated_at { get; set; }
|
|
||||||
public string season { get; set; }
|
|
||||||
public string episode { get; set; }
|
|
||||||
public string series { get; set; }
|
|
||||||
public string network { get; set; }
|
|
||||||
public string mediainfo { get; set; }
|
|
||||||
public string download { get; set; }
|
|
||||||
public string additional { get; set; }
|
|
||||||
public string episodeUrl { get; set; }
|
|
||||||
public string commentUrl { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Net;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using NzbDrone.Common.Extensions;
|
|
||||||
using NzbDrone.Common.Serializer;
|
|
||||||
using NzbDrone.Core.Indexers.Exceptions;
|
|
||||||
using NzbDrone.Core.Parser.Model;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers.TitansOfTv
|
|
||||||
{
|
|
||||||
public class TitansOfTvParser : IParseIndexerResponse
|
|
||||||
{
|
|
||||||
private static readonly Regex RegexProtocol = new Regex("^https?:", RegexOptions.Compiled);
|
|
||||||
|
|
||||||
public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|
||||||
{
|
|
||||||
var results = new List<ReleaseInfo>();
|
|
||||||
|
|
||||||
switch (indexerResponse.HttpResponse.StatusCode)
|
|
||||||
{
|
|
||||||
case HttpStatusCode.Unauthorized:
|
|
||||||
throw new ApiKeyException("API Key invalid or not authorized");
|
|
||||||
case HttpStatusCode.NotFound:
|
|
||||||
throw new IndexerException(indexerResponse, "Indexer API call returned NotFound, the Indexer API may have changed.");
|
|
||||||
case HttpStatusCode.ServiceUnavailable:
|
|
||||||
throw new RequestLimitReachedException("Indexer API is temporarily unavailable, try again later");
|
|
||||||
default:
|
|
||||||
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK)
|
|
||||||
{
|
|
||||||
throw new IndexerException(indexerResponse, "Indexer API call returned an unexpected StatusCode [{0}]", indexerResponse.HttpResponse.StatusCode);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
var content = indexerResponse.HttpResponse.Content;
|
|
||||||
var parsed = Json.Deserialize<TitansOfTvApiResult>(content);
|
|
||||||
var protocol = indexerResponse.HttpRequest.Url.Scheme + ":";
|
|
||||||
|
|
||||||
foreach (var parsedItem in parsed.results)
|
|
||||||
{
|
|
||||||
var release = new TorrentInfo();
|
|
||||||
release.Guid = string.Format("ToTV-{0}", parsedItem.id);
|
|
||||||
release.DownloadUrl = RegexProtocol.Replace(parsedItem.download, protocol);
|
|
||||||
release.InfoUrl = RegexProtocol.Replace(parsedItem.episodeUrl, protocol);
|
|
||||||
if (parsedItem.commentUrl.IsNotNullOrWhiteSpace())
|
|
||||||
{
|
|
||||||
release.CommentUrl = RegexProtocol.Replace(parsedItem.commentUrl, protocol);
|
|
||||||
}
|
|
||||||
release.DownloadProtocol = DownloadProtocol.Torrent;
|
|
||||||
release.Title = parsedItem.release_name;
|
|
||||||
release.Size = parsedItem.size;
|
|
||||||
release.Seeders = parsedItem.seeders;
|
|
||||||
release.Peers = parsedItem.leechers + release.Seeders;
|
|
||||||
release.PublishDate = parsedItem.created_at;
|
|
||||||
results.Add(release);
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,121 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using NzbDrone.Common.Extensions;
|
|
||||||
using NzbDrone.Common.Http;
|
|
||||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers.TitansOfTv
|
|
||||||
{
|
|
||||||
public class TitansOfTvRequestGenerator : IIndexerRequestGenerator
|
|
||||||
{
|
|
||||||
public int MaxPages { get; set; }
|
|
||||||
public int PageSize { get; set; }
|
|
||||||
public TitansOfTvSettings Settings { get; set; }
|
|
||||||
|
|
||||||
public TitansOfTvRequestGenerator()
|
|
||||||
{
|
|
||||||
MaxPages = 30;
|
|
||||||
PageSize = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual IndexerPageableRequestChain GetRecentRequests()
|
|
||||||
{
|
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
|
||||||
|
|
||||||
pageableRequests.Add(GetPagedRequests(MaxPages));
|
|
||||||
|
|
||||||
return pageableRequests;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria)
|
|
||||||
{
|
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
|
||||||
|
|
||||||
pageableRequests.Add(GetPagedRequests(MaxPages,
|
|
||||||
series_id: searchCriteria.Series.TvdbId,
|
|
||||||
episode: string.Format("S{0:00}E{1:00}", searchCriteria.SeasonNumber, searchCriteria.EpisodeNumber)));
|
|
||||||
|
|
||||||
pageableRequests.Add(GetPagedRequests(MaxPages,
|
|
||||||
series_id: searchCriteria.Series.TvdbId,
|
|
||||||
season: string.Format("Season {0:00}", searchCriteria.SeasonNumber)));
|
|
||||||
|
|
||||||
return pageableRequests;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria)
|
|
||||||
{
|
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
|
||||||
|
|
||||||
pageableRequests.Add(GetPagedRequests(MaxPages,
|
|
||||||
series_id: searchCriteria.Series.TvdbId,
|
|
||||||
season: string.Format("Season {0:00}", searchCriteria.SeasonNumber)));
|
|
||||||
|
|
||||||
pageableRequests.AddTier();
|
|
||||||
|
|
||||||
// TODO: Search for all episodes?!?
|
|
||||||
|
|
||||||
return pageableRequests;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria)
|
|
||||||
{
|
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
|
||||||
|
|
||||||
pageableRequests.Add(GetPagedRequests(MaxPages,
|
|
||||||
series_id: searchCriteria.Series.TvdbId,
|
|
||||||
air_date: searchCriteria.AirDate));
|
|
||||||
|
|
||||||
return pageableRequests;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria)
|
|
||||||
{
|
|
||||||
return new IndexerPageableRequestChain();
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria)
|
|
||||||
{
|
|
||||||
return new IndexerPageableRequestChain();
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, int? series_id = null, string episode = null, string season = null, DateTime? air_date = null)
|
|
||||||
{
|
|
||||||
var pageSize = PageSize;
|
|
||||||
|
|
||||||
if (pageSize == 0)
|
|
||||||
{
|
|
||||||
maxPages = 1;
|
|
||||||
pageSize = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var page = 0; page < maxPages; page++)
|
|
||||||
{
|
|
||||||
var request = new IndexerRequest(string.Format("{0}/torrents?offset={1}&limit={2}", Settings.BaseUrl.TrimEnd('/'), page * pageSize, pageSize), HttpAccept.Json);
|
|
||||||
request.HttpRequest.Headers.Add("X-Authorization", Settings.ApiKey);
|
|
||||||
|
|
||||||
if (series_id.HasValue)
|
|
||||||
{
|
|
||||||
request.HttpRequest.AddQueryParam("series_id", series_id.Value.ToString(CultureInfo.InvariantCulture));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (season != null)
|
|
||||||
{
|
|
||||||
request.HttpRequest.AddQueryParam("season", season);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (episode != null)
|
|
||||||
{
|
|
||||||
request.HttpRequest.AddQueryParam("episode", episode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (air_date.HasValue)
|
|
||||||
{
|
|
||||||
request.HttpRequest.AddQueryParam("air_date", air_date.Value.ToString("yyyy-MM-dd"));
|
|
||||||
}
|
|
||||||
|
|
||||||
yield return request;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
using FluentValidation;
|
|
||||||
using NzbDrone.Core.Annotations;
|
|
||||||
using NzbDrone.Core.ThingiProvider;
|
|
||||||
using NzbDrone.Core.Validation;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers.TitansOfTv
|
|
||||||
{
|
|
||||||
public class TitansOfTvSettingsValidator : AbstractValidator<TitansOfTvSettings>
|
|
||||||
{
|
|
||||||
public TitansOfTvSettingsValidator()
|
|
||||||
{
|
|
||||||
RuleFor(c => c.ApiKey).NotEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TitansOfTvSettings : IProviderConfig
|
|
||||||
{
|
|
||||||
private static readonly TitansOfTvSettingsValidator Validator = new TitansOfTvSettingsValidator();
|
|
||||||
|
|
||||||
public TitansOfTvSettings()
|
|
||||||
{
|
|
||||||
BaseUrl = "http://titansof.tv/api";
|
|
||||||
}
|
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "API URL", Advanced = true, HelpText = "Do not change this unless you know what you're doing. Since your API key will be sent to that host.")]
|
|
||||||
public string BaseUrl { get; set; }
|
|
||||||
|
|
||||||
[FieldDefinition(1, Label = "API key", HelpText = "Enter your ToTV API key. (My Account->API->Site API Key)")]
|
|
||||||
public string ApiKey { get; set; }
|
|
||||||
|
|
||||||
public NzbDroneValidationResult Validate()
|
|
||||||
{
|
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -273,6 +273,9 @@
|
|||||||
<Compile Include="Datastore\Migration\093_naming_config_replace_characters.cs" />
|
<Compile Include="Datastore\Migration\093_naming_config_replace_characters.cs" />
|
||||||
<Compile Include="Datastore\Migration\092_add_unverifiedscenenumbering.cs" />
|
<Compile Include="Datastore\Migration\092_add_unverifiedscenenumbering.cs" />
|
||||||
<Compile Include="Datastore\Migration\094_add_tvmazeid.cs" />
|
<Compile Include="Datastore\Migration\094_add_tvmazeid.cs" />
|
||||||
|
<Compile Include="Datastore\Migration\098_remove_titans_of_tv.cs">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
|
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
|
||||||
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
|
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
|
||||||
<Compile Include="Datastore\Migration\Framework\MigrationDbFactory.cs" />
|
<Compile Include="Datastore\Migration\Framework\MigrationDbFactory.cs" />
|
||||||
@ -554,11 +557,6 @@
|
|||||||
<Compile Include="Indexers\RssSyncCommand.cs" />
|
<Compile Include="Indexers\RssSyncCommand.cs" />
|
||||||
<Compile Include="Indexers\RssSyncCompleteEvent.cs" />
|
<Compile Include="Indexers\RssSyncCompleteEvent.cs" />
|
||||||
<Compile Include="Indexers\RssSyncService.cs" />
|
<Compile Include="Indexers\RssSyncService.cs" />
|
||||||
<Compile Include="Indexers\TitansOfTv\TitansOfTv.cs" />
|
|
||||||
<Compile Include="Indexers\TitansOfTv\TitansOfTvApiResult.cs" />
|
|
||||||
<Compile Include="Indexers\TitansOfTv\TitansOfTvParser.cs" />
|
|
||||||
<Compile Include="Indexers\TitansOfTv\TitansOfTvRequestGenerator.cs" />
|
|
||||||
<Compile Include="Indexers\TitansOfTv\TitansOfTvSettings.cs" />
|
|
||||||
<Compile Include="Indexers\Torrentleech\TorrentleechRequestGenerator.cs" />
|
<Compile Include="Indexers\Torrentleech\TorrentleechRequestGenerator.cs" />
|
||||||
<Compile Include="Indexers\Torrentleech\Torrentleech.cs" />
|
<Compile Include="Indexers\Torrentleech\Torrentleech.cs" />
|
||||||
<Compile Include="Indexers\Torrentleech\TorrentleechSettings.cs" />
|
<Compile Include="Indexers\Torrentleech\TorrentleechSettings.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user