The Free Software Media System - Server Backend & API
added new image params & GameSystem constants
Luke Pulverenti7dae0069d658
diff --git a/MediaBrowser.Api/Images/ImageRequest.cs b/MediaBrowser.Api/Images/ImageRequest.csindex 210ee5b64e..288fd9ea63 100644--- a/MediaBrowser.Api/Images/ImageRequest.cs+++ b/MediaBrowser.Api/Images/ImageRequest.cs@@ -56,11 +56,11 @@ namespace MediaBrowser.Api.Images[ApiMember(Name = "Format", Description = "Determines the output foramt of the image - original,gif,jpg,png", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]public ImageOutputFormat Format { get; set; }- [ApiMember(Name = "Indicator", Description = "Determines what overlay to render, if any. none, watched.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]- public ImageOverlay? Indicator { get; set; }+ [ApiMember(Name = "AddPlayedIndicator", Description = "Optional. Add a played indicator", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]+ public bool AddPlayedIndicator { get; set; }- [ApiMember(Name = "PercentPlayed", Description = "Percent to render for the percent played overlay", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]- public int PercentPlayed { get; set; }+ [ApiMember(Name = "PercentPlayed", Description = "Optional percent to render for the percent played overlay", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]+ public int? PercentPlayed { get; set; }[ApiMember(Name = "BackgroundColor", Description = "Optional. Apply a background color for transparent images.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]public string BackgroundColor { get; set; }diff --git a/MediaBrowser.Api/Images/ImageWriter.cs b/MediaBrowser.Api/Images/ImageWriter.csindex 190d2ba473..4c61b68024 100644--- a/MediaBrowser.Api/Images/ImageWriter.cs+++ b/MediaBrowser.Api/Images/ImageWriter.cs@@ -90,7 +90,7 @@ namespace MediaBrowser.Api.ImagesQuality = Request.Quality,Width = Request.Width,OutputFormat = Request.Format,- Indicator = Request.Indicator,+ AddPlayedIndicator = Request.AddPlayedIndicator,PercentPlayed = Request.PercentPlayed,BackgroundColor = Request.BackgroundColor};diff --git a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.csindex 5910601248..76a079c577 100644--- a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs+++ b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs@@ -35,9 +35,9 @@ namespace MediaBrowser.Controller.Drawingpublic ImageOutputFormat OutputFormat { get; set; }- public ImageOverlay? Indicator { get; set; }+ public bool AddPlayedIndicator { get; set; }- public int PercentPlayed { get; set; }+ public int? PercentPlayed { get; set; }public string BackgroundColor { get; set; }}diff --git a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs b/MediaBrowser.Controller/LiveTv/ChannelInfo.csindex 5f40134482..7ad1ec6c9b 100644--- a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs+++ b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs@@ -1,4 +1,5 @@-+using MediaBrowser.Model.LiveTv;+namespace MediaBrowser.Controller.LiveTv{/// <summary>@@ -17,5 +18,11 @@ namespace MediaBrowser.Controller.LiveTv/// </summary>/// <value>The name of the service.</value>public string ServiceName { get; set; }++ /// <summary>+ /// Gets or sets the type of the channel.+ /// </summary>+ /// <value>The type of the channel.</value>+ public ChannelType ChannelType { get; set; }}}diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csprojindex 56e9c3f8e3..60eacd91ce 100644--- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj+++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj@@ -86,9 +86,6 @@<Compile Include="..\MediaBrowser.Model\Drawing\ImageOutputFormat.cs"><Link>Drawing\ImageOutputFormat.cs</Link></Compile>- <Compile Include="..\MediaBrowser.Model\Drawing\ImageOverlay.cs">- <Link>Drawing\ImageOverlay.cs</Link>- </Compile><Compile Include="..\MediaBrowser.Model\Dto\BaseItemDto.cs"><Link>Dto\BaseItemDto.cs</Link></Compile>@@ -203,6 +200,9 @@<Compile Include="..\MediaBrowser.Model\Extensions\ModelExtensions.cs"><Link>Extensions\ModelExtensions.cs</Link></Compile>+ <Compile Include="..\MediaBrowser.Model\Games\GameSystem.cs">+ <Link>Games\GameSystem.cs</Link>+ </Compile><Compile Include="..\MediaBrowser.Model\Globalization\CountryInfo.cs"><Link>Globalization\CountryInfo.cs</Link></Compile>@@ -218,6 +218,9 @@<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs"><Link>LiveTv\ChannelInfoDto.cs</Link></Compile>+ <Compile Include="..\MediaBrowser.Model\LiveTv\ChannelType.cs">+ <Link>LiveTv\ChannelType.cs</Link>+ </Compile><Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs"><Link>LiveTv\LiveTvServiceInfo.cs</Link></Compile>diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csprojindex 92abac5cff..70cd4533dc 100644--- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj+++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj@@ -70,9 +70,6 @@<Compile Include="..\MediaBrowser.Model\Drawing\ImageOutputFormat.cs"><Link>Drawing\ImageOutputFormat.cs</Link></Compile>- <Compile Include="..\MediaBrowser.Model\Drawing\ImageOverlay.cs">- <Link>Drawing\ImageOverlay.cs</Link>- </Compile><Compile Include="..\MediaBrowser.Model\Dto\BaseItemDto.cs"><Link>Dto\BaseItemDto.cs</Link></Compile>@@ -187,6 +184,9 @@<Compile Include="..\MediaBrowser.Model\Extensions\ModelExtensions.cs"><Link>Extensions\ModelExtensions.cs</Link></Compile>+ <Compile Include="..\MediaBrowser.Model\Games\GameSystem.cs">+ <Link>Games\GameSystem.cs</Link>+ </Compile><Compile Include="..\MediaBrowser.Model\Globalization\CountryInfo.cs"><Link>Globalization\CountryInfo.cs</Link></Compile>@@ -202,6 +202,9 @@<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs"><Link>LiveTv\ChannelInfoDto.cs</Link></Compile>+ <Compile Include="..\MediaBrowser.Model\LiveTv\ChannelType.cs">+ <Link>LiveTv\ChannelType.cs</Link>+ </Compile><Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs"><Link>LiveTv\LiveTvServiceInfo.cs</Link></Compile>diff --git a/MediaBrowser.Model/Drawing/ImageOverlay.cs b/MediaBrowser.Model/Drawing/ImageOverlay.csdeleted file mode 100644index 8ae53746be..0000000000--- a/MediaBrowser.Model/Drawing/ImageOverlay.cs+++ /dev/null@@ -1,18 +0,0 @@--namespace MediaBrowser.Model.Drawing-{- /// <summary>- /// Enum ImageOverlay- /// </summary>- public enum ImageOverlay- {- /// <summary>- /// The watched- /// </summary>- Played,- /// <summary>- /// The percent played- /// </summary>- PercentPlayed- }-}diff --git a/MediaBrowser.Model/Dto/ImageOptions.cs b/MediaBrowser.Model/Dto/ImageOptions.csindex c5c89b0b23..7fe162ff99 100644--- a/MediaBrowser.Model/Dto/ImageOptions.cs+++ b/MediaBrowser.Model/Dto/ImageOptions.cs@@ -70,10 +70,33 @@ namespace MediaBrowser.Model.Dto/// <value><c>true</c> if [enable image enhancers]; otherwise, <c>false</c>.</value>public bool EnableImageEnhancers { get; set; }+ /// <summary>+ /// Gets or sets the format.+ /// </summary>+ /// <value>The format.</value>public ImageOutputFormat Format { get; set; }- public ImageOverlay? Indicator { get; set; }-+ /// <summary>+ /// Gets or sets a value indicating whether [add played indicator].+ /// </summary>+ /// <value><c>true</c> if [add played indicator]; otherwise, <c>false</c>.</value>+ public bool AddPlayedIndicator { get; set; }++ /// <summary>+ /// Gets or sets the percent played.+ /// </summary>+ /// <value>The percent played.</value>+ public int? PercentPlayed { get; set; }++ /// <summary>+ /// Gets or sets the color of the background.+ /// </summary>+ /// <value>The color of the background.</value>+ public string BackgroundColor { get; set; }++ /// <summary>+ /// Initializes a new instance of the <see cref="ImageOptions" /> class.+ /// </summary>public ImageOptions(){EnableImageEnhancers = true;diff --git a/MediaBrowser.Model/Games/GameSystem.cs b/MediaBrowser.Model/Games/GameSystem.csnew file mode 100644index 0000000000..ab8f1efa75--- /dev/null+++ b/MediaBrowser.Model/Games/GameSystem.cs@@ -0,0 +1,48 @@++namespace MediaBrowser.Model.Games+{+ public class GameSystem+ {+ public const string Nintendo = "Nintendo";+ public const string SuperNintendo = "Super Nintendo";+ public const string Panasonic3DO = "3DO";+ public const string Amiga = "Amiga";+ public const string Arcade = "Arcade";+ public const string Atari2600 = "Atari 2600";+ public const string Atari5200 = "Atari 5200";+ public const string Atari7800 = "Atari 7800";+ public const string AtariXE = "Atari XE";+ public const string AtariJaguar = "Atari Jaguar";+ public const string AtariJaguarCD = "Atari Jaguar CD";+ public const string Colecovision = "Colecovision";+ public const string Commodore64 = "Commodore 64";+ public const string CommodoreVic20 = "Commodore Vic-20";+ public const string Intellivision = "Intellivision";+ public const string MicrosoftXBox = "Xbox";+ public const string NeoGeo = "Neo Geo";+ public const string Nintendo64 = "Nintendo 64";+ public const string NintendoDS = "Nintendo DS";+ public const string NintendoGameBoy = "Game Boy";+ public const string NintendoGameBoyAdvance = "Game Boy Advance";+ public const string NintendoGameBoyColor = "Game Boy Color";+ public const string NintendoGameCube = "Gamecube";+ public const string VirtualBoy = "Virtual Boy";+ public const string Wii = "Nintendo Wii";+ public const string DOS = "DOS";+ public const string Windows = "Windows";+ public const string Sega32X = "Sega 32X";+ public const string SegaCD = "Sega CD";+ public const string SegaDreamcast = "Dreamcast";+ public const string SegaGameGear = "Game Gear";+ public const string SegaGenesis = "Sega Genesis";+ public const string SegaMasterSystem = "Sega Master System";+ public const string SegaMegaDrive = "Sega Mega Drive";+ public const string SegaSaturn = "Sega Saturn";+ public const string SonyPlaystation = "Sony Playstation";+ public const string SonyPlaystation2 = "PS2";+ public const string SonyPSP = "PSP";+ public const string TurboGrafx16 = "TurboGrafx 16";+ public const string TurboGrafxCD = "TurboGrafx CD";+ public const string ZxSpectrum = "ZX Spectrum";+ }+}diff --git a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs b/MediaBrowser.Model/LiveTv/ChannelInfoDto.csindex 5150897c3d..c77d7ed127 100644--- a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs+++ b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs@@ -17,5 +17,11 @@ namespace MediaBrowser.Model.LiveTv/// </summary>/// <value>The name of the service.</value>public string ServiceName { get; set; }++ /// <summary>+ /// Gets or sets the type of the channel.+ /// </summary>+ /// <value>The type of the channel.</value>+ public ChannelType ChannelType { get; set; }}}diff --git a/MediaBrowser.Model/LiveTv/ChannelType.cs b/MediaBrowser.Model/LiveTv/ChannelType.csnew file mode 100644index 0000000000..bca16f8396--- /dev/null+++ b/MediaBrowser.Model/LiveTv/ChannelType.cs@@ -0,0 +1,19 @@++namespace MediaBrowser.Model.LiveTv+{+ /// <summary>+ /// Enum ChannelType+ /// </summary>+ public enum ChannelType+ {+ /// <summary>+ /// The TV+ /// </summary>+ TV,++ /// <summary>+ /// The radio+ /// </summary>+ Radio+ }+}diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csprojindex b317dbf0ee..1ee9b97a2e 100644--- a/MediaBrowser.Model/MediaBrowser.Model.csproj+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj@@ -48,7 +48,6 @@<Compile Include="Configuration\BaseApplicationConfiguration.cs" /><Compile Include="Configuration\ManualLoginCategory.cs" /><Compile Include="Configuration\ServerConfiguration.cs" />- <Compile Include="Drawing\ImageOverlay.cs" /><Compile Include="Drawing\ImageOutputFormat.cs" /><Compile Include="Dto\BaseItemPerson.cs" /><Compile Include="Dto\ChapterInfoDto.cs" />@@ -63,10 +62,12 @@<Compile Include="Entities\MediaUrl.cs" /><Compile Include="Entities\MetadataFields.cs" /><Compile Include="Entities\Video3DFormat.cs" />+ <Compile Include="Games\GameSystem.cs" /><Compile Include="IO\IIsoManager.cs" /><Compile Include="IO\IIsoMount.cs" /><Compile Include="IO\IIsoMounter.cs" /><Compile Include="LiveTv\ChannelInfoDto.cs" />+ <Compile Include="LiveTv\ChannelType.cs" /><Compile Include="LiveTv\LiveTvServiceInfo.cs" /><Compile Include="Net\WebSocketMessage.cs" /><Compile Include="Net\WebSocketMessageType.cs" />diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.csindex 7a16747fbe..d073521496 100644--- a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs+++ b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs@@ -109,7 +109,7 @@ namespace MediaBrowser.Server.Implementations.Drawingvar quality = options.Quality ?? 90;- var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, options.OutputFormat, options.Indicator, options.PercentPlayed, options.BackgroundColor);+ var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, options.OutputFormat, options.AddPlayedIndicator, options.PercentPlayed, options.BackgroundColor);try{@@ -180,7 +180,7 @@ namespace MediaBrowser.Server.Implementations.DrawingthumbnailGraph.DrawImage(originalImage, 0, 0, newWidth, newHeight);- DrawIndicator(thumbnailGraph, newWidth, newHeight, options.Indicator, options.PercentPlayed);+ DrawIndicator(thumbnailGraph, newWidth, newHeight, options);var outputFormat = GetOutputFormat(originalImage, options.OutputFormat);@@ -277,28 +277,31 @@ namespace MediaBrowser.Server.Implementations.Drawing/// <param name="graphics">The graphics.</param>/// <param name="imageWidth">Width of the image.</param>/// <param name="imageHeight">Height of the image.</param>- /// <param name="indicator">The indicator.</param>- /// <param name="percentPlayed">The percent played.</param>- private void DrawIndicator(Graphics graphics, int imageWidth, int imageHeight, ImageOverlay? indicator, int percentPlayed)+ /// <param name="options">The options.</param>+ private void DrawIndicator(Graphics graphics, int imageWidth, int imageHeight, ImageProcessingOptions options){- if (!indicator.HasValue)+ if (!options.AddPlayedIndicator && !options.PercentPlayed.HasValue){return;}try{- if (indicator.Value == ImageOverlay.Played)+ var percentOffset = 0;++ if (options.AddPlayedIndicator){var currentImageSize = new Size(imageWidth, imageHeight);new WatchedIndicatorDrawer().Process(graphics, currentImageSize);++ percentOffset = 0 - WatchedIndicatorDrawer.IndicatorWidth;}- if (indicator.Value == ImageOverlay.PercentPlayed)+ if (options.PercentPlayed.HasValue){var currentImageSize = new Size(imageWidth, imageHeight);- new PercentPlayedDrawer().Process(graphics, currentImageSize, percentPlayed);+ new PercentPlayedDrawer().Process(graphics, currentImageSize, options.PercentPlayed.Value, percentOffset);}}catch (Exception ex)@@ -400,7 +403,7 @@ namespace MediaBrowser.Server.Implementations.Drawing/// <summary>/// Gets the cache file path based on a set of parameters/// </summary>- private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageOutputFormat format, ImageOverlay? overlay, int percentPlayed, string backgroundColor)+ private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageOutputFormat format, bool addPlayedIndicator, int? percentPlayed, string backgroundColor){var filename = originalPath;@@ -417,10 +420,14 @@ namespace MediaBrowser.Server.Implementations.Drawingfilename += "f=" + format;}- if (overlay.HasValue)+ if (addPlayedIndicator)+ {+ filename += "pl=true";+ }++ if (percentPlayed.HasValue){- filename += "o=" + overlay.Value;- filename += "p=" + percentPlayed;+ filename += "p=" + percentPlayed.Value;}if (!string.IsNullOrEmpty(backgroundColor))diff --git a/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs b/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.csindex 3558244584..e2f5b6129c 100644--- a/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs+++ b/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs@@ -10,9 +10,9 @@ namespace MediaBrowser.Server.Implementations.Drawingprivate const int FontSize = 30;private readonly CultureInfo _usCulture = new CultureInfo("en-US");- public void Process(Graphics graphics, Size imageSize, int percent)+ public void Process(Graphics graphics, Size imageSize, int percent, int rightOffset){- var x = imageSize.Width - IndicatorWidth;+ var x = imageSize.Width - IndicatorWidth + rightOffset;using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 102, 192, 16))){@@ -20,7 +20,7 @@ namespace MediaBrowser.Server.Implementations.Drawingvar text = string.Format("{0}%", percent.ToString(_usCulture));- x = imageSize.Width - (percent < 10 ? 66 : 75);+ x = imageSize.Width - (percent < 10 ? 66 : 75) + rightOffset;using (var font = new Font(FontFamily.GenericSansSerif, FontSize, FontStyle.Regular, GraphicsUnit.Pixel)){diff --git a/MediaBrowser.Server.Implementations/Drawing/WatchedIndicatorDrawer.cs b/MediaBrowser.Server.Implementations/Drawing/WatchedIndicatorDrawer.csindex 921494dba6..c889db3044 100644--- a/MediaBrowser.Server.Implementations/Drawing/WatchedIndicatorDrawer.cs+++ b/MediaBrowser.Server.Implementations/Drawing/WatchedIndicatorDrawer.cs@@ -5,15 +5,16 @@ namespace MediaBrowser.Server.Implementations.Drawingpublic class WatchedIndicatorDrawer{private const int IndicatorHeight = 50;+ public const int IndicatorWidth = 50;private const int FontSize = 50;public void Process(Graphics graphics, Size imageSize){- var x = imageSize.Width - IndicatorHeight;+ var x = imageSize.Width - IndicatorWidth;using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 204, 51, 51))){- graphics.FillRectangle(backdroundBrush, x, 0, IndicatorHeight, IndicatorHeight);+ graphics.FillRectangle(backdroundBrush, x, 0, IndicatorWidth, IndicatorHeight);const string text = "a";diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.csindex 87b02816f7..34be46d726 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs@@ -38,7 +38,8 @@ namespace MediaBrowser.Server.Implementations.LiveTvreturn new ChannelInfoDto{Name = info.Name,- ServiceName = info.ServiceName+ ServiceName = info.ServiceName,+ ChannelType = info.ChannelType};}}