From 5c49ac6b29f824669772b0e72b28a9bd194bcd4f Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 12 Jul 2012 19:02:30 -0700 Subject: [PATCH] Added metadata options to settings #ND-21 New: Metadata file creation for XBMC --- .../Providers/Core/ConfigProvider.cs | 14 ----- .../Controllers/SettingsController.cs | 22 ++++++-- NzbDrone.Web/Models/EpisodeNamingModel.cs | 8 +++ NzbDrone.Web/NzbDrone.Web.csproj | 6 +++ .../Settings/EpisodeNamingPartial.cshtml | 53 +++++++++++++++++++ .../Views/Settings/MetadataPartial.cshtml | 15 ++++++ NzbDrone.Web/Views/Settings/Naming.cshtml | 52 +++--------------- 7 files changed, 108 insertions(+), 62 deletions(-) create mode 100644 NzbDrone.Web/Views/Settings/EpisodeNamingPartial.cshtml create mode 100644 NzbDrone.Web/Views/Settings/MetadataPartial.cshtml diff --git a/NzbDrone.Core/Providers/Core/ConfigProvider.cs b/NzbDrone.Core/Providers/Core/ConfigProvider.cs index 76ad96d42..c2637dc3c 100644 --- a/NzbDrone.Core/Providers/Core/ConfigProvider.cs +++ b/NzbDrone.Core/Providers/Core/ConfigProvider.cs @@ -501,20 +501,6 @@ public virtual string PlexPassword set { SetValue("PlexPassword", value); } } - public virtual Boolean MetadataEnabled - { - get { return GetValueBoolean("MetadataEnabled"); } - - set { SetValue("MetadataEnabled", value); } - } - - public virtual Boolean MetadataXbmcEnabled - { - get { return GetValueBoolean("MetadataXbmcEnabled"); } - - set { SetValue("MetadataXbmcEnabled", value); } - } - public virtual Boolean MetadataUseBanners { get { return GetValueBoolean("MetadataUseBanners"); } diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 14e6bb721..a22fca30a 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -31,17 +31,19 @@ public class SettingsController : Controller private readonly QualityTypeProvider _qualityTypeProvider; private readonly ConfigFileProvider _configFileProvider; private readonly NewznabProvider _newznabProvider; + private readonly MetadataProvider _metadataProvider; public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider, - QualityProvider qualityProvider, AutoConfigureProvider autoConfigureProvider, - SeriesProvider seriesProvider, ExternalNotificationProvider externalNotificationProvider, - QualityTypeProvider qualityTypeProvider, - ConfigFileProvider configFileProvider, NewznabProvider newznabProvider) + QualityProvider qualityProvider, AutoConfigureProvider autoConfigureProvider, + SeriesProvider seriesProvider, ExternalNotificationProvider externalNotificationProvider, + QualityTypeProvider qualityTypeProvider, ConfigFileProvider configFileProvider, + NewznabProvider newznabProvider, MetadataProvider metadataProvider) { _externalNotificationProvider = externalNotificationProvider; _qualityTypeProvider = qualityTypeProvider; _configFileProvider = configFileProvider; _newznabProvider = newznabProvider; + _metadataProvider = metadataProvider; _configProvider = configProvider; _indexerProvider = indexerProvider; _qualityProvider = qualityProvider; @@ -207,6 +209,10 @@ public ActionResult Naming() model.SeparatorStyles = new SelectList(EpisodeSortingHelper.GetSeparatorStyles(), "Id", "Name"); model.NumberStyles = new SelectList(EpisodeSortingHelper.GetNumberStyles(), "Id", "Name"); model.MultiEpisodeStyles = new SelectList(EpisodeSortingHelper.GetMultiEpisodeStyles(), "Id", "Name"); + + //Metadata + model.MetadataXbmcEnabled = _metadataProvider.GetSettings(typeof(Core.Providers.Metadata.Xbmc)).Enable; + model.MetadataUseBanners = _configProvider.MetadataUseBanners; return View(model); } @@ -589,6 +595,14 @@ public JsonResult SaveNaming(EpisodeNamingModel data) _configProvider.SortingNumberStyle = data.NumberStyle; _configProvider.SortingMultiEpisodeStyle = data.MultiEpisodeStyle; + //Metadata + _configProvider.MetadataUseBanners = data.MetadataUseBanners; + + //Xbmc + var xbmc = _metadataProvider.GetSettings(typeof(Core.Providers.Metadata.Xbmc)); + xbmc.Enable = data.MetadataXbmcEnabled; + _metadataProvider.SaveSettings(xbmc); + return GetSuccessResult(); } diff --git a/NzbDrone.Web/Models/EpisodeNamingModel.cs b/NzbDrone.Web/Models/EpisodeNamingModel.cs index 88b21e08b..3331f5883 100644 --- a/NzbDrone.Web/Models/EpisodeNamingModel.cs +++ b/NzbDrone.Web/Models/EpisodeNamingModel.cs @@ -43,6 +43,14 @@ public class EpisodeNamingModel [Description("How will multi-episode files be named?")] public int MultiEpisodeStyle { get; set; } + [DisplayName("XBMC")] + [Description("Enable creating metadata for XBMC")] + public bool MetadataXbmcEnabled { get; set; } + + [DisplayName("Use Banners")] + [Description("Use banners instead of posters?")] + public bool MetadataUseBanners { get; set; } + public SelectList SeparatorStyles { get; set; } public SelectList NumberStyles { get; set; } public SelectList MultiEpisodeStyles { get; set; } diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 000bd26da..95da07b1e 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -543,6 +543,12 @@ + + + + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/NzbDrone.Web/Views/Settings/EpisodeNamingPartial.cshtml b/NzbDrone.Web/Views/Settings/EpisodeNamingPartial.cshtml new file mode 100644 index 000000000..b751a045e --- /dev/null +++ b/NzbDrone.Web/Views/Settings/EpisodeNamingPartial.cshtml @@ -0,0 +1,53 @@ +@using NzbDrone.Web.Helpers +@model NzbDrone.Web.Models.EpisodeNamingModel +@{ + Layout = null; +} + +
+ @Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") + + @Html.CheckBoxFor(m => m.SeriesName, new { @class = "inputClass checkClass" }) + + @Html.CheckBoxFor(m => m.EpisodeName, new { @class = "inputClass checkClass" }) + + @Html.CheckBoxFor(m => m.ReplaceSpaces, new { @class = "inputClass checkClass" }) + + @Html.CheckBoxFor(m => m.AppendQuality, new { @class = "inputClass checkClass" }) + + @Html.CheckBoxFor(m => m.SeasonFolders, new { @class = "inputClass checkClass" }) + + @Html.TextBoxFor(m => m.SeasonFolderFormat, new { @class = "inputClass" }) + + @Html.DropDownListFor(m => m.SeparatorStyle, Model.SeparatorStyles, new { @class = "inputClass selectClass" }) + + @Html.DropDownListFor(m => m.NumberStyle, Model.NumberStyles, new { @class = "inputClass selectClass" }) + + @Html.DropDownListFor(m => m.MultiEpisodeStyle, Model.MultiEpisodeStyles, new { @class = "inputClass selectClass" }) +
+
+
+ Single Episode Example: +
+
+ Multi-Episode Example: +
+
\ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/MetadataPartial.cshtml b/NzbDrone.Web/Views/Settings/MetadataPartial.cshtml new file mode 100644 index 000000000..c37de47b4 --- /dev/null +++ b/NzbDrone.Web/Views/Settings/MetadataPartial.cshtml @@ -0,0 +1,15 @@ +@using NzbDrone.Web.Helpers +@model NzbDrone.Web.Models.EpisodeNamingModel +@{ + Layout = null; +} + + +@Html.CheckBoxFor(m => m.MetadataXbmcEnabled, new { @class = "inputClass checkClass" }) + + +@Html.CheckBoxFor(m => m.MetadataUseBanners, new { @class = "inputClass checkClass" }) \ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/Naming.cshtml b/NzbDrone.Web/Views/Settings/Naming.cshtml index 70b32754a..d3438b932 100644 --- a/NzbDrone.Web/Views/Settings/Naming.cshtml +++ b/NzbDrone.Web/Views/Settings/Naming.cshtml @@ -20,51 +20,15 @@
@using (Html.BeginForm("SaveNaming", "Settings", FormMethod.Post, new { id = "NamingForm", name = "NamingForm", @class = "settingsForm" })) { -
- @Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") - - @Html.CheckBoxFor(m => m.SeriesName, new { @class = "inputClass checkClass" }) - - @Html.CheckBoxFor(m => m.EpisodeName, new { @class = "inputClass checkClass" }) - - @Html.CheckBoxFor(m => m.ReplaceSpaces, new { @class = "inputClass checkClass" }) - - @Html.CheckBoxFor(m => m.AppendQuality, new { @class = "inputClass checkClass" }) - - @Html.CheckBoxFor(m => m.SeasonFolders, new { @class = "inputClass checkClass" }) - - @Html.TextBoxFor(m => m.SeasonFolderFormat, new { @class = "inputClass" }) - - @Html.DropDownListFor(m => m.SeparatorStyle, Model.SeparatorStyles, new { @class = "inputClass selectClass" }) - - @Html.DropDownListFor(m => m.NumberStyle, Model.NumberStyles, new { @class = "inputClass selectClass" }) - - @Html.DropDownListFor(m => m.MultiEpisodeStyle, Model.MultiEpisodeStyles, new { @class = "inputClass selectClass" }) -
-
-
- Single Episode Example: +
+

Episode Naming

+
+ @{Html.RenderPartial("EpisodeNamingPartial", Model);}
-
- Multi-Episode Example: + +

Metadata

+
+ @{Html.RenderPartial("MetaDataPartial", Model);}