Fixed: (PTP) Download torrent files with API credentials

This commit is contained in:
Bogdan 2025-05-15 00:58:38 +03:00
parent 010959d915
commit 9bee9841c1
4 changed files with 19 additions and 14 deletions

View file

@ -49,7 +49,7 @@ public async Task should_parse_feed_from_PTP(string fileName)
first.Guid.Should().Be("PassThePopcorn-452135"); first.Guid.Should().Be("PassThePopcorn-452135");
first.Title.Should().Be("The.Night.Of.S01.BluRay.AAC2.0.x264-DEPTH"); first.Title.Should().Be("The.Night.Of.S01.BluRay.AAC2.0.x264-DEPTH");
first.DownloadProtocol.Should().Be(DownloadProtocol.Torrent); first.DownloadProtocol.Should().Be(DownloadProtocol.Torrent);
first.DownloadUrl.Should().Be("https://passthepopcorn.me/torrents.php?action=download&id=452135&authkey=00000000000000000000000000000000&torrent_pass=00000000000000000000000000000000"); first.DownloadUrl.Should().Be("https://passthepopcorn.me/torrents.php?action=download&id=452135");
first.InfoUrl.Should().Be("https://passthepopcorn.me/torrents.php?id=148131&torrentid=452135"); first.InfoUrl.Should().Be("https://passthepopcorn.me/torrents.php?id=148131&torrentid=452135");
first.PublishDate.Should().Be(DateTime.Parse("2016-10-18T23:40:59+0000").ToUniversalTime()); first.PublishDate.Should().Be(DateTime.Parse("2016-10-18T23:40:59+0000").ToUniversalTime());

View file

@ -33,5 +33,15 @@ public override IParseIndexerResponse GetParser()
{ {
return new PassThePopcornParser(Settings, _logger); return new PassThePopcornParser(Settings, _logger);
} }
public override HttpRequest GetDownloadRequest(string link)
{
var request = new HttpRequest(link);
request.Headers.Set("ApiUser", Settings.APIUser);
request.Headers.Set("ApiKey", Settings.APIKey);
return request;
}
} }
} }

View file

@ -6,10 +6,8 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn
public class PassThePopcornResponse public class PassThePopcornResponse
{ {
public string TotalResults { get; set; } public string TotalResults { get; set; }
public List<PassThePopcornMovie> Movies { get; set; } public IReadOnlyCollection<PassThePopcornMovie> Movies { get; set; }
public string Page { get; set; } public string Page { get; set; }
public string AuthKey { get; set; }
public string PassKey { get; set; }
} }
public class PassThePopcornMovie public class PassThePopcornMovie
@ -18,9 +16,9 @@ public class PassThePopcornMovie
public string Title { get; set; } public string Title { get; set; }
public string Year { get; set; } public string Year { get; set; }
public string Cover { 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 string ImdbId { get; set; }
public List<PassThePopcornTorrent> Torrents { get; set; } public IReadOnlyCollection<PassThePopcornTorrent> Torrents { get; set; }
} }
public class PassThePopcornTorrent public class PassThePopcornTorrent

View file

@ -75,7 +75,6 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
flags |= IndexerFlags.G_Scene; flags |= IndexerFlags.G_Scene;
} }
// Only add approved torrents
try try
{ {
torrentInfos.Add(new PassThePopcornInfo torrentInfos.Add(new PassThePopcornInfo
@ -83,7 +82,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
Guid = $"PassThePopcorn-{id}", Guid = $"PassThePopcorn-{id}",
Title = torrent.ReleaseName, Title = torrent.ReleaseName,
Size = long.Parse(torrent.Size), Size = long.Parse(torrent.Size),
DownloadUrl = GetDownloadUrl(id, jsonResponse.AuthKey, jsonResponse.PassKey), DownloadUrl = GetDownloadUrl(id),
InfoUrl = GetInfoUrl(result.GroupId, id), InfoUrl = GetInfoUrl(result.GroupId, id),
Seeders = int.Parse(torrent.Seeders), Seeders = int.Parse(torrent.Seeders),
Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders), Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders),
@ -118,16 +117,12 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
torrentInfos; torrentInfos;
} }
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; } private string GetDownloadUrl(int torrentId)
private string GetDownloadUrl(int torrentId, string authKey, string passKey)
{ {
var url = new HttpUri(_settings.BaseUrl) var url = new HttpUri(_settings.BaseUrl)
.CombinePath("/torrents.php") .CombinePath("/torrents.php")
.AddQueryParam("action", "download") .AddQueryParam("action", "download")
.AddQueryParam("id", torrentId) .AddQueryParam("id", torrentId);
.AddQueryParam("authkey", authKey)
.AddQueryParam("torrent_pass", passKey);
return url.FullUri; return url.FullUri;
} }
@ -141,5 +136,7 @@ private string GetInfoUrl(string groupId, int torrentId)
return url.FullUri; return url.FullUri;
} }
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
} }
} }