mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-10-03 01:01:34 +02:00
Fixed: (HDBits) Change TVDB search for daily shows, append slash to IndexerUrl
This commit is contained in:
@@ -10,7 +10,7 @@ using NUnit.Framework;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Indexers.HDBits;
|
||||
using NzbDrone.Core.Indexers.Definitions.HDBits;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
@@ -5,7 +5,7 @@ using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Indexers.HDBits;
|
||||
using NzbDrone.Core.Indexers.Definitions.HDBits;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
@@ -14,11 +14,13 @@ namespace NzbDrone.Core.Test.IndexerTests.HDBitsTests
|
||||
public class HDBitsRequestGeneratorFixture : CoreTest<HDBitsRequestGenerator>
|
||||
{
|
||||
private MovieSearchCriteria _movieSearchCriteria;
|
||||
private TvSearchCriteria _tvSearchSeasonEpisodeCriteria;
|
||||
private TvSearchCriteria _tvSearchDailyEpisodeCriteria;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Subject.Settings = new HDBitsSettings()
|
||||
Subject.Settings = new HDBitsSettings
|
||||
{
|
||||
ApiKey = "abcd",
|
||||
Username = "somename"
|
||||
@@ -47,9 +49,25 @@ namespace NzbDrone.Core.Test.IndexerTests.HDBitsTests
|
||||
|
||||
_movieSearchCriteria = new MovieSearchCriteria
|
||||
{
|
||||
Categories = new int[] { 2000, 2010 },
|
||||
Categories = new[] { 2000, 2010 },
|
||||
ImdbId = "0076759"
|
||||
};
|
||||
|
||||
_tvSearchSeasonEpisodeCriteria = new TvSearchCriteria
|
||||
{
|
||||
Categories = new[] { 5000, 5010 },
|
||||
TvdbId = 392256,
|
||||
Season = 1,
|
||||
Episode = "3"
|
||||
};
|
||||
|
||||
_tvSearchDailyEpisodeCriteria = new TvSearchCriteria
|
||||
{
|
||||
Categories = new[] { 5000, 5010 },
|
||||
TvdbId = 289574,
|
||||
Season = 2023,
|
||||
Episode = "01/03"
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -70,5 +88,49 @@ namespace NzbDrone.Core.Test.IndexerTests.HDBitsTests
|
||||
query.Category.Should().HaveCount(1);
|
||||
query.ImdbInfo.Id.Should().Be(imdbQuery);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_search_by_tvdbid_season_episode_if_supported()
|
||||
{
|
||||
var results = Subject.GetSearchRequests(_tvSearchSeasonEpisodeCriteria);
|
||||
var tvdbQuery = _tvSearchSeasonEpisodeCriteria.TvdbId;
|
||||
|
||||
results.GetAllTiers().Should().HaveCount(1);
|
||||
|
||||
var page = results.GetAllTiers().First().First();
|
||||
|
||||
var encoding = HttpHeader.GetEncodingFromContentType(page.HttpRequest.Headers.ContentType);
|
||||
|
||||
var body = encoding.GetString(page.HttpRequest.ContentData);
|
||||
var query = JsonConvert.DeserializeObject<TorrentQuery>(body);
|
||||
|
||||
query.Category.Should().HaveCount(3);
|
||||
query.TvdbInfo.Id.Should().Be(tvdbQuery);
|
||||
query.Search.Should().BeNullOrWhiteSpace();
|
||||
query.TvdbInfo.Season.Should().Be(1);
|
||||
query.TvdbInfo.Episode.Should().Be("3");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_search_by_tvdbid_daily_episode_if_supported()
|
||||
{
|
||||
var results = Subject.GetSearchRequests(_tvSearchDailyEpisodeCriteria);
|
||||
var tvdbQuery = _tvSearchDailyEpisodeCriteria.TvdbId;
|
||||
|
||||
results.GetAllTiers().Should().HaveCount(1);
|
||||
|
||||
var page = results.GetAllTiers().First().First();
|
||||
|
||||
var encoding = HttpHeader.GetEncodingFromContentType(page.HttpRequest.Headers.ContentType);
|
||||
|
||||
var body = encoding.GetString(page.HttpRequest.ContentData);
|
||||
var query = JsonConvert.DeserializeObject<TorrentQuery>(body);
|
||||
|
||||
query.Category.Should().HaveCount(3);
|
||||
query.TvdbInfo.Id.Should().Be(tvdbQuery);
|
||||
query.Search.Should().Be("2023-01-03");
|
||||
query.TvdbInfo.Season.Should().BeNull();
|
||||
query.TvdbInfo.Episode.Should().BeNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.HDBits
|
||||
namespace NzbDrone.Core.Indexers.Definitions.HDBits
|
||||
{
|
||||
public class HDBits : TorrentIndexerBase<HDBitsSettings>
|
||||
{
|
||||
public override string Name => "HDBits";
|
||||
public override string[] IndexerUrls => new string[] { "https://hdbits.org" };
|
||||
public override string[] IndexerUrls => new[] { "https://hdbits.org/" };
|
||||
public override string[] LegacyUrls => new[] { "https://hdbits.org" };
|
||||
public override string Description => "Best HD Tracker";
|
||||
public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
|
||||
public override IndexerPrivacy Privacy => IndexerPrivacy.Private;
|
||||
public override IndexerCapabilities Capabilities => SetCapabilities();
|
||||
public override bool SupportsRedirect => true;
|
||||
|
||||
public override int PageSize => 30;
|
||||
|
||||
public HDBits(IIndexerHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger)
|
||||
@@ -25,7 +24,7 @@ namespace NzbDrone.Core.Indexers.HDBits
|
||||
|
||||
public override IIndexerRequestGenerator GetRequestGenerator()
|
||||
{
|
||||
return new HDBitsRequestGenerator() { Settings = Settings, Capabilities = Capabilities };
|
||||
return new HDBitsRequestGenerator { Settings = Settings, Capabilities = Capabilities };
|
||||
}
|
||||
|
||||
public override IParseIndexerResponse GetParser()
|
||||
@@ -38,13 +37,13 @@ namespace NzbDrone.Core.Indexers.HDBits
|
||||
var caps = new IndexerCapabilities
|
||||
{
|
||||
TvSearchParams = new List<TvSearchParam>
|
||||
{
|
||||
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.TvdbId
|
||||
},
|
||||
{
|
||||
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.TvdbId
|
||||
},
|
||||
MovieSearchParams = new List<MovieSearchParam>
|
||||
{
|
||||
MovieSearchParam.Q, MovieSearchParam.ImdbId
|
||||
}
|
||||
{
|
||||
MovieSearchParam.Q, MovieSearchParam.ImdbId
|
||||
}
|
||||
};
|
||||
|
||||
caps.Categories.AddCategoryMapping(6, NewznabStandardCategory.Audio, "Audio Track");
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.HDBits
|
||||
namespace NzbDrone.Core.Indexers.Definitions.HDBits
|
||||
{
|
||||
public class TorrentQuery
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.HDBits
|
||||
namespace NzbDrone.Core.Indexers.Definitions.HDBits
|
||||
{
|
||||
public class HDBitsInfo : TorrentInfo
|
||||
{
|
||||
|
@@ -7,7 +7,7 @@ using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Indexers.Exceptions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.HDBits
|
||||
namespace NzbDrone.Core.Indexers.Definitions.HDBits
|
||||
{
|
||||
public class HDBitsParser : IParseIndexerResponse
|
||||
{
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using NzbDrone.Common.Extensions;
|
||||
@@ -8,7 +9,7 @@ using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.HDBits
|
||||
namespace NzbDrone.Core.Indexers.Definitions.HDBits
|
||||
{
|
||||
public class HDBitsRequestGenerator : IIndexerRequestGenerator
|
||||
{
|
||||
@@ -33,7 +34,7 @@ namespace NzbDrone.Core.Indexers.HDBits
|
||||
|
||||
if (imdbId != 0)
|
||||
{
|
||||
query.ImdbInfo = query.ImdbInfo ?? new ImdbInfo();
|
||||
query.ImdbInfo ??= new ImdbInfo();
|
||||
query.ImdbInfo.Id = imdbId;
|
||||
}
|
||||
|
||||
@@ -91,15 +92,23 @@ namespace NzbDrone.Core.Indexers.HDBits
|
||||
|
||||
if (tvdbId != 0)
|
||||
{
|
||||
query.TvdbInfo = query.TvdbInfo ?? new TvdbInfo();
|
||||
query.TvdbInfo ??= new TvdbInfo();
|
||||
query.TvdbInfo.Id = tvdbId;
|
||||
query.TvdbInfo.Season = searchCriteria.Season;
|
||||
query.TvdbInfo.Episode = searchCriteria.Episode;
|
||||
|
||||
if (DateTime.TryParseExact($"{searchCriteria.Season} {searchCriteria.Episode}", "yyyy MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var showDate))
|
||||
{
|
||||
query.Search = showDate.ToString("yyyy-MM-dd");
|
||||
}
|
||||
else
|
||||
{
|
||||
query.TvdbInfo.Season = searchCriteria.Season;
|
||||
query.TvdbInfo.Episode = searchCriteria.Episode;
|
||||
}
|
||||
}
|
||||
|
||||
if (imdbId != 0)
|
||||
{
|
||||
query.ImdbInfo = query.ImdbInfo ?? new ImdbInfo();
|
||||
query.ImdbInfo ??= new ImdbInfo();
|
||||
query.ImdbInfo.Id = imdbId;
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@ using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.Indexers.Settings;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.HDBits
|
||||
namespace NzbDrone.Core.Indexers.Definitions.HDBits
|
||||
{
|
||||
public class HDBitsSettingsValidator : NoAuthSettingsValidator<HDBitsSettings>
|
||||
{
|
||||
|
Reference in New Issue
Block a user