Fixed: HDBits and Filelist

pull/18/head
Qstick 4 years ago
parent 5833549535
commit 3cb436898a

@ -1,3 +1,4 @@
using System.Collections.Generic;
using NLog; using NLog;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
@ -12,6 +13,8 @@ namespace NzbDrone.Core.Indexers.FileList
public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerPrivacy Privacy => IndexerPrivacy.Private;
public override bool SupportsRss => true; public override bool SupportsRss => true;
public override bool SupportsSearch => true; public override bool SupportsSearch => true;
public override bool SupportsRedirect => true;
public override IndexerCapabilities Capabilities => SetCapabilities();
public FileList(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) public FileList(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger)
: base(httpClient, indexerStatusService, configService, logger) : base(httpClient, indexerStatusService, configService, logger)
@ -27,5 +30,57 @@ namespace NzbDrone.Core.Indexers.FileList
{ {
return new FileListParser(Settings, BaseUrl); return new FileListParser(Settings, BaseUrl);
} }
private IndexerCapabilities SetCapabilities()
{
var caps = new IndexerCapabilities
{
TvSearchParams = new List<TvSearchParam>
{
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep
},
MovieSearchParams = new List<MovieSearchParam>
{
MovieSearchParam.Q, MovieSearchParam.ImdbId
},
MusicSearchParams = new List<MusicSearchParam>
{
MusicSearchParam.Q
},
BookSearchParams = new List<BookSearchParam>
{
BookSearchParam.Q
}
};
caps.Categories.AddCategoryMapping(1, NewznabStandardCategory.MoviesSD, "Filme SD");
caps.Categories.AddCategoryMapping(2, NewznabStandardCategory.MoviesDVD, "Filme DVD");
caps.Categories.AddCategoryMapping(3, NewznabStandardCategory.MoviesForeign, "Filme DVD-RO");
caps.Categories.AddCategoryMapping(4, NewznabStandardCategory.MoviesHD, "Filme HD");
caps.Categories.AddCategoryMapping(5, NewznabStandardCategory.AudioLossless, "FLAC");
caps.Categories.AddCategoryMapping(6, NewznabStandardCategory.MoviesUHD, "Filme 4K");
caps.Categories.AddCategoryMapping(7, NewznabStandardCategory.XXX, "XXX");
caps.Categories.AddCategoryMapping(8, NewznabStandardCategory.PC, "Programe");
caps.Categories.AddCategoryMapping(9, NewznabStandardCategory.PCGames, "Jocuri PC");
caps.Categories.AddCategoryMapping(10, NewznabStandardCategory.Console, "Jocuri Console");
caps.Categories.AddCategoryMapping(11, NewznabStandardCategory.Audio, "Audio");
caps.Categories.AddCategoryMapping(12, NewznabStandardCategory.AudioVideo, "Videoclip");
caps.Categories.AddCategoryMapping(13, NewznabStandardCategory.TVSport, "Sport");
caps.Categories.AddCategoryMapping(15, NewznabStandardCategory.TV, "Desene");
caps.Categories.AddCategoryMapping(16, NewznabStandardCategory.Books, "Docs");
caps.Categories.AddCategoryMapping(17, NewznabStandardCategory.PC, "Linux");
caps.Categories.AddCategoryMapping(18, NewznabStandardCategory.Other, "Diverse");
caps.Categories.AddCategoryMapping(19, NewznabStandardCategory.MoviesForeign, "Filme HD-RO");
caps.Categories.AddCategoryMapping(20, NewznabStandardCategory.MoviesBluRay, "Filme Blu-Ray");
caps.Categories.AddCategoryMapping(21, NewznabStandardCategory.TVHD, "Seriale HD");
caps.Categories.AddCategoryMapping(22, NewznabStandardCategory.PCMobileOther, "Mobile");
caps.Categories.AddCategoryMapping(23, NewznabStandardCategory.TVSD, "Seriale SD");
caps.Categories.AddCategoryMapping(24, NewznabStandardCategory.TVAnime, "Anime");
caps.Categories.AddCategoryMapping(25, NewznabStandardCategory.Movies3D, "Filme 3D");
caps.Categories.AddCategoryMapping(26, NewznabStandardCategory.MoviesBluRay, "Filme 4K Blu-Ray");
caps.Categories.AddCategoryMapping(27, NewznabStandardCategory.TVUHD, "Seriale 4K");
return caps;
}
} }
} }

@ -18,6 +18,8 @@ namespace NzbDrone.Core.Indexers.FileList
public string ImdbId { get; set; } public string ImdbId { get; set; }
[JsonProperty(PropertyName = "freeleech")] [JsonProperty(PropertyName = "freeleech")]
public bool FreeLeech { get; set; } public bool FreeLeech { get; set; }
[JsonProperty(PropertyName = "doubleup")]
public bool DoubleUp { get; set; }
[JsonProperty(PropertyName = "upload_date")] [JsonProperty(PropertyName = "upload_date")]
public DateTime UploadDate { get; set; } public DateTime UploadDate { get; set; }
} }

@ -49,6 +49,9 @@ 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 uploadVolumeFactor = result.DoubleUp == true ? 2 : 1;
torrentInfos.Add(new TorrentInfo() torrentInfos.Add(new TorrentInfo()
{ {
Guid = string.Format("FileList-{0}", id), Guid = string.Format("FileList-{0}", id),
@ -60,7 +63,13 @@ namespace NzbDrone.Core.Indexers.FileList
Peers = result.Leechers + result.Seeders, Peers = result.Leechers + result.Seeders,
PublishDate = result.UploadDate, PublishDate = result.UploadDate,
ImdbId = imdbId, ImdbId = imdbId,
IndexerFlags = flags IndexerFlags = flags,
Files = (int)result.Files,
Grabs = (int)result.TimesCompleted,
DownloadVolumeFactor = downloadVolumeFactor,
UploadVolumeFactor = uploadVolumeFactor,
MinimumRatio = 1,
MinimumSeedTime = 172800, //48 hours
}); });
} }

@ -24,7 +24,7 @@ namespace NzbDrone.Core.Indexers.FileList
} }
else if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace()) else if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
{ {
var titleYearSearchQuery = string.Format("{0}", searchCriteria.SearchTerm); var titleYearSearchQuery = string.Format("{0}", searchCriteria.SanitizedSearchTerm);
pageableRequests.Add(GetRequest("search-torrents", searchCriteria.Categories, string.Format("&type=name&query={0}", titleYearSearchQuery.Trim()))); pageableRequests.Add(GetRequest("search-torrents", searchCriteria.Categories, string.Format("&type=name&query={0}", titleYearSearchQuery.Trim())));
} }
else else
@ -37,22 +37,71 @@ namespace NzbDrone.Core.Indexers.FileList
public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria) public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria)
{ {
return new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
{
var titleYearSearchQuery = string.Format("{0}", searchCriteria.SanitizedSearchTerm);
pageableRequests.Add(GetRequest("search-torrents", searchCriteria.Categories, string.Format("&type=name&query={0}", titleYearSearchQuery.Trim())));
}
else
{
pageableRequests.Add(GetRequest("latest-torrents", searchCriteria.Categories, ""));
}
return pageableRequests;
} }
public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria) public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria)
{ {
return new IndexerPageableRequestChain(); 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.ImdbId, 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;
} }
public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria)
{ {
return new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
{
var titleYearSearchQuery = string.Format("{0}", searchCriteria.SanitizedSearchTerm);
pageableRequests.Add(GetRequest("search-torrents", searchCriteria.Categories, string.Format("&type=name&query={0}", titleYearSearchQuery.Trim())));
}
else
{
pageableRequests.Add(GetRequest("latest-torrents", searchCriteria.Categories, ""));
}
return pageableRequests;
} }
public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria) public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria)
{ {
return new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
{
var titleYearSearchQuery = string.Format("{0}", searchCriteria.SanitizedSearchTerm);
pageableRequests.Add(GetRequest("search-torrents", searchCriteria.Categories, string.Format("&type=name&query={0}", titleYearSearchQuery.Trim())));
}
else
{
pageableRequests.Add(GetRequest("latest-torrents", searchCriteria.Categories, ""));
}
return pageableRequests;
} }
private IEnumerable<IndexerRequest> GetRequest(string searchType, int[] categories, string parameters) private IEnumerable<IndexerRequest> GetRequest(string searchType, int[] categories, string parameters)

@ -1,3 +1,4 @@
using System.Collections.Generic;
using NLog; using NLog;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
@ -10,6 +11,8 @@ namespace NzbDrone.Core.Indexers.HDBits
public override string BaseUrl => "https://hdbits.org"; public override string BaseUrl => "https://hdbits.org";
public override DownloadProtocol Protocol => DownloadProtocol.Torrent; public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerPrivacy Privacy => IndexerPrivacy.Private;
public override IndexerCapabilities Capabilities => SetCapabilities();
public override bool SupportsRedirect => true;
public override int PageSize => 30; public override int PageSize => 30;
@ -27,5 +30,31 @@ namespace NzbDrone.Core.Indexers.HDBits
{ {
return new HDBitsParser(Settings, BaseUrl); return new HDBitsParser(Settings, BaseUrl);
} }
private IndexerCapabilities SetCapabilities()
{
var caps = new IndexerCapabilities
{
TvSearchParams = new List<TvSearchParam>
{
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.TvdbId
},
MovieSearchParams = new List<MovieSearchParam>
{
MovieSearchParam.Q, MovieSearchParam.ImdbId
}
};
caps.Categories.AddCategoryMapping(6, NewznabStandardCategory.Audio, "Audio Track");
caps.Categories.AddCategoryMapping(3, NewznabStandardCategory.TVDocumentary, "Documentary");
caps.Categories.AddCategoryMapping(8, NewznabStandardCategory.Other, "Misc/Demo");
caps.Categories.AddCategoryMapping(1, NewznabStandardCategory.Movies, "Movie");
caps.Categories.AddCategoryMapping(4, NewznabStandardCategory.Audio, "Music");
caps.Categories.AddCategoryMapping(5, NewznabStandardCategory.TVSport, "Sport");
caps.Categories.AddCategoryMapping(2, NewznabStandardCategory.TV, "TV");
caps.Categories.AddCategoryMapping(7, NewznabStandardCategory.XXX, "XXX");
return caps;
}
} }
} }

@ -1,4 +1,4 @@
using System; using System;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace NzbDrone.Core.Indexers.HDBits namespace NzbDrone.Core.Indexers.HDBits
@ -113,7 +113,7 @@ namespace NzbDrone.Core.Indexers.HDBits
{ {
public int? Id { get; set; } public int? Id { get; set; }
public int? Season { get; set; } public int? Season { get; set; }
public int? Episode { get; set; } public string Episode { get; set; }
} }
public enum StatusCode public enum StatusCode

@ -76,10 +76,13 @@ namespace NzbDrone.Core.Indexers.HDBits
DownloadUrl = GetDownloadUrl(id), DownloadUrl = GetDownloadUrl(id),
InfoUrl = GetInfoUrl(id), InfoUrl = GetInfoUrl(id),
Seeders = result.Seeders, Seeders = result.Seeders,
Grabs = (int)result.TimesCompleted,
Files = (int)result.NumFiles,
Peers = result.Leechers + result.Seeders, Peers = result.Leechers + result.Seeders,
PublishDate = result.Added.ToUniversalTime(), PublishDate = result.Added.ToUniversalTime(),
Internal = internalRelease, Internal = internalRelease,
ImdbId = result.ImdbInfo?.Id ?? 0, ImdbId = result.ImdbInfo?.Id ?? 0,
TvdbId = result.TvdbInfo?.Id ?? 0,
IndexerFlags = flags IndexerFlags = flags
}); });
} }

@ -10,6 +10,7 @@ namespace NzbDrone.Core.Indexers.HDBits
{ {
public class HDBitsRequestGenerator : IIndexerRequestGenerator public class HDBitsRequestGenerator : IIndexerRequestGenerator
{ {
public IndexerCapabilities Capabilities { get; set; }
public HDBitsSettings Settings { get; set; } public HDBitsSettings Settings { get; set; }
public string BaseUrl { get; set; } public string BaseUrl { get; set; }
@ -18,19 +19,14 @@ namespace NzbDrone.Core.Indexers.HDBits
var pageableRequests = new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
var query = new TorrentQuery(); var query = new TorrentQuery();
if (TryAddSearchParameters(query, searchCriteria)) if (searchCriteria.Categories.Length > 0)
{ {
pageableRequests.Add(GetRequest(query)); query.Category = Capabilities.Categories.MapTorznabCapsToTrackers(searchCriteria.Categories).Select(int.Parse).ToArray();
} }
return pageableRequests; if (searchCriteria.ImdbId.IsNullOrWhiteSpace() && searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
}
private bool TryAddSearchParameters(TorrentQuery query, MovieSearchCriteria searchCriteria)
{
if (searchCriteria.ImdbId.IsNullOrWhiteSpace())
{ {
return false; query.Search = searchCriteria.SanitizedSearchTerm;
} }
var imdbId = int.Parse(searchCriteria.ImdbId.Substring(2)); var imdbId = int.Parse(searchCriteria.ImdbId.Substring(2));
@ -39,13 +35,11 @@ namespace NzbDrone.Core.Indexers.HDBits
{ {
query.ImdbInfo = query.ImdbInfo ?? new ImdbInfo(); query.ImdbInfo = query.ImdbInfo ?? new ImdbInfo();
query.ImdbInfo.Id = imdbId; query.ImdbInfo.Id = imdbId;
//TODO Map Categories
query.Category = searchCriteria.Categories;
return true;
} }
return false; pageableRequests.Add(GetRequest(query));
return pageableRequests;
} }
public Func<IDictionary<string, string>> GetCookies { get; set; } public Func<IDictionary<string, string>> GetCookies { get; set; }
@ -82,7 +76,32 @@ namespace NzbDrone.Core.Indexers.HDBits
public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria) public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria)
{ {
return new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
var query = new TorrentQuery();
if (searchCriteria.Categories.Length > 0)
{
query.Category = Capabilities.Categories.MapTorznabCapsToTrackers(searchCriteria.Categories).Select(int.Parse).ToArray();
}
if (searchCriteria.TvdbId == 0 && searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
{
query.Search = (searchCriteria.SanitizedSearchTerm + " " + searchCriteria.EpisodeSearchString).Trim();
}
var tvdbId = searchCriteria.TvdbId;
if (tvdbId != 0)
{
query.TvdbInfo = query.TvdbInfo ?? new TvdbInfo();
query.TvdbInfo.Id = tvdbId;
query.TvdbInfo.Season = searchCriteria.Season;
query.TvdbInfo.Episode = searchCriteria.Episode;
}
pageableRequests.Add(GetRequest(query));
return pageableRequests;
} }
public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria)
@ -92,7 +111,22 @@ namespace NzbDrone.Core.Indexers.HDBits
public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria) public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria)
{ {
return new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
var query = new TorrentQuery();
if (searchCriteria.Categories.Length > 0)
{
query.Category = Capabilities.Categories.MapTorznabCapsToTrackers(searchCriteria.Categories).Select(int.Parse).ToArray();
}
if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
{
query.Search = searchCriteria.SanitizedSearchTerm;
}
pageableRequests.Add(GetRequest(query));
return pageableRequests;
} }
} }
} }

@ -220,6 +220,7 @@
"EnableCompletedDownloadHandlingHelpText": "Automatically import completed downloads from download client", "EnableCompletedDownloadHandlingHelpText": "Automatically import completed downloads from download client",
"EnabledHelpText": "Enable this list for use in Prowlarr", "EnabledHelpText": "Enable this list for use in Prowlarr",
"EnableHelpText": "Enable metadata file creation for this metadata type", "EnableHelpText": "Enable metadata file creation for this metadata type",
"EnableIndexer": "Enable Indexer",
"EnableInteractiveSearch": "Enable Interactive Search", "EnableInteractiveSearch": "Enable Interactive Search",
"EnableInteractiveSearchHelpText": "Will be used when interactive search is used", "EnableInteractiveSearchHelpText": "Will be used when interactive search is used",
"EnableInteractiveSearchHelpTextWarning": "Search is not supported with this indexer", "EnableInteractiveSearchHelpTextWarning": "Search is not supported with this indexer",
@ -336,6 +337,7 @@
"IndexerLongTermStatusCheckSingleClientMessage": "Indexers unavailable due to failures for more than 6 hours: {0}", "IndexerLongTermStatusCheckSingleClientMessage": "Indexers unavailable due to failures for more than 6 hours: {0}",
"IndexerPriority": "Indexer Priority", "IndexerPriority": "Indexer Priority",
"IndexerPriorityHelpText": "Indexer Priority from 1 (Highest) to 50 (Lowest). Default: 25.", "IndexerPriorityHelpText": "Indexer Priority from 1 (Highest) to 50 (Lowest). Default: 25.",
"IndexerQuery": "Indexer Query",
"IndexerRssHealthCheckNoAvailableIndexers": "All rss-capable indexers are temporarily unavailable due to recent indexer errors", "IndexerRssHealthCheckNoAvailableIndexers": "All rss-capable indexers are temporarily unavailable due to recent indexer errors",
"IndexerRssHealthCheckNoIndexers": "No indexers available with RSS sync enabled, Prowlarr will not grab new releases automatically", "IndexerRssHealthCheckNoIndexers": "No indexers available with RSS sync enabled, Prowlarr will not grab new releases automatically",
"Indexers": "Indexers", "Indexers": "Indexers",

@ -4,7 +4,6 @@ using System.Net;
using System.Text; using System.Text;
using Nancy; using Nancy;
using Nancy.ModelBinding; using Nancy.ModelBinding;
using Nancy.Responses;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers;
using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.IndexerSearch;

Loading…
Cancel
Save