diff --git a/LostInfo.txt b/LostInfo.txt new file mode 100644 index 000000000..6d80cce27 --- /dev/null +++ b/LostInfo.txt @@ -0,0 +1,32 @@ +Missing after HDD Failure.... + +ExternalNotiifcationProvider + - NotifyOnGrab, Download, Rename + +XbmcProvider + - SendNotification + - Update + - Clean + +Settings/Notications +NoticationSettingsModel + XBMC: + Enabled + Notify On: Grab, Download, Rename + Update On: Download, Rename + FullUpdate (If Required) + Clean On: Download, Rename + Show Image? + TimeToDisplay? + + +ServerHelper + - Get IP/Hostname + + +SyncProvider Changes + - Add by Root or Single Series + +AddSeries + - Simlar to SB + - FileBrowserModel - Name, Path \ No newline at end of file diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 29c60a616..86709dc9d 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -158,6 +158,7 @@ + @@ -173,20 +174,26 @@ + + + + + + diff --git a/NzbDrone.Core/Providers/IExtenalNotificationProvider.cs b/NzbDrone.Core/Providers/IExtenalNotificationProvider.cs index 83d2752a2..6c483b44e 100644 --- a/NzbDrone.Core/Providers/IExtenalNotificationProvider.cs +++ b/NzbDrone.Core/Providers/IExtenalNotificationProvider.cs @@ -2,14 +2,14 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using NzbDrone.Core.Repository; +using NzbDrone.Core.Model; namespace NzbDrone.Core.Providers { public interface IExtenalNotificationProvider { void OnGrab(string message); - void OnDownload(EpisodeFile episodeFile); - void OnRename(EpisodeFile episodeFile); + void OnDownload(EpisodeRenameModel erm); + void OnRename(EpisodeRenameModel erm); } } diff --git a/NzbDrone.Core/Providers/RenameProvider.cs b/NzbDrone.Core/Providers/RenameProvider.cs index 1329be90b..d8e334405 100644 --- a/NzbDrone.Core/Providers/RenameProvider.cs +++ b/NzbDrone.Core/Providers/RenameProvider.cs @@ -198,10 +198,10 @@ namespace NzbDrone.Core.Providers _mediaFileProvider.Update(erm.EpisodeFile); if (erm.NewDownload) - _externalNotificationProvider.OnDownload(); + _externalNotificationProvider.OnDownload(erm); else - _externalNotificationProvider.OnRename(); + _externalNotificationProvider.OnRename(erm); } catch (Exception ex) diff --git a/NzbDrone.Core/Providers/XbmcProvider.cs b/NzbDrone.Core/Providers/XbmcProvider.cs index d044a0ed0..e0d853b28 100644 --- a/NzbDrone.Core/Providers/XbmcProvider.cs +++ b/NzbDrone.Core/Providers/XbmcProvider.cs @@ -1,9 +1,12 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Net; using System.Text; +using System.Xml.Linq; using NLog; +using NzbDrone.Core.Helpers; namespace NzbDrone.Core.Providers { @@ -26,27 +29,54 @@ namespace NzbDrone.Core.Providers { //Get time in seconds and convert to ms var time = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", "3", true)) * 1000; - var command = String.Format("ExecBuiltIn(Notification({0},{1},{2}))", header, message, time); - foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80", true).Split(',')) + if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false, true))) { - Logger.Trace("Sending Notifcation to XBMC Host: {0}", host); + //Todo: Get the actual port that NzbDrone is running on... + var serverInfo = String.Format("http://{0}:{1}", ServerHelper.GetServerHostname(), "8989"); + var imageUrl = String.Format("{0}/Content/XbmcNotification.png", serverInfo); + command = String.Format("ExecBuiltIn(Notification({0},{1},{2}, {3}))", header, message, time, imageUrl); } - - throw new NotImplementedException(); + foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80", true).Split(',')) + { + Logger.Trace("Sending Notifcation to XBMC Host: {0}", host); + SendCommand(host, command); + } } public void Update(int seriesId) { - throw new NotImplementedException(); + foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80", true).Split(',')) + { + Logger.Trace("Sending Update DB Request to XBMC Host: {0}", host); + var xbmcSeriesPath = GetXbmcSeriesPath(host, seriesId); + + //If the path is not found & the user wants to update the entire library, do it now. + if (String.IsNullOrEmpty(xbmcSeriesPath) && Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true))) + { + //Update the entire library + Logger.Trace("Series [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", seriesId, host); + SendCommand(host, "ExecBuiltIn(UpdateLibrary(video))"); + return; + } + + var command = String.Format("ExecBuiltIn(UpdateLibrary(video,{0}))", xbmcSeriesPath); + SendCommand(host, command); + } } public void Clean() { - throw new NotImplementedException(); + foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80", true).Split(',')) + { + Logger.Trace("Sending DB Clean Request to XBMC Host: {0}", host); + + var command = String.Format("ExecBuiltIn(CleanLibrary(database) )"); + SendCommand(host, command); + } } #endregion @@ -75,5 +105,34 @@ namespace NzbDrone.Core.Providers return string.Empty; } + + private string GetXbmcSeriesPath(string host, int seriesId) + { + var query = String.Format("select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = {0} and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath", seriesId); + var command = String.Format("QueryVideoDatabase({0})", query); + + var setResponseCommand = "SetResponseFormat(webheader;false;webfooter;false;header;;footer;;opentag;;closetag;;closefinaltag;false)"; + var resetResponseCommand = "SetResponseFormat()"; + + SendCommand(host, setResponseCommand); + var response = SendCommand(host, command); + SendCommand(host, resetResponseCommand); + + if (String.IsNullOrEmpty(response)) + return String.Empty; + + var xDoc = XDocument.Load(new StringReader(response)); + var xml = (from x in xDoc.Descendants("xml") select x).FirstOrDefault(); + + if (xml == null) + return String.Empty; + + var field = xml.Descendants("field").FirstOrDefault(); + + if (field == null) + return String.Empty; + + return field.Value; + } } } diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 033ee295f..fb3caf55f 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -231,6 +231,7 @@ +