mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 12:32:31 +01:00
Storing nzo_id from SAB in history (data)
This commit is contained in:
parent
fa2bc76102
commit
2e1b921543
@ -22,7 +22,7 @@ public BlackholeProvider(IConfigService configService, IHttpProvider httpProvide
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DownloadNzb(RemoteEpisode remoteEpisode)
|
public string DownloadNzb(RemoteEpisode remoteEpisode)
|
||||||
{
|
{
|
||||||
var url = remoteEpisode.Release.DownloadUrl;
|
var url = remoteEpisode.Release.DownloadUrl;
|
||||||
var title = remoteEpisode.Release.Title;
|
var title = remoteEpisode.Release.Title;
|
||||||
@ -34,8 +34,9 @@ public void DownloadNzb(RemoteEpisode remoteEpisode)
|
|||||||
|
|
||||||
_logger.Trace("Downloading NZB from: {0} to: {1}", url, filename);
|
_logger.Trace("Downloading NZB from: {0} to: {1}", url, filename);
|
||||||
_httpProvider.DownloadFile(url, filename);
|
_httpProvider.DownloadFile(url, filename);
|
||||||
|
|
||||||
_logger.Trace("NZB Download succeeded, saved to: {0}", filename);
|
_logger.Trace("NZB Download succeeded, saved to: {0}", filename);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsConfigured
|
public bool IsConfigured
|
||||||
|
@ -24,7 +24,7 @@ public NzbgetClient(IConfigService configService, IHttpProvider httpProvider, IP
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DownloadNzb(RemoteEpisode remoteEpisode)
|
public string DownloadNzb(RemoteEpisode remoteEpisode)
|
||||||
{
|
{
|
||||||
var url = remoteEpisode.Release.DownloadUrl;
|
var url = remoteEpisode.Release.DownloadUrl;
|
||||||
var title = remoteEpisode.Release.Title + ".nzb";
|
var title = remoteEpisode.Release.Title + ".nzb";
|
||||||
@ -46,6 +46,7 @@ public void DownloadNzb(RemoteEpisode remoteEpisode)
|
|||||||
var success = Json.Deserialize<EnqueueResponse>(response).Result;
|
var success = Json.Deserialize<EnqueueResponse>(response).Result;
|
||||||
_logger.Debug("Queue Response: [{0}]", success);
|
_logger.Debug("Queue Response: [{0}]", success);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsConfigured
|
public bool IsConfigured
|
||||||
|
@ -26,7 +26,7 @@ public PneumaticClient(IConfigService configService, IHttpProvider httpProvider,
|
|||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DownloadNzb(RemoteEpisode remoteEpisode)
|
public string DownloadNzb(RemoteEpisode remoteEpisode)
|
||||||
{
|
{
|
||||||
var url = remoteEpisode.Release.DownloadUrl;
|
var url = remoteEpisode.Release.DownloadUrl;
|
||||||
var title = remoteEpisode.Release.Title;
|
var title = remoteEpisode.Release.Title;
|
||||||
@ -41,8 +41,6 @@ public void DownloadNzb(RemoteEpisode remoteEpisode)
|
|||||||
//Save to the Pneumatic directory (The user will need to ensure its accessible by XBMC)
|
//Save to the Pneumatic directory (The user will need to ensure its accessible by XBMC)
|
||||||
var filename = Path.Combine(_configService.PneumaticFolder, title + ".nzb");
|
var filename = Path.Combine(_configService.PneumaticFolder, title + ".nzb");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger.Trace("Downloading NZB from: {0} to: {1}", url, filename);
|
logger.Trace("Downloading NZB from: {0} to: {1}", url, filename);
|
||||||
_httpProvider.DownloadFile(url, filename);
|
_httpProvider.DownloadFile(url, filename);
|
||||||
|
|
||||||
@ -50,6 +48,8 @@ public void DownloadNzb(RemoteEpisode remoteEpisode)
|
|||||||
|
|
||||||
var contents = String.Format("plugin://plugin.program.pneumatic/?mode=strm&type=add_file&nzb={0}&nzbname={1}", filename, title);
|
var contents = String.Format("plugin://plugin.program.pneumatic/?mode=strm&type=add_file&nzb={0}&nzbname={1}", filename, title);
|
||||||
_diskProvider.WriteAllText(Path.Combine(_configService.DownloadedEpisodesFolder, title + ".strm"), contents);
|
_diskProvider.WriteAllText(Path.Combine(_configService.DownloadedEpisodesFolder, title + ".strm"), contents);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsConfigured
|
public bool IsConfigured
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
@ -13,43 +14,6 @@
|
|||||||
|
|
||||||
namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||||
{
|
{
|
||||||
public class SabRequestBuilder
|
|
||||||
{
|
|
||||||
private readonly IConfigService _configService;
|
|
||||||
|
|
||||||
public SabRequestBuilder(IConfigService configService)
|
|
||||||
{
|
|
||||||
_configService = configService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IRestRequest AddToQueueRequest(RemoteEpisode remoteEpisode)
|
|
||||||
{
|
|
||||||
string cat = _configService.SabTvCategory;
|
|
||||||
int priority = (int)_configService.SabRecentTvPriority;
|
|
||||||
|
|
||||||
string name = remoteEpisode.Release.DownloadUrl.Replace("&", "%26");
|
|
||||||
string nzbName = HttpUtility.UrlEncode(remoteEpisode.Release.Title);
|
|
||||||
|
|
||||||
string action = string.Format("mode=addurl&name={0}&priority={1}&pp=3&cat={2}&nzbname={3}&output=json",
|
|
||||||
name, priority, cat, nzbName);
|
|
||||||
|
|
||||||
string request = GetSabRequest(action);
|
|
||||||
|
|
||||||
return new RestRequest(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetSabRequest(string action)
|
|
||||||
{
|
|
||||||
return string.Format(@"http://{0}:{1}/api?{2}&apikey={3}&ma_username={4}&ma_password={5}",
|
|
||||||
_configService.SabHost,
|
|
||||||
_configService.SabPort,
|
|
||||||
action,
|
|
||||||
_configService.SabApiKey,
|
|
||||||
_configService.SabUsername,
|
|
||||||
_configService.SabPassword);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SabnzbdClient : IDownloadClient
|
public class SabnzbdClient : IDownloadClient
|
||||||
{
|
{
|
||||||
private readonly IConfigService _configService;
|
private readonly IConfigService _configService;
|
||||||
@ -74,7 +38,7 @@ public SabnzbdClient(IConfigService configService,
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DownloadNzb(RemoteEpisode remoteEpisode)
|
public string DownloadNzb(RemoteEpisode remoteEpisode)
|
||||||
{
|
{
|
||||||
var url = remoteEpisode.Release.DownloadUrl;
|
var url = remoteEpisode.Release.DownloadUrl;
|
||||||
var title = remoteEpisode.Release.Title;
|
var title = remoteEpisode.Release.Title;
|
||||||
@ -84,9 +48,11 @@ public void DownloadNzb(RemoteEpisode remoteEpisode)
|
|||||||
using (var nzb = _httpProvider.DownloadStream(url))
|
using (var nzb = _httpProvider.DownloadStream(url))
|
||||||
{
|
{
|
||||||
_logger.Info("Adding report [{0}] to the queue.", title);
|
_logger.Info("Adding report [{0}] to the queue.", title);
|
||||||
var response = _sabCommunicationProxy.DownloadNzb(nzb, title, category, priority);
|
var response = Json.Deserialize<SabAddResponse>(_sabCommunicationProxy.DownloadNzb(nzb, title, category, priority));
|
||||||
|
|
||||||
_logger.Debug("Queue Response: [{0}]", response);
|
_logger.Debug("Queue Response: [{0}]", response.Status);
|
||||||
|
|
||||||
|
return response.Ids.First();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using NLog;
|
using System;
|
||||||
|
using NLog;
|
||||||
using NzbDrone.Common.EnsureThat;
|
using NzbDrone.Common.EnsureThat;
|
||||||
using NzbDrone.Core.Instrumentation;
|
using NzbDrone.Core.Instrumentation;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
@ -40,10 +41,17 @@ public void DownloadReport(RemoteEpisode remoteEpisode)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadClient.DownloadNzb(remoteEpisode);
|
var downloadClientId = downloadClient.DownloadNzb(remoteEpisode);
|
||||||
|
var episodeGrabbedEvent = new EpisodeGrabbedEvent(remoteEpisode);
|
||||||
|
|
||||||
|
if (!String.IsNullOrWhiteSpace(downloadClientId))
|
||||||
|
{
|
||||||
|
episodeGrabbedEvent.DownloadClient = downloadClient.GetType().Name;
|
||||||
|
episodeGrabbedEvent.DownloadClientId = downloadClientId;
|
||||||
|
}
|
||||||
|
|
||||||
_logger.ProgressInfo("Report sent to download client. {0}", downloadTitle);
|
_logger.ProgressInfo("Report sent to download client. {0}", downloadTitle);
|
||||||
_eventAggregator.PublishEvent(new EpisodeGrabbedEvent(remoteEpisode));
|
_eventAggregator.PublishEvent(episodeGrabbedEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using NzbDrone.Common.Messaging;
|
using System;
|
||||||
|
using NzbDrone.Common.Messaging;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Download
|
namespace NzbDrone.Core.Download
|
||||||
@ -6,6 +7,8 @@ namespace NzbDrone.Core.Download
|
|||||||
public class EpisodeGrabbedEvent : IEvent
|
public class EpisodeGrabbedEvent : IEvent
|
||||||
{
|
{
|
||||||
public RemoteEpisode Episode { get; private set; }
|
public RemoteEpisode Episode { get; private set; }
|
||||||
|
public String DownloadClient { get; set; }
|
||||||
|
public String DownloadClientId { get; set; }
|
||||||
|
|
||||||
public EpisodeGrabbedEvent(RemoteEpisode episode)
|
public EpisodeGrabbedEvent(RemoteEpisode episode)
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ namespace NzbDrone.Core.Download
|
|||||||
{
|
{
|
||||||
public interface IDownloadClient
|
public interface IDownloadClient
|
||||||
{
|
{
|
||||||
void DownloadNzb(RemoteEpisode remoteEpisode);
|
string DownloadNzb(RemoteEpisode remoteEpisode);
|
||||||
bool IsConfigured { get; }
|
bool IsConfigured { get; }
|
||||||
IEnumerable<QueueItem> GetQueue();
|
IEnumerable<QueueItem> GetQueue();
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,12 @@ public void Handle(EpisodeGrabbedEvent message)
|
|||||||
history.Data.Add("ReleaseGroup", message.Episode.Release.ReleaseGroup);
|
history.Data.Add("ReleaseGroup", message.Episode.Release.ReleaseGroup);
|
||||||
history.Data.Add("Age", message.Episode.Release.Age.ToString());
|
history.Data.Add("Age", message.Episode.Release.Age.ToString());
|
||||||
|
|
||||||
|
if (!String.IsNullOrWhiteSpace(message.DownloadClientId))
|
||||||
|
{
|
||||||
|
history.Data.Add("DownloadClient", message.DownloadClient);
|
||||||
|
history.Data.Add("DownloadClientId", message.DownloadClientId);
|
||||||
|
}
|
||||||
|
|
||||||
_historyRepository.Insert(history);
|
_historyRepository.Insert(history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user