1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Fixed XBMC updating

This commit is contained in:
Mark McDowall 2013-06-04 20:13:57 -07:00
parent 66bce4b51e
commit 9722506aca
3 changed files with 28 additions and 20 deletions

View File

@ -72,7 +72,13 @@ public void ProcessDownloadedEpiosdesFolder()
{ {
try try
{ {
var series = _parsingService.GetSeries(videoFile); var series = _parsingService.GetSeries(Path.GetFileNameWithoutExtension(videoFile));
if (series == null)
{
_logger.Trace("Unknown Series for file: {0}", videoFile);
}
ProcessVideoFile(videoFile, series); ProcessVideoFile(videoFile, series);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -10,6 +10,7 @@
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
using Omu.ValueInjecter; using Omu.ValueInjecter;
namespace NzbDrone.Core.Notifications namespace NzbDrone.Core.Notifications
@ -134,10 +135,10 @@ private INotification GetInstance(NotificationDefinition indexerDefinition)
return instance; return instance;
} }
private string GetMessage(ParsedEpisodeInfo parsedEpisodeInfo) private string GetMessage(ParsedEpisodeInfo parsedEpisodeInfo, Series series)
{ {
return String.Format("{0} - {1}{2}", return String.Format("{0} - {1}{2}",
parsedEpisodeInfo.SeriesTitle, series.Title,
parsedEpisodeInfo.SeasonNumber, parsedEpisodeInfo.SeasonNumber,
String.Concat(parsedEpisodeInfo.EpisodeNumbers.Select(i => String.Format("x{0:00}", i)))); String.Concat(parsedEpisodeInfo.EpisodeNumbers.Select(i => String.Format("x{0:00}", i))));
} }
@ -148,7 +149,7 @@ public void Handle(EpisodeGrabbedEvent message)
.ToList() .ToList()
.ForEach(notification => .ForEach(notification =>
notification.Instance notification.Instance
.OnGrab(GetMessage(message.Episode.ParsedEpisodeInfo)) .OnGrab(GetMessage(message.Episode.ParsedEpisodeInfo, message.Episode.Series))
); );
} }
@ -158,7 +159,7 @@ public void Handle(EpisodeDownloadedEvent message)
.ToList() .ToList()
.ForEach(notification => .ForEach(notification =>
notification.Instance notification.Instance
.OnDownload(GetMessage(message.ParsedEpisodeInfo), message.Series) .OnDownload(GetMessage(message.ParsedEpisodeInfo, message.Series), message.Series)
); );
} }

View File

@ -39,19 +39,19 @@ public virtual void Update(XbmcSettings settings, Series series)
var username = settings.Username; var username = settings.Username;
var password = settings.Password; var password = settings.Password;
var host = settings.Host; var address = String.Format("{0}:{1}", settings.Host, settings.Port);
Logger.Trace("Determining version of XBMC Host: {0}", host); Logger.Trace("Determining version of XBMC Host: {0}", address);
var version = GetJsonVersion(host, username, password); var version = GetJsonVersion(address, username, password);
//If Dharma //Dharma
if (version == new XbmcVersion(2)) if (version == new XbmcVersion(2))
{ {
//Check for active player only when we should skip updates when playing //Check for active player only when we should skip updates when playing
if (!settings.AlwaysUpdate) if (!settings.AlwaysUpdate)
{ {
Logger.Trace("Determining if there are any active players on XBMC host: {0}", host); Logger.Trace("Determining if there are any active players on XBMC host: {0}", address);
var activePlayers = GetActivePlayersDharma(host, username, password); var activePlayers = GetActivePlayersDharma(address, username, password);
//If video is currently playing, then skip update //If video is currently playing, then skip update
if (activePlayers["video"]) if (activePlayers["video"])
@ -60,17 +60,17 @@ public virtual void Update(XbmcSettings settings, Series series)
return; return;
} }
} }
UpdateWithHttp(series, host, username, password); UpdateWithHttp(series, address, username, password);
} }
//If Eden or newer (attempting to make it future compatible) //Eden
else if (version == new XbmcVersion(3) || version == new XbmcVersion(4)) else if (version == new XbmcVersion(3) || version == new XbmcVersion(4))
{ {
//Check for active player only when we should skip updates when playing //Check for active player only when we should skip updates when playing
if (!settings.AlwaysUpdate) if (!settings.AlwaysUpdate)
{ {
Logger.Trace("Determining if there are any active players on XBMC host: {0}", host); Logger.Trace("Determining if there are any active players on XBMC host: {0}", address);
var activePlayers = GetActivePlayersEden(host, username, password); var activePlayers = GetActivePlayersEden(address, username, password);
//If video is currently playing, then skip update //If video is currently playing, then skip update
if (activePlayers.Any(a => a.Type.Equals("video"))) if (activePlayers.Any(a => a.Type.Equals("video")))
@ -80,16 +80,17 @@ public virtual void Update(XbmcSettings settings, Series series)
} }
} }
UpdateWithJsonExecBuiltIn(series, host, username, password); UpdateWithJsonExecBuiltIn(series, address, username, password);
} }
//Frodo or newer (attempting to make it future compatible)
else if (version >= new XbmcVersion(5)) else if (version >= new XbmcVersion(5))
{ {
//Check for active player only when we should skip updates when playing //Check for active player only when we should skip updates when playing
if (!settings.AlwaysUpdate) if (!settings.AlwaysUpdate)
{ {
Logger.Trace("Determining if there are any active players on XBMC host: {0}", host); Logger.Trace("Determining if there are any active players on XBMC host: {0}", address);
var activePlayers = GetActivePlayersEden(host, username, password); var activePlayers = GetActivePlayersEden(address, username, password);
//If video is currently playing, then skip update //If video is currently playing, then skip update
if (activePlayers.Any(a => a.Type.Equals("video"))) if (activePlayers.Any(a => a.Type.Equals("video")))
@ -99,7 +100,7 @@ public virtual void Update(XbmcSettings settings, Series series)
} }
} }
UpdateWithJsonVideoLibraryScan(series, host, username, password); UpdateWithJsonVideoLibraryScan(series, address, username, password);
} }
//Log Version zero if check failed //Log Version zero if check failed
@ -163,7 +164,7 @@ public virtual bool UpdateWithJsonVideoLibraryScan(Series series, string host, s
Logger.Trace("Failed to get TV Shows from XBMC"); Logger.Trace("Failed to get TV Shows from XBMC");
else else
path = xbmcShows.FirstOrDefault(s => s.ImdbNumber == series.Id || s.Label == series.Title); path = xbmcShows.FirstOrDefault(s => s.ImdbNumber == series.TvdbId || s.Label == series.Title);
var postJson = new JObject(); var postJson = new JObject();
postJson.Add(new JProperty("jsonrpc", "2.0")); postJson.Add(new JProperty("jsonrpc", "2.0"));