mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-04-24 13:57:11 -04:00
Fixed: (FileList) RequestGenerator refactoring, append slash to IndexerUrl
This commit is contained in:
parent
5a9d4d6280
commit
1b78fd38db
7 changed files with 155 additions and 106 deletions
|
@ -21,10 +21,15 @@ namespace NzbDrone.Core.Test.IndexerTests.FileListTests
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
Subject.Definition = new IndexerDefinition()
|
Subject.Definition = new IndexerDefinition
|
||||||
{
|
{
|
||||||
Name = "FileList",
|
Name = "FileList",
|
||||||
Settings = new FileListSettings() { Username = "someuser", Passkey = "somepass" }
|
Settings = new FileListSettings
|
||||||
|
{
|
||||||
|
BaseUrl = "https://filelist.io/",
|
||||||
|
Username = "someuser",
|
||||||
|
Passkey = "somepass"
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +40,9 @@ namespace NzbDrone.Core.Test.IndexerTests.FileListTests
|
||||||
|
|
||||||
Mocker.GetMock<IIndexerHttpClient>()
|
Mocker.GetMock<IIndexerHttpClient>()
|
||||||
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.Get), Subject.Definition))
|
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.Get), Subject.Definition))
|
||||||
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed)));
|
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader { { "Content-Type", "application/json" } }, new CookieCollection(), recentFeed)));
|
||||||
|
|
||||||
var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 } })).Releases;
|
var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new[] { 2000 } })).Releases;
|
||||||
|
|
||||||
releases.Should().HaveCount(4);
|
releases.Should().HaveCount(4);
|
||||||
releases.First().Should().BeOfType<TorrentInfo>();
|
releases.First().Should().BeOfType<TorrentInfo>();
|
||||||
|
@ -50,12 +55,14 @@ namespace NzbDrone.Core.Test.IndexerTests.FileListTests
|
||||||
torrentInfo.InfoUrl.Should().Be("https://filelist.io/details.php?id=665873");
|
torrentInfo.InfoUrl.Should().Be("https://filelist.io/details.php?id=665873");
|
||||||
torrentInfo.CommentUrl.Should().BeNullOrEmpty();
|
torrentInfo.CommentUrl.Should().BeNullOrEmpty();
|
||||||
torrentInfo.Indexer.Should().Be(Subject.Definition.Name);
|
torrentInfo.Indexer.Should().Be(Subject.Definition.Name);
|
||||||
torrentInfo.PublishDate.Should().Be(DateTime.Parse("2020-01-25 20:20:19").ToUniversalTime());
|
torrentInfo.PublishDate.Should().Be(DateTime.Parse("2020-01-25 20:20:19"));
|
||||||
torrentInfo.Size.Should().Be(8300512414);
|
torrentInfo.Size.Should().Be(8300512414);
|
||||||
torrentInfo.InfoHash.Should().Be(null);
|
torrentInfo.InfoHash.Should().Be(null);
|
||||||
torrentInfo.MagnetUrl.Should().Be(null);
|
torrentInfo.MagnetUrl.Should().Be(null);
|
||||||
torrentInfo.Peers.Should().Be(2 + 12);
|
torrentInfo.Peers.Should().Be(2 + 12);
|
||||||
torrentInfo.Seeders.Should().Be(12);
|
torrentInfo.Seeders.Should().Be(12);
|
||||||
|
|
||||||
|
releases.Any(t => t.IndexerFlags.Contains(IndexerFlag.Internal)).Should().Be(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,34 +16,35 @@ namespace NzbDrone.Core.Test.IndexerTests.FileListTests
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
Subject.Settings = new FileListSettings()
|
Subject.Settings = new FileListSettings
|
||||||
{
|
{
|
||||||
|
BaseUrl = "https://filelist.io/",
|
||||||
Passkey = "abcd",
|
Passkey = "abcd",
|
||||||
Username = "somename",
|
Username = "somename"
|
||||||
BaseUrl = "https://filelist.io"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Subject.Capabilities = new IndexerCapabilities
|
Subject.Capabilities = new IndexerCapabilities
|
||||||
{
|
{
|
||||||
TvSearchParams = new List<TvSearchParam>
|
TvSearchParams = new List<TvSearchParam>
|
||||||
{
|
{
|
||||||
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep
|
TvSearchParam.Q, TvSearchParam.ImdbId, TvSearchParam.Season, TvSearchParam.Ep
|
||||||
},
|
},
|
||||||
MovieSearchParams = new List<MovieSearchParam>
|
MovieSearchParams = new List<MovieSearchParam>
|
||||||
{
|
{
|
||||||
MovieSearchParam.Q, MovieSearchParam.ImdbId
|
MovieSearchParam.Q, MovieSearchParam.ImdbId
|
||||||
},
|
},
|
||||||
MusicSearchParams = new List<MusicSearchParam>
|
MusicSearchParams = new List<MusicSearchParam>
|
||||||
{
|
{
|
||||||
MusicSearchParam.Q
|
MusicSearchParam.Q
|
||||||
},
|
},
|
||||||
BookSearchParams = new List<BookSearchParam>
|
BookSearchParams = new List<BookSearchParam>
|
||||||
{
|
{
|
||||||
BookSearchParam.Q
|
BookSearchParam.Q
|
||||||
},
|
},
|
||||||
Flags = new List<IndexerFlag>
|
Flags = new List<IndexerFlag>
|
||||||
{
|
{
|
||||||
IndexerFlag.FreeLeech
|
IndexerFlag.FreeLeech,
|
||||||
|
IndexerFlag.Internal,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,7 +54,7 @@ namespace NzbDrone.Core.Test.IndexerTests.FileListTests
|
||||||
_movieSearchCriteria = new MovieSearchCriteria
|
_movieSearchCriteria = new MovieSearchCriteria
|
||||||
{
|
{
|
||||||
SearchTerm = "Star Wars",
|
SearchTerm = "Star Wars",
|
||||||
Categories = new int[] { 2000 }
|
Categories = new[] { 2000 }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,13 +66,13 @@ namespace NzbDrone.Core.Test.IndexerTests.FileListTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_use_categories_for_feed()
|
public void should_use_categories_for_feed()
|
||||||
{
|
{
|
||||||
var results = Subject.GetSearchRequests(new MovieSearchCriteria { Categories = new int[] { NewznabStandardCategory.MoviesSD.Id, NewznabStandardCategory.MoviesDVD.Id } });
|
var results = Subject.GetSearchRequests(new MovieSearchCriteria { Categories = new[] { NewznabStandardCategory.MoviesSD.Id, NewznabStandardCategory.MoviesDVD.Id } });
|
||||||
|
|
||||||
results.GetAllTiers().Should().HaveCount(1);
|
results.GetAllTiers().Should().HaveCount(1);
|
||||||
|
|
||||||
var page = results.GetAllTiers().First().First();
|
var page = results.GetAllTiers().First().First();
|
||||||
|
|
||||||
page.Url.Query.Should().Contain("&category=1,2&");
|
page.Url.Query.Should().Contain("&category=1%2C2");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -100,7 +101,7 @@ namespace NzbDrone.Core.Test.IndexerTests.FileListTests
|
||||||
var page = results.GetAllTiers().First().First();
|
var page = results.GetAllTiers().First().First();
|
||||||
|
|
||||||
page.Url.Query.Should().Contain("type=name");
|
page.Url.Query.Should().Contain("type=name");
|
||||||
page.Url.Query.Should().Contain("query=Star Wars");
|
page.Url.Query.Should().Contain("query=Star+Wars");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Http;
|
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
|
|
||||||
|
@ -9,7 +8,8 @@ namespace NzbDrone.Core.Indexers.FileList
|
||||||
public class FileList : TorrentIndexerBase<FileListSettings>
|
public class FileList : TorrentIndexerBase<FileListSettings>
|
||||||
{
|
{
|
||||||
public override string Name => "FileList.io";
|
public override string Name => "FileList.io";
|
||||||
public override string[] IndexerUrls => new string[] { "https://filelist.io" };
|
public override string[] IndexerUrls => new[] { "https://filelist.io/" };
|
||||||
|
public override string[] LegacyUrls => new[] { "https://filelist.io" };
|
||||||
public override string Description => "FileList (FL) is a ROMANIAN Private Torrent Tracker for 0DAY / GENERAL";
|
public override string Description => "FileList (FL) is a ROMANIAN Private Torrent Tracker for 0DAY / GENERAL";
|
||||||
public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
|
public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
|
||||||
public override IndexerPrivacy Privacy => IndexerPrivacy.Private;
|
public override IndexerPrivacy Privacy => IndexerPrivacy.Private;
|
||||||
|
@ -18,14 +18,18 @@ namespace NzbDrone.Core.Indexers.FileList
|
||||||
public override bool SupportsRedirect => true;
|
public override bool SupportsRedirect => true;
|
||||||
public override IndexerCapabilities Capabilities => SetCapabilities();
|
public override IndexerCapabilities Capabilities => SetCapabilities();
|
||||||
|
|
||||||
public FileList(IIndexerHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger)
|
public FileList(IIndexerHttpClient httpClient,
|
||||||
|
IEventAggregator eventAggregator,
|
||||||
|
IIndexerStatusService indexerStatusService,
|
||||||
|
IConfigService configService,
|
||||||
|
Logger logger)
|
||||||
: base(httpClient, eventAggregator, indexerStatusService, configService, logger)
|
: base(httpClient, eventAggregator, indexerStatusService, configService, logger)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IIndexerRequestGenerator GetRequestGenerator()
|
public override IIndexerRequestGenerator GetRequestGenerator()
|
||||||
{
|
{
|
||||||
return new FileListRequestGenerator() { Settings = Settings, Capabilities = Capabilities };
|
return new FileListRequestGenerator { Settings = Settings, Capabilities = Capabilities };
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IParseIndexerResponse GetParser()
|
public override IParseIndexerResponse GetParser()
|
||||||
|
@ -38,21 +42,21 @@ namespace NzbDrone.Core.Indexers.FileList
|
||||||
var caps = new IndexerCapabilities
|
var caps = new IndexerCapabilities
|
||||||
{
|
{
|
||||||
TvSearchParams = new List<TvSearchParam>
|
TvSearchParams = new List<TvSearchParam>
|
||||||
{
|
{
|
||||||
TvSearchParam.Q, TvSearchParam.ImdbId, TvSearchParam.Season, TvSearchParam.Ep
|
TvSearchParam.Q, TvSearchParam.ImdbId, TvSearchParam.Season, TvSearchParam.Ep
|
||||||
},
|
},
|
||||||
MovieSearchParams = new List<MovieSearchParam>
|
MovieSearchParams = new List<MovieSearchParam>
|
||||||
{
|
{
|
||||||
MovieSearchParam.Q, MovieSearchParam.ImdbId
|
MovieSearchParam.Q, MovieSearchParam.ImdbId
|
||||||
},
|
},
|
||||||
MusicSearchParams = new List<MusicSearchParam>
|
MusicSearchParams = new List<MusicSearchParam>
|
||||||
{
|
{
|
||||||
MusicSearchParam.Q
|
MusicSearchParam.Q
|
||||||
},
|
},
|
||||||
BookSearchParams = new List<BookSearchParam>
|
BookSearchParams = new List<BookSearchParam>
|
||||||
{
|
{
|
||||||
BookSearchParam.Q
|
BookSearchParam.Q
|
||||||
},
|
},
|
||||||
Flags = new List<IndexerFlag>
|
Flags = new List<IndexerFlag>
|
||||||
{
|
{
|
||||||
IndexerFlag.Internal,
|
IndexerFlag.Internal,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers.FileList
|
namespace NzbDrone.Core.Indexers.FileList
|
||||||
|
@ -24,5 +23,7 @@ namespace NzbDrone.Core.Indexers.FileList
|
||||||
[JsonProperty(PropertyName = "upload_date")]
|
[JsonProperty(PropertyName = "upload_date")]
|
||||||
public string UploadDate { get; set; }
|
public string UploadDate { get; set; }
|
||||||
public string Category { get; set; }
|
public string Category { get; set; }
|
||||||
|
[JsonProperty(PropertyName = "small_description")]
|
||||||
|
public string SmallDescription { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
|
@ -25,9 +27,12 @@ namespace NzbDrone.Core.Indexers.FileList
|
||||||
|
|
||||||
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK)
|
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
throw new IndexerException(indexerResponse,
|
throw new IndexerException(indexerResponse, "Unexpected response status {0} code from API request", indexerResponse.HttpResponse.StatusCode);
|
||||||
"Unexpected response status {0} code from API request",
|
}
|
||||||
indexerResponse.HttpResponse.StatusCode);
|
|
||||||
|
if (!indexerResponse.HttpResponse.Headers.ContentType.Contains(HttpAccept.Json.Value))
|
||||||
|
{
|
||||||
|
throw new IndexerException(indexerResponse, $"Unexpected response header {indexerResponse.HttpResponse.Headers.ContentType} from API request, expected {HttpAccept.Json.Value}");
|
||||||
}
|
}
|
||||||
|
|
||||||
var queryResults = JsonConvert.DeserializeObject<List<FileListTorrent>>(indexerResponse.Content);
|
var queryResults = JsonConvert.DeserializeObject<List<FileListTorrent>>(indexerResponse.Content);
|
||||||
|
@ -49,10 +54,10 @@ namespace NzbDrone.Core.Indexers.FileList
|
||||||
imdbId = int.Parse(result.ImdbId.Substring(2));
|
imdbId = int.Parse(result.ImdbId.Substring(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
var downloadVolumeFactor = result.FreeLeech == true ? 0 : 1;
|
var downloadVolumeFactor = result.FreeLeech ? 0 : 1;
|
||||||
var uploadVolumeFactor = result.DoubleUp == true ? 2 : 1;
|
var uploadVolumeFactor = result.DoubleUp ? 2 : 1;
|
||||||
|
|
||||||
torrentInfos.Add(new TorrentInfo()
|
torrentInfos.Add(new TorrentInfo
|
||||||
{
|
{
|
||||||
Guid = string.Format("FileList-{0}", id),
|
Guid = string.Format("FileList-{0}", id),
|
||||||
Title = result.Name,
|
Title = result.Name,
|
||||||
|
@ -62,7 +67,9 @@ namespace NzbDrone.Core.Indexers.FileList
|
||||||
InfoUrl = GetInfoUrl(id),
|
InfoUrl = GetInfoUrl(id),
|
||||||
Seeders = result.Seeders,
|
Seeders = result.Seeders,
|
||||||
Peers = result.Leechers + result.Seeders,
|
Peers = result.Leechers + result.Seeders,
|
||||||
PublishDate = DateTime.Parse(result.UploadDate + " +0200"),
|
PublishDate = DateTime.Parse(result.UploadDate + " +0200", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal),
|
||||||
|
Description = result.SmallDescription,
|
||||||
|
Genres = result.SmallDescription.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries).ToList(),
|
||||||
ImdbId = imdbId,
|
ImdbId = imdbId,
|
||||||
IndexerFlags = flags,
|
IndexerFlags = flags,
|
||||||
Files = (int)result.Files,
|
Files = (int)result.Files,
|
||||||
|
@ -70,7 +77,7 @@ namespace NzbDrone.Core.Indexers.FileList
|
||||||
DownloadVolumeFactor = downloadVolumeFactor,
|
DownloadVolumeFactor = downloadVolumeFactor,
|
||||||
UploadVolumeFactor = uploadVolumeFactor,
|
UploadVolumeFactor = uploadVolumeFactor,
|
||||||
MinimumRatio = 1,
|
MinimumRatio = 1,
|
||||||
MinimumSeedTime = 172800, //48 hours
|
MinimumSeedTime = 172800, // 48 hours
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||||
|
using NzbDrone.Core.Parser;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers.FileList
|
namespace NzbDrone.Core.Indexers.FileList
|
||||||
{
|
{
|
||||||
|
@ -13,60 +15,74 @@ namespace NzbDrone.Core.Indexers.FileList
|
||||||
public Func<IDictionary<string, string>> GetCookies { get; set; }
|
public Func<IDictionary<string, string>> GetCookies { get; set; }
|
||||||
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
||||||
|
|
||||||
|
public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria)
|
||||||
|
{
|
||||||
|
var pageableRequests = new IndexerPageableRequestChain();
|
||||||
|
var parameters = GetDefaultParameters();
|
||||||
|
|
||||||
|
if (searchCriteria.ImdbId.IsNotNullOrWhiteSpace() || searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
parameters.Add("action", "search-torrents");
|
||||||
|
|
||||||
|
if (searchCriteria.ImdbId.IsNotNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
parameters.Add("type", "imdb");
|
||||||
|
parameters.Add("query", searchCriteria.FullImdbId);
|
||||||
|
}
|
||||||
|
else if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
parameters.Add("type", "name");
|
||||||
|
parameters.Add("query", searchCriteria.SanitizedSearchTerm.Trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchCriteria.Season.HasValue)
|
||||||
|
{
|
||||||
|
parameters.Add("season", searchCriteria.Season.ToString());
|
||||||
|
parameters.Add("episode", searchCriteria.Episode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pageableRequests.Add(GetRequest(searchCriteria, parameters));
|
||||||
|
|
||||||
|
return pageableRequests;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
|
public virtual IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
|
||||||
{
|
{
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
var pageableRequests = new IndexerPageableRequestChain();
|
||||||
|
var parameters = GetDefaultParameters();
|
||||||
|
|
||||||
if (searchCriteria.ImdbId.IsNotNullOrWhiteSpace())
|
if (searchCriteria.ImdbId.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
pageableRequests.Add(GetRequest("search-torrents", searchCriteria.Categories, string.Format("&type=imdb&query={0}", searchCriteria.FullImdbId)));
|
parameters.Add("action", "search-torrents");
|
||||||
|
parameters.Add("type", "imdb");
|
||||||
|
parameters.Add("query", searchCriteria.FullImdbId);
|
||||||
}
|
}
|
||||||
else if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
else if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
var titleYearSearchQuery = string.Format("{0}", searchCriteria.SanitizedSearchTerm);
|
parameters.Add("action", "search-torrents");
|
||||||
pageableRequests.Add(GetRequest("search-torrents", searchCriteria.Categories, string.Format("&type=name&query={0}", titleYearSearchQuery.Trim())));
|
parameters.Add("type", "name");
|
||||||
}
|
parameters.Add("query", searchCriteria.SanitizedSearchTerm.Trim());
|
||||||
else
|
|
||||||
{
|
|
||||||
pageableRequests.Add(GetRequest("latest-torrents", searchCriteria.Categories, ""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pageableRequests.Add(GetRequest(searchCriteria, parameters));
|
||||||
|
|
||||||
return pageableRequests;
|
return pageableRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria)
|
public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria)
|
||||||
{
|
{
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
var pageableRequests = new IndexerPageableRequestChain();
|
||||||
|
var parameters = GetDefaultParameters();
|
||||||
|
|
||||||
if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
var titleYearSearchQuery = string.Format("{0}", searchCriteria.SanitizedSearchTerm);
|
parameters.Add("action", "search-torrents");
|
||||||
pageableRequests.Add(GetRequest("search-torrents", searchCriteria.Categories, string.Format("&type=name&query={0}", titleYearSearchQuery.Trim())));
|
parameters.Add("type", "name");
|
||||||
}
|
parameters.Add("query", searchCriteria.SanitizedSearchTerm.Trim());
|
||||||
else
|
|
||||||
{
|
|
||||||
pageableRequests.Add(GetRequest("latest-torrents", searchCriteria.Categories, ""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pageableRequests;
|
pageableRequests.Add(GetRequest(searchCriteria, parameters));
|
||||||
}
|
|
||||||
|
|
||||||
public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria)
|
|
||||||
{
|
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
|
||||||
|
|
||||||
if (searchCriteria.ImdbId.IsNotNullOrWhiteSpace())
|
|
||||||
{
|
|
||||||
pageableRequests.Add(GetRequest("search-torrents", searchCriteria.Categories, string.Format("&type=imdb&query={0}&season={1}&episode={2}", searchCriteria.FullImdbId, searchCriteria.Season, searchCriteria.Episode)));
|
|
||||||
}
|
|
||||||
else if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
|
||||||
{
|
|
||||||
var titleYearSearchQuery = string.Format("{0}", searchCriteria.SanitizedSearchTerm);
|
|
||||||
pageableRequests.Add(GetRequest("search-torrents", searchCriteria.Categories, string.Format("&type=name&query={0}&season={1}&episode={2}", titleYearSearchQuery.Trim(), searchCriteria.Season, searchCriteria.Episode)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pageableRequests.Add(GetRequest("latest-torrents", searchCriteria.Categories, ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
return pageableRequests;
|
return pageableRequests;
|
||||||
}
|
}
|
||||||
|
@ -74,47 +90,65 @@ namespace NzbDrone.Core.Indexers.FileList
|
||||||
public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria)
|
public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria)
|
||||||
{
|
{
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
var pageableRequests = new IndexerPageableRequestChain();
|
||||||
|
var parameters = GetDefaultParameters();
|
||||||
|
|
||||||
if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
var titleYearSearchQuery = string.Format("{0}", searchCriteria.SanitizedSearchTerm);
|
parameters.Add("action", "search-torrents");
|
||||||
pageableRequests.Add(GetRequest("search-torrents", searchCriteria.Categories, string.Format("&type=name&query={0}", titleYearSearchQuery.Trim())));
|
parameters.Add("type", "name");
|
||||||
}
|
parameters.Add("query", searchCriteria.SanitizedSearchTerm.Trim());
|
||||||
else
|
|
||||||
{
|
|
||||||
pageableRequests.Add(GetRequest("latest-torrents", searchCriteria.Categories, ""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pageableRequests.Add(GetRequest(searchCriteria, parameters));
|
||||||
|
|
||||||
return pageableRequests;
|
return pageableRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria)
|
public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria)
|
||||||
{
|
{
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
var pageableRequests = new IndexerPageableRequestChain();
|
||||||
|
var parameters = GetDefaultParameters();
|
||||||
|
|
||||||
if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
var titleYearSearchQuery = string.Format("{0}", searchCriteria.SanitizedSearchTerm);
|
parameters.Add("action", "search-torrents");
|
||||||
pageableRequests.Add(GetRequest("search-torrents", searchCriteria.Categories, string.Format("&type=name&query={0}", titleYearSearchQuery.Trim())));
|
parameters.Add("type", "name");
|
||||||
}
|
parameters.Add("query", searchCriteria.SanitizedSearchTerm.Trim());
|
||||||
else
|
|
||||||
{
|
|
||||||
pageableRequests.Add(GetRequest("latest-torrents", searchCriteria.Categories, ""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pageableRequests.Add(GetRequest(searchCriteria, parameters));
|
||||||
|
|
||||||
return pageableRequests;
|
return pageableRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<IndexerRequest> GetRequest(string searchType, int[] categories, string parameters)
|
private IEnumerable<IndexerRequest> GetRequest(SearchCriteriaBase searchCriteria, NameValueCollection parameters)
|
||||||
{
|
{
|
||||||
var categoriesQuery = string.Join(",", Capabilities.Categories.MapTorznabCapsToTrackers(categories));
|
if (parameters.Get("action") is null)
|
||||||
|
{
|
||||||
|
parameters.Add("action", "latest-torrents");
|
||||||
|
}
|
||||||
|
|
||||||
var baseUrl = string.Format("{0}/api.php?action={1}&category={2}&username={3}&passkey={4}{5}", Settings.BaseUrl.TrimEnd('/'), searchType, categoriesQuery, Settings.Username.Trim(), Settings.Passkey.Trim(), parameters);
|
parameters.Add("category", string.Join(",", Capabilities.Categories.MapTorznabCapsToTrackers(searchCriteria.Categories)));
|
||||||
|
|
||||||
|
var searchUrl = $"{Settings.BaseUrl.TrimEnd('/')}/api.php?{parameters.GetQueryString()}";
|
||||||
|
|
||||||
|
yield return new IndexerRequest(searchUrl, HttpAccept.Json);
|
||||||
|
}
|
||||||
|
|
||||||
|
private NameValueCollection GetDefaultParameters()
|
||||||
|
{
|
||||||
|
var parameters = new NameValueCollection
|
||||||
|
{
|
||||||
|
{ "username", Settings.Username.Trim() },
|
||||||
|
{ "passkey", Settings.Passkey.Trim() }
|
||||||
|
};
|
||||||
|
|
||||||
if (Settings.FreeleechOnly)
|
if (Settings.FreeleechOnly)
|
||||||
{
|
{
|
||||||
baseUrl += "&freeleech=1";
|
parameters.Add("freeleech", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return new IndexerRequest(baseUrl, HttpAccept.Json);
|
return parameters;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,7 @@ namespace NzbDrone.Core.Indexers.FileList
|
||||||
|
|
||||||
public class FileListSettings : NoAuthTorrentBaseSettings
|
public class FileListSettings : NoAuthTorrentBaseSettings
|
||||||
{
|
{
|
||||||
private static readonly FileListSettingsValidator Validator = new FileListSettingsValidator();
|
private static readonly FileListSettingsValidator Validator = new ();
|
||||||
|
|
||||||
public FileListSettings()
|
|
||||||
{
|
|
||||||
BaseUrl = "https://filelist.io";
|
|
||||||
}
|
|
||||||
|
|
||||||
[FieldDefinition(2, Label = "Username", HelpText = "Site Username", Privacy = PrivacyLevel.UserName)]
|
[FieldDefinition(2, Label = "Username", HelpText = "Site Username", Privacy = PrivacyLevel.UserName)]
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue