Implement `AddTorrentFromUrl`

This commit is contained in:
Michael Feinbier 2023-09-17 12:18:17 +02:00
parent c77566fc43
commit 9bff767feb
2 changed files with 24 additions and 4 deletions

View File

@ -227,5 +227,11 @@ namespace NzbDrone.Core.Download.Clients.Putio
{
throw new NotImplementedException();
}
public override void MarkItemAsImported(DownloadClientItem downloadClientItem)
{
// What to do here? Maybe delete the file and transfer from put.io?
base.MarkItemAsImported(downloadClientItem);
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
namespace NzbDrone.Core.Download.Clients.Putio
@ -35,9 +36,15 @@ namespace NzbDrone.Core.Download.Clients.Putio
public void AddTorrentFromUrl(string torrentUrl, PutioSettings settings)
{
// var arguments = new Dictionary<string, object>();
// arguments.Add("url", torrentUrl);
// ProcessRequest<PutioGenericResponse>(Method.POST, "transfers/add", arguments, settings);
var request = BuildRequest(HttpMethod.Post, "transfers/add", settings);
request.AddFormParameter("url", torrentUrl);
if (settings.SaveParentId.IsNotNullOrWhiteSpace())
{
request.AddFormParameter("save_parent_id", settings.SaveParentId);
}
Execute<PutioGenericResponse>(request);
}
public void AddTorrentFromData(byte[] torrentData, PutioSettings settings)
@ -78,9 +85,16 @@ namespace NzbDrone.Core.Download.Clients.Putio
request.LogResponseContent = true;
try
{
if (requestBuilder.Method == HttpMethod.Post)
{
return _httpClient.Post<TResult>(request);
}
else
{
return _httpClient.Get<TResult>(request);
}
}
catch (HttpException ex)
{
if (ex.Response.StatusCode == HttpStatusCode.Unauthorized)