mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 15: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 @@ namespace NzbDrone.Core.Download.Clients
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void DownloadNzb(RemoteEpisode remoteEpisode)
|
||||
public string DownloadNzb(RemoteEpisode remoteEpisode)
|
||||
{
|
||||
var url = remoteEpisode.Release.DownloadUrl;
|
||||
var title = remoteEpisode.Release.Title;
|
||||
@ -34,8 +34,9 @@ namespace NzbDrone.Core.Download.Clients
|
||||
|
||||
_logger.Trace("Downloading NZB from: {0} to: {1}", url, filename);
|
||||
_httpProvider.DownloadFile(url, filename);
|
||||
|
||||
_logger.Trace("NZB Download succeeded, saved to: {0}", filename);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsConfigured
|
||||
|
@ -24,7 +24,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void DownloadNzb(RemoteEpisode remoteEpisode)
|
||||
public string DownloadNzb(RemoteEpisode remoteEpisode)
|
||||
{
|
||||
var url = remoteEpisode.Release.DownloadUrl;
|
||||
var title = remoteEpisode.Release.Title + ".nzb";
|
||||
@ -46,6 +46,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||
var success = Json.Deserialize<EnqueueResponse>(response).Result;
|
||||
_logger.Debug("Queue Response: [{0}]", success);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsConfigured
|
||||
|
@ -26,7 +26,7 @@ namespace NzbDrone.Core.Download.Clients
|
||||
_diskProvider = diskProvider;
|
||||
}
|
||||
|
||||
public void DownloadNzb(RemoteEpisode remoteEpisode)
|
||||
public string DownloadNzb(RemoteEpisode remoteEpisode)
|
||||
{
|
||||
var url = remoteEpisode.Release.DownloadUrl;
|
||||
var title = remoteEpisode.Release.Title;
|
||||
@ -41,8 +41,6 @@ namespace NzbDrone.Core.Download.Clients
|
||||
//Save to the Pneumatic directory (The user will need to ensure its accessible by XBMC)
|
||||
var filename = Path.Combine(_configService.PneumaticFolder, title + ".nzb");
|
||||
|
||||
|
||||
|
||||
logger.Trace("Downloading NZB from: {0} to: {1}", url, filename);
|
||||
_httpProvider.DownloadFile(url, filename);
|
||||
|
||||
@ -50,6 +48,8 @@ namespace NzbDrone.Core.Download.Clients
|
||||
|
||||
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);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsConfigured
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
@ -13,43 +14,6 @@ using RestSharp;
|
||||
|
||||
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
|
||||
{
|
||||
private readonly IConfigService _configService;
|
||||
@ -74,7 +38,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void DownloadNzb(RemoteEpisode remoteEpisode)
|
||||
public string DownloadNzb(RemoteEpisode remoteEpisode)
|
||||
{
|
||||
var url = remoteEpisode.Release.DownloadUrl;
|
||||
var title = remoteEpisode.Release.Title;
|
||||
@ -84,9 +48,11 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||
using (var nzb = _httpProvider.DownloadStream(url))
|
||||
{
|
||||
_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.Core.Instrumentation;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
@ -40,10 +41,17 @@ namespace NzbDrone.Core.Download
|
||||
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);
|
||||
_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;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
@ -6,6 +7,8 @@ namespace NzbDrone.Core.Download
|
||||
public class EpisodeGrabbedEvent : IEvent
|
||||
{
|
||||
public RemoteEpisode Episode { get; private set; }
|
||||
public String DownloadClient { get; set; }
|
||||
public String DownloadClientId { get; set; }
|
||||
|
||||
public EpisodeGrabbedEvent(RemoteEpisode episode)
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ namespace NzbDrone.Core.Download
|
||||
{
|
||||
public interface IDownloadClient
|
||||
{
|
||||
void DownloadNzb(RemoteEpisode remoteEpisode);
|
||||
string DownloadNzb(RemoteEpisode remoteEpisode);
|
||||
bool IsConfigured { get; }
|
||||
IEnumerable<QueueItem> GetQueue();
|
||||
}
|
||||
|
@ -75,6 +75,12 @@ namespace NzbDrone.Core.History
|
||||
history.Data.Add("ReleaseGroup", message.Episode.Release.ReleaseGroup);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user