mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-03-05 13:40:08 -05:00
Fixed: (PTP) Download torrent files with API credentials
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
||||
@@ -39,6 +41,18 @@ namespace NzbDrone.Core.Indexers.Definitions.PassThePopcorn
|
||||
return new PassThePopcornParser(Settings, Capabilities.Categories);
|
||||
}
|
||||
|
||||
protected override Task<HttpRequest> GetDownloadRequest(Uri link)
|
||||
{
|
||||
var requestBuilder = new HttpRequestBuilder(link.AbsoluteUri);
|
||||
|
||||
var request = requestBuilder
|
||||
.SetHeader("ApiUser", Settings.APIUser)
|
||||
.SetHeader("ApiKey", Settings.APIKey)
|
||||
.Build();
|
||||
|
||||
return Task.FromResult(request);
|
||||
}
|
||||
|
||||
private IndexerCapabilities SetCapabilities()
|
||||
{
|
||||
var caps = new IndexerCapabilities
|
||||
|
||||
@@ -5,10 +5,8 @@ namespace NzbDrone.Core.Indexers.Definitions.PassThePopcorn
|
||||
public class PassThePopcornResponse
|
||||
{
|
||||
public string TotalResults { get; set; }
|
||||
public List<PassThePopcornMovie> Movies { get; set; }
|
||||
public IReadOnlyCollection<PassThePopcornMovie> Movies { get; set; }
|
||||
public string Page { get; set; }
|
||||
public string AuthKey { get; set; }
|
||||
public string PassKey { get; set; }
|
||||
}
|
||||
|
||||
public class PassThePopcornMovie
|
||||
@@ -18,9 +16,9 @@ namespace NzbDrone.Core.Indexers.Definitions.PassThePopcorn
|
||||
public string Title { get; set; }
|
||||
public string Year { get; set; }
|
||||
public string Cover { get; set; }
|
||||
public List<string> Tags { get; set; }
|
||||
public IReadOnlyCollection<string> Tags { get; set; }
|
||||
public string ImdbId { get; set; }
|
||||
public List<PassThePopcornTorrent> Torrents { get; set; }
|
||||
public IReadOnlyCollection<PassThePopcornTorrent> Torrents { get; set; }
|
||||
}
|
||||
|
||||
public class PassThePopcornTorrent
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
@@ -95,7 +96,7 @@ namespace NzbDrone.Core.Indexers.Definitions.PassThePopcorn
|
||||
Title = title,
|
||||
Year = int.Parse(result.Year),
|
||||
InfoUrl = GetInfoUrl(result.GroupId, id),
|
||||
DownloadUrl = GetDownloadUrl(id, jsonResponse.AuthKey, jsonResponse.PassKey),
|
||||
DownloadUrl = GetDownloadUrl(id),
|
||||
Categories = _categories.MapTrackerCatToNewznab(result.CategoryId),
|
||||
Size = long.Parse(torrent.Size),
|
||||
Grabs = int.Parse(torrent.Snatched),
|
||||
@@ -109,7 +110,7 @@ namespace NzbDrone.Core.Indexers.Definitions.PassThePopcorn
|
||||
UploadVolumeFactor = uploadVolumeFactor,
|
||||
MinimumRatio = 1,
|
||||
MinimumSeedTime = 345600,
|
||||
Genres = result.Tags ?? new List<string>(),
|
||||
Genres = result.Tags?.ToList() ?? new List<string>(),
|
||||
PosterUrl = GetPosterUrl(result.Cover)
|
||||
});
|
||||
}
|
||||
@@ -120,14 +121,12 @@ namespace NzbDrone.Core.Indexers.Definitions.PassThePopcorn
|
||||
|
||||
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
||||
|
||||
private string GetDownloadUrl(int torrentId, string authKey, string passKey)
|
||||
private string GetDownloadUrl(int torrentId)
|
||||
{
|
||||
var url = new HttpUri(_settings.BaseUrl)
|
||||
.CombinePath("/torrents.php")
|
||||
.AddQueryParam("action", "download")
|
||||
.AddQueryParam("id", torrentId)
|
||||
.AddQueryParam("authkey", authKey)
|
||||
.AddQueryParam("torrent_pass", passKey);
|
||||
.AddQueryParam("id", torrentId);
|
||||
|
||||
return url.FullUri;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user