Fixed: (Headphones) Use custom download request

Closes #3595
pull/3603/head
Bogdan 2 years ago
parent bfe917a09e
commit d317c3dd60

@ -20,10 +20,10 @@ namespace NzbDrone.Core.Test.IndexerTests.HeadphonesTests
[SetUp]
public void Setup()
{
Subject.Definition = new IndexerDefinition()
Subject.Definition = new IndexerDefinition
{
Name = "Headphones VIP",
Settings = new HeadphonesSettings()
Settings = new HeadphonesSettings
{
Categories = new int[] { 3000 },
Username = "user",
@ -51,12 +51,11 @@ namespace NzbDrone.Core.Test.IndexerTests.HeadphonesTests
releases.Should().HaveCount(16);
releases.First().Should().BeOfType<ReleaseInfo>();
var releaseInfo = releases.First() as ReleaseInfo;
var releaseInfo = releases.First();
releaseInfo.Title.Should().Be("Lady Gaga Born This Way 2CD FLAC 2011 WRE");
releaseInfo.DownloadProtocol.Should().Be(DownloadProtocol.Usenet);
releaseInfo.DownloadUrl.Should().Be("https://indexer.codeshy.com/api?t=g&guid=123456&apikey=123456789");
releaseInfo.BasicAuthString.Should().Be("dXNlcjpwYXNz");
releaseInfo.Indexer.Should().Be(Subject.Definition.Name);
releaseInfo.PublishDate.Should().Be(DateTime.Parse("2013/06/02 08:58:54"));
releaseInfo.Size.Should().Be(917347414);

@ -47,12 +47,6 @@ namespace NzbDrone.Core.Download
var request = indexer?.GetDownloadRequest(url) ?? new HttpRequest(url);
request.RateLimitKey = remoteAlbum?.Release?.IndexerId.ToString();
// TODO: Look into moving download request handling to indexer
if (remoteAlbum.Release.BasicAuthString.IsNotNullOrWhiteSpace())
{
request.Headers.Set("Authorization", "Basic " + remoteAlbum.Release.BasicAuthString);
}
nzbData = _httpClient.Get(request).ResponseData;
_logger.Debug("Downloaded nzb for release '{0}' finished ({1} bytes from {2})", remoteAlbum.Release.Title, nzbData.Length, url);

@ -6,6 +6,7 @@ using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Core.Parser;
namespace NzbDrone.Core.Indexers.Headphones
@ -20,6 +21,12 @@ namespace NzbDrone.Core.Indexers.Headphones
public override int PageSize => _capabilitiesProvider.GetCapabilities(Settings).DefaultPageSize;
public Headphones(IHeadphonesCapabilitiesProvider capabilitiesProvider, IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
: base(httpClient, indexerStatusService, configService, parsingService, logger)
{
_capabilitiesProvider = capabilitiesProvider;
}
public override IIndexerRequestGenerator GetRequestGenerator()
{
return new HeadphonesRequestGenerator(_capabilitiesProvider)
@ -31,16 +38,17 @@ namespace NzbDrone.Core.Indexers.Headphones
public override IParseIndexerResponse GetParser()
{
return new HeadphonesRssParser
{
Settings = Settings
};
return new NewznabRssParser();
}
public Headphones(IHeadphonesCapabilitiesProvider capabilitiesProvider, IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
: base(httpClient, indexerStatusService, configService, parsingService, logger)
public override HttpRequest GetDownloadRequest(string link)
{
_capabilitiesProvider = capabilitiesProvider;
var request = new HttpRequest(link)
{
Credentials = new BasicNetworkCredential(Settings.Username, Settings.Password)
};
return request;
}
protected override void Test(List<ValidationFailure> failures)

@ -1,22 +0,0 @@
using System;
using System.Text;
using NzbDrone.Core.Indexers.Newznab;
namespace NzbDrone.Core.Indexers.Headphones
{
public class HeadphonesRssParser : NewznabRssParser
{
public HeadphonesSettings Settings { get; set; }
public HeadphonesRssParser()
{
PreferredEnclosureMimeTypes = UsenetEnclosureMimeTypes;
UseEnclosureUrl = true;
}
protected override string GetBasicAuth()
{
return Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes($"{Settings.Username}:{Settings.Password}"));
}
}
}

@ -156,7 +156,6 @@ namespace NzbDrone.Core.Indexers
releaseInfo.Title = GetTitle(item);
releaseInfo.PublishDate = GetPublishDate(item);
releaseInfo.DownloadUrl = GetDownloadUrl(item);
releaseInfo.BasicAuthString = GetBasicAuth();
releaseInfo.InfoUrl = GetInfoUrl(item);
releaseInfo.CommentUrl = GetCommentUrl(item);
@ -199,11 +198,6 @@ namespace NzbDrone.Core.Indexers
return XElementExtensions.ParseDate(dateString);
}
protected virtual string GetBasicAuth()
{
return null;
}
protected virtual string GetDownloadUrl(XElement item)
{
if (UseEnclosureUrl)

@ -10,7 +10,6 @@ namespace NzbDrone.Core.Parser.Model
public string Title { get; set; }
public long Size { get; set; }
public string DownloadUrl { get; set; }
public string BasicAuthString { get; set; }
public string InfoUrl { get; set; }
public string CommentUrl { get; set; }
public int IndexerId { get; set; }

Loading…
Cancel
Save