diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-10-31 00:28:23 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-10-31 00:28:23 -0400 |
| commit | 3bf72b71b35c031e89a1b45ddc717e3d5d45afb0 (patch) | |
| tree | 35ee919a685c70fff79125a98a4286c5a529422c | |
| parent | 0579f245e47334094c03583defc1baf434de2b36 (diff) | |
consolidate internal interfaces
28 files changed, 113 insertions, 300 deletions
diff --git a/Emby.Common.Implementations/IO/ManagedFileSystem.cs b/Emby.Common.Implementations/IO/ManagedFileSystem.cs index 6317fc08b..bfc316d3f 100644 --- a/Emby.Common.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Common.Implementations/IO/ManagedFileSystem.cs @@ -408,13 +408,13 @@ namespace Emby.Common.Implementations.IO { if (isHidden) { - FileAttributes attributes = File.GetAttributes(path); - attributes = RemoveAttribute(attributes, FileAttributes.Hidden); - File.SetAttributes(path, attributes); + File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden); } else { - File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden); + FileAttributes attributes = File.GetAttributes(path); + attributes = RemoveAttribute(attributes, FileAttributes.Hidden); + File.SetAttributes(path, attributes); } } } diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 3235b7efa..47c9357fd 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -780,40 +780,38 @@ namespace Emby.Drawing // All enhanced images are saved as png to allow transparency var enhancedImagePath = GetCachePath(EnhancedImageCachePath, cacheGuid + ".png"); - var semaphore = GetLock(enhancedImagePath); - - await semaphore.WaitAsync().ConfigureAwait(false); - // Check again in case of contention if (_fileSystem.FileExists(enhancedImagePath)) { - semaphore.Release(); return enhancedImagePath; } - var imageProcessingLockTaken = false; + _fileSystem.CreateDirectory(Path.GetDirectoryName(enhancedImagePath)); - try - { - _fileSystem.CreateDirectory(Path.GetDirectoryName(enhancedImagePath)); + var tmpPath = Path.Combine(_appPaths.TempDirectory, Path.ChangeExtension(Guid.NewGuid().ToString(), Path.GetExtension(enhancedImagePath))); + _fileSystem.CreateDirectory(Path.GetDirectoryName(tmpPath)); - await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false); + await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false); - imageProcessingLockTaken = true; + try + { + await ExecuteImageEnhancers(supportedEnhancers, originalImagePath, tmpPath, item, imageType, imageIndex).ConfigureAwait(false); - await ExecuteImageEnhancers(supportedEnhancers, originalImagePath, enhancedImagePath, item, imageType, imageIndex).ConfigureAwait(false); + try + { + File.Copy(tmpPath, enhancedImagePath, true); + } + catch + { + + } } finally { - if (imageProcessingLockTaken) - { - _imageProcessingSemaphore.Release(); - } - - semaphore.Release(); + _imageProcessingSemaphore.Release(); } - return enhancedImagePath; + return tmpPath; } /// <summary> @@ -839,21 +837,6 @@ namespace Emby.Drawing } /// <summary> - /// The _semaphoreLocks - /// </summary> - private readonly ConcurrentDictionary<string, SemaphoreSlim> _semaphoreLocks = new ConcurrentDictionary<string, SemaphoreSlim>(); - - /// <summary> - /// Gets the lock. - /// </summary> - /// <param name="filename">The filename.</param> - /// <returns>System.Object.</returns> - private SemaphoreSlim GetLock(string filename) - { - return _semaphoreLocks.GetOrAdd(filename, key => new SemaphoreSlim(1, 1)); - } - - /// <summary> /// Gets the cache path. /// </summary> /// <param name="path">The path.</param> diff --git a/MediaBrowser.Common/MediaBrowser.Common.xproj b/MediaBrowser.Common/MediaBrowser.Common.xproj deleted file mode 100644 index 797070193..000000000 --- a/MediaBrowser.Common/MediaBrowser.Common.xproj +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="14.0.25420" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25420</VisualStudioVersion> - <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> - </PropertyGroup> - <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> - <PropertyGroup Label="Globals"> - <ProjectGuid>7d5d3d18-3b43-43e6-a5a9-ac734430affd</ProjectGuid> - <RootNamespace>MediaBrowser.Common</RootNamespace> - <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> - <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> - </PropertyGroup> - - <PropertyGroup> - <SchemaVersion>2.0</SchemaVersion> - </PropertyGroup> - <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> -</Project>
\ No newline at end of file diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index e9a3eb512..cd4461608 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -22,8 +22,7 @@ namespace MediaBrowser.Controller.Entities.Audio IHasArtist, IHasMusicGenres, IHasLookupInfo<SongInfo>, - IHasMediaSources, - IThemeMedia + IHasMediaSources { public List<ChannelMediaInfo> ChannelMediaSources { get; set; } @@ -39,7 +38,7 @@ namespace MediaBrowser.Controller.Entities.Audio public List<string> AlbumArtists { get; set; } [IgnoreDataMember] - public bool IsThemeMedia + public override bool IsThemeMedia { get { diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index ea3a7f79c..8211d89d2 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -203,6 +203,16 @@ namespace MediaBrowser.Controller.Entities get { return PremiereDate.HasValue && PremiereDate.Value.ToLocalTime().Date >= DateTime.Now.Date; } } + [IgnoreDataMember] + public virtual bool IsThemeMedia + { + get + { + return false; + } + } + + [IgnoreDataMember] public string OriginalTitle { get; set; } /// <summary> diff --git a/MediaBrowser.Controller/Entities/IHasOriginalTitle.cs b/MediaBrowser.Controller/Entities/IHasOriginalTitle.cs deleted file mode 100644 index 6f5cb59bc..000000000 --- a/MediaBrowser.Controller/Entities/IHasOriginalTitle.cs +++ /dev/null @@ -1,8 +0,0 @@ - -namespace MediaBrowser.Controller.Entities -{ - public interface IHasOriginalTitle - { - string OriginalTitle { get; set; } - } -} diff --git a/MediaBrowser.Controller/Entities/IThemeMedia.cs b/MediaBrowser.Controller/Entities/IThemeMedia.cs deleted file mode 100644 index b2eff230f..000000000 --- a/MediaBrowser.Controller/Entities/IThemeMedia.cs +++ /dev/null @@ -1,8 +0,0 @@ - -namespace MediaBrowser.Controller.Entities -{ - public interface IThemeMedia - { - bool IsThemeMedia { get; } - } -} diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 5fee87b7a..6ae4cf9f1 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Entities.Movies /// <summary> /// Class Movie /// </summary> - public class Movie : Video, IHasSpecialFeatures, IHasBudget, IHasTrailers, IHasAwards, IHasMetascore, IHasLookupInfo<MovieInfo>, ISupportsBoxSetGrouping, IHasOriginalTitle + public class Movie : Video, IHasSpecialFeatures, IHasBudget, IHasTrailers, IHasAwards, IHasMetascore, IHasLookupInfo<MovieInfo>, ISupportsBoxSetGrouping { public List<Guid> SpecialFeatureIds { get; set; } diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 64520646b..cca8e3c19 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Entities.TV /// <summary> /// Class Series /// </summary> - public class Series : Folder, IHasTrailers, IHasDisplayOrder, IHasLookupInfo<SeriesInfo>, IMetadataContainer, IHasOriginalTitle + public class Series : Folder, IHasTrailers, IHasDisplayOrder, IHasLookupInfo<SeriesInfo>, IMetadataContainer { public int? AnimeSeriesIndex { get; set; } diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 08fd86743..b67e7ffe3 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -10,7 +10,7 @@ namespace MediaBrowser.Controller.Entities /// <summary> /// Class Trailer /// </summary> - public class Trailer : Video, IHasBudget, IHasMetascore, IHasOriginalTitle, IHasLookupInfo<TrailerInfo> + public class Trailer : Video, IHasBudget, IHasMetascore, IHasLookupInfo<TrailerInfo> { public Trailer() { diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index d86557840..6b8c894c8 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -25,8 +25,7 @@ namespace MediaBrowser.Controller.Entities public class Video : BaseItem, IHasAspectRatio, ISupportsPlaceHolders, - IHasMediaSources, - IThemeMedia + IHasMediaSources { [IgnoreDataMember] public string PrimaryVersionId { get; set; } @@ -37,7 +36,7 @@ namespace MediaBrowser.Controller.Entities public List<ChannelMediaInfo> ChannelMediaSources { get; set; } [IgnoreDataMember] - public bool IsThemeMedia + public override bool IsThemeMedia { get { @@ -114,12 +113,6 @@ namespace MediaBrowser.Controller.Entities public string ShortcutPath { get; set; } /// <summary> - /// Gets or sets the video bit rate. - /// </summary> - /// <value>The video bit rate.</value> - public int? VideoBitRate { get; set; } - - /// <summary> /// Gets or sets the default index of the video stream. /// </summary> /// <value>The default index of the video stream.</value> diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index d588f6127..0f26ad5ec 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -113,7 +113,6 @@ <Compile Include="Entities\KeywordExtensions.cs" /> <Compile Include="Entities\IHasMediaSources.cs" /> <Compile Include="Entities\IHasMetascore.cs" /> - <Compile Include="Entities\IHasOriginalTitle.cs" /> <Compile Include="Entities\IHasProgramAttributes.cs" /> <Compile Include="Entities\IHasScreenshots.cs" /> <Compile Include="Entities\IHasSeries.cs" /> @@ -129,7 +128,6 @@ <Compile Include="Entities\ISupportsBoxSetGrouping.cs" /> <Compile Include="Entities\ISupportsPlaceHolders.cs" /> <Compile Include="Entities\ItemImageInfo.cs" /> - <Compile Include="Entities\IThemeMedia.cs" /> <Compile Include="Entities\LinkedChild.cs" /> <Compile Include="Entities\MusicVideo.cs" /> <Compile Include="Entities\IHasAwards.cs" /> diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.xproj b/MediaBrowser.Controller/MediaBrowser.Controller.xproj deleted file mode 100644 index 34994695d..000000000 --- a/MediaBrowser.Controller/MediaBrowser.Controller.xproj +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="14.0.25420" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25420</VisualStudioVersion> - <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> - </PropertyGroup> - <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> - <PropertyGroup Label="Globals"> - <ProjectGuid>f9fe523c-6eb0-4e4d-ae26-de5c7982b063</ProjectGuid> - <RootNamespace>MediaBrowser.Controller</RootNamespace> - <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> - <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> - </PropertyGroup> - - <PropertyGroup> - <SchemaVersion>2.0</SchemaVersion> - </PropertyGroup> - <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> -</Project>
\ No newline at end of file diff --git a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs b/MediaBrowser.LocalMetadata/BaseXmlProvider.cs index 9f5a12104..50e9de727 100644 --- a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs +++ b/MediaBrowser.LocalMetadata/BaseXmlProvider.cs @@ -96,7 +96,5 @@ namespace MediaBrowser.LocalMetadata return "Emby Xml"; } } - - internal static readonly SemaphoreSlim XmlParsingResourcePool = new SemaphoreSlim(4, 4); } } diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs index d54e41308..d78ddc8ea 100644 --- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs @@ -163,13 +163,9 @@ namespace MediaBrowser.LocalMetadata.Parsers { var val = reader.ReadElementContentAsString(); - var hasOriginalTitle = item as IHasOriginalTitle; - if (hasOriginalTitle != null) + if (!string.IsNullOrEmpty(val)) { - if (!string.IsNullOrEmpty(hasOriginalTitle.OriginalTitle)) - { - hasOriginalTitle.OriginalTitle = val; - } + item.OriginalTitle = val; } break; } diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs index 9cfca3086..3a8a4c9f8 100644 --- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs +++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs @@ -344,58 +344,52 @@ namespace MediaBrowser.LocalMetadata.Savers writer.WriteElementString("Overview", item.Overview); } - //var hasOriginalTitle = item as IHasOriginalTitle; - //if (hasOriginalTitle != null) - //{ - // if (!string.IsNullOrEmpty(hasOriginalTitle.OriginalTitle)) - // { - // builder.Append("<OriginalTitle>" + SecurityElement.Escape(hasOriginalTitle.OriginalTitle) + "</OriginalTitle>"); - // } - //} - - //if (!string.IsNullOrEmpty(item.ShortOverview)) - //{ - // builder.Append("<ShortOverview><![CDATA[" + item.ShortOverview + "]]></ShortOverview>"); - //} - - //if (!string.IsNullOrEmpty(item.CustomRating)) - //{ - // builder.Append("<CustomRating>" + SecurityElement.Escape(item.CustomRating) + "</CustomRating>"); - //} + if (!string.IsNullOrEmpty(item.OriginalTitle)) + { + writer.WriteElementString("OriginalTitle", item.OriginalTitle); + } + if (!string.IsNullOrEmpty(item.ShortOverview)) + { + writer.WriteElementString("ShortOverview", item.ShortOverview); + } + if (!string.IsNullOrEmpty(item.CustomRating)) + { + writer.WriteElementString("CustomRating", item.CustomRating); + } - //if (!string.IsNullOrEmpty(item.Name) && !(item is Episode)) - //{ - // builder.Append("<LocalTitle>" + SecurityElement.Escape(item.Name) + "</LocalTitle>"); - //} + if (!string.IsNullOrEmpty(item.Name) && !(item is Episode)) + { + writer.WriteElementString("LocalTitle", item.Name); + } - //if (!string.IsNullOrEmpty(item.ForcedSortName)) - //{ - // builder.Append("<SortTitle>" + SecurityElement.Escape(item.ForcedSortName) + "</SortTitle>"); - //} + if (!string.IsNullOrEmpty(item.ForcedSortName)) + { + writer.WriteElementString("SortTitle", item.ForcedSortName); + } - //if (item.PremiereDate.HasValue) - //{ - // if (item is Person) - // { - // builder.Append("<BirthDate>" + SecurityElement.Escape(item.PremiereDate.Value.ToLocalTime().ToString("yyyy-MM-dd")) + "</BirthDate>"); - // } - // else if (!(item is Episode)) - // { - // builder.Append("<PremiereDate>" + SecurityElement.Escape(item.PremiereDate.Value.ToLocalTime().ToString("yyyy-MM-dd")) + "</PremiereDate>"); - // } - //} + if (item.PremiereDate.HasValue) + { + if (item is Person) + { + writer.WriteElementString("BirthDate", item.PremiereDate.Value.ToLocalTime().ToString("yyyy-MM-dd")); + } + else if (!(item is Episode)) + { + writer.WriteElementString("PremiereDate", item.PremiereDate.Value.ToLocalTime().ToString("yyyy-MM-dd")); + } + } - //if (item.EndDate.HasValue) - //{ - // if (item is Person) - // { - // builder.Append("<DeathDate>" + SecurityElement.Escape(item.EndDate.Value.ToString("yyyy-MM-dd")) + "</DeathDate>"); - // } - // else if (!(item is Episode)) - // { - // builder.Append("<EndDate>" + SecurityElement.Escape(item.EndDate.Value.ToString("yyyy-MM-dd")) + "</EndDate>"); - // } - //} + if (item.EndDate.HasValue) + { + if (item is Person) + { + writer.WriteElementString("DeathDate", item.EndDate.Value.ToLocalTime().ToString("yyyy-MM-dd")); + } + else if (!(item is Episode)) + { + writer.WriteElementString("EndDate", item.EndDate.Value.ToLocalTime().ToString("yyyy-MM-dd")); + } + } //var hasTrailers = item as IHasTrailers; //if (hasTrailers != null) @@ -612,6 +606,8 @@ namespace MediaBrowser.LocalMetadata.Savers //{ // AddShares(hasShares, builder); //} + + AddMediaInfo(item, writer); } public static void AddShares(IHasShares item, StringBuilder builder) @@ -635,33 +631,31 @@ namespace MediaBrowser.LocalMetadata.Savers /// Appends the media info. /// </summary> /// <typeparam name="T"></typeparam> - public static void AddMediaInfo<T>(T item, StringBuilder builder, IItemRepository itemRepository) + public static void AddMediaInfo<T>(T item, XmlWriter writer) where T : BaseItem { var video = item as Video; if (video != null) { - //AddChapters(video, builder, itemRepository); - if (video.Video3DFormat.HasValue) { switch (video.Video3DFormat.Value) { case Video3DFormat.FullSideBySide: - builder.Append("<Format3D>FSBS</Format3D>"); + writer.WriteElementString("Format3D", "FSBS"); break; case Video3DFormat.FullTopAndBottom: - builder.Append("<Format3D>FTAB</Format3D>"); + writer.WriteElementString("Format3D", "FTAB"); break; case Video3DFormat.HalfSideBySide: - builder.Append("<Format3D>HSBS</Format3D>"); + writer.WriteElementString("Format3D", "HSBS"); break; case Video3DFormat.HalfTopAndBottom: - builder.Append("<Format3D>HTAB</Format3D>"); + writer.WriteElementString("Format3D", "HTAB"); break; case Video3DFormat.MVC: - builder.Append("<Format3D>MVC</Format3D>"); + writer.WriteElementString("Format3D", "MVC"); break; } } diff --git a/MediaBrowser.Model/Entities/BaseItemInfo.cs b/MediaBrowser.Model/Entities/BaseItemInfo.cs index af9091a78..db6c4b3fa 100644 --- a/MediaBrowser.Model/Entities/BaseItemInfo.cs +++ b/MediaBrowser.Model/Entities/BaseItemInfo.cs @@ -132,6 +132,8 @@ namespace MediaBrowser.Model.Entities /// <value>The album.</value> public string Album { get; set; } + public bool IsThemeMedia { get; set; } + /// <summary> /// Gets or sets the artists. /// </summary> diff --git a/MediaBrowser.Model/MediaBrowser.Model.xproj b/MediaBrowser.Model/MediaBrowser.Model.xproj deleted file mode 100644 index d4777935e..000000000 --- a/MediaBrowser.Model/MediaBrowser.Model.xproj +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="14.0.25420" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25420</VisualStudioVersion> - <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> - </PropertyGroup> - <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> - <PropertyGroup Label="Globals"> - <ProjectGuid>a02a9262-f007-4464-bb32-02f5f2593651</ProjectGuid> - <RootNamespace>MediaBrowser.Model</RootNamespace> - <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> - <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> - </PropertyGroup> - - <PropertyGroup> - <SchemaVersion>2.0</SchemaVersion> - </PropertyGroup> - <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> -</Project>
\ No newline at end of file diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs index fee11d989..d65084287 100644 --- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs @@ -6,14 +6,11 @@ using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; -using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Common.IO; -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; namespace MediaBrowser.Providers.MediaInfo @@ -23,8 +20,6 @@ namespace MediaBrowser.Providers.MediaInfo /// </summary> public class AudioImageProvider : IDynamicImageProvider, IHasItemChangeMonitor { - private readonly ConcurrentDictionary<string, SemaphoreSlim> _locks = new ConcurrentDictionary<string, SemaphoreSlim>(); - private readonly IMediaEncoder _mediaEncoder; private readonly IServerConfigurationManager _config; private readonly IFileSystem _fileSystem; @@ -67,41 +62,25 @@ namespace MediaBrowser.Providers.MediaInfo if (!_fileSystem.FileExists(path)) { - var semaphore = GetLock(path); - - // Acquire a lock - await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false); - - try - { - // Check again in case it was saved while waiting for the lock - if (!_fileSystem.FileExists(path)) - { - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); - - var imageStream = imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("front", StringComparison.OrdinalIgnoreCase) != -1) ?? - imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("cover", StringComparison.OrdinalIgnoreCase) != -1) ?? - imageStreams.FirstOrDefault(); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); - var imageStreamIndex = imageStream == null ? (int?)null : imageStream.Index; + var imageStream = imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("front", StringComparison.OrdinalIgnoreCase) != -1) ?? + imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("cover", StringComparison.OrdinalIgnoreCase) != -1) ?? + imageStreams.FirstOrDefault(); - var tempFile = await _mediaEncoder.ExtractAudioImage(item.Path, imageStreamIndex, cancellationToken).ConfigureAwait(false); + var imageStreamIndex = imageStream == null ? (int?)null : imageStream.Index; - _fileSystem.CopyFile(tempFile, path, true); + var tempFile = await _mediaEncoder.ExtractAudioImage(item.Path, imageStreamIndex, cancellationToken).ConfigureAwait(false); - try - { - _fileSystem.DeleteFile(tempFile); - } - catch - { + _fileSystem.CopyFile(tempFile, path, true); - } - } + try + { + _fileSystem.DeleteFile(tempFile); } - finally + catch { - semaphore.Release(); + } } @@ -145,16 +124,6 @@ namespace MediaBrowser.Providers.MediaInfo } } - /// <summary> - /// Gets the lock. - /// </summary> - /// <param name="filename">The filename.</param> - /// <returns>SemaphoreSlim.</returns> - private SemaphoreSlim GetLock(string filename) - { - return _locks.GetOrAdd(filename, key => new SemaphoreSlim(1, 1)); - } - public string Name { get { return "Image Extractor"; } diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 45fcbc251..0a070d348 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -203,7 +203,6 @@ namespace MediaBrowser.Providers.MediaInfo var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video); - video.VideoBitRate = videoStream == null ? null : videoStream.BitRate; video.DefaultVideoStreamIndex = videoStream == null ? (int?)null : videoStream.Index; video.HasSubtitles = mediaStreams.Any(i => i.Type == MediaStreamType.Subtitle); diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs index 5da18ac60..ca701b70f 100644 --- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs @@ -13,9 +13,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Common.IO; -using MediaBrowser.Controller.IO; -using MediaBrowser.Model.IO; namespace MediaBrowser.Providers.MediaInfo { diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs index 96b8aad5d..51f5f57b3 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs @@ -123,8 +123,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints return; } - var themeMedia = item as IThemeMedia; - if (themeMedia != null && themeMedia.IsThemeMedia) + if (item.IsThemeMedia) { // Don't report theme song or local trailer playback return; @@ -156,8 +155,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints return; } - var themeMedia = item as IThemeMedia; - if (themeMedia != null && themeMedia.IsThemeMedia) + if (item.IsThemeMedia) { // Don't report theme song or local trailer playback return; diff --git a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifications.cs b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifications.cs index 8f35f0e76..f3d1dc8f9 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifications.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifications.cs @@ -256,9 +256,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications } var item = e.MediaInfo; - var themeMedia = item as IThemeMedia; - if (themeMedia != null && themeMedia.IsThemeMedia) + if ( item.IsThemeMedia) { // Don't report theme song or local trailer playback return; diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 295d78a5f..f3224127a 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -367,7 +367,6 @@ <Compile Include="Persistence\SqliteUserDataRepository.cs" /> <Compile Include="Persistence\SqliteUserRepository.cs" /> <Compile Include="Sorting\StudioComparer.cs" /> - <Compile Include="Sorting\VideoBitRateComparer.cs" /> <Compile Include="Sync\AppSyncProvider.cs" /> <Compile Include="Sync\CloudSyncProfile.cs" /> <Compile Include="Sync\IHasSyncQuality.cs" /> diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index 9326c4f43..6d86ff091 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1611,7 +1611,8 @@ namespace MediaBrowser.Server.Implementations.Session IndexNumber = item.IndexNumber, ParentIndexNumber = item.ParentIndexNumber, PremiereDate = item.PremiereDate, - ProductionYear = item.ProductionYear + ProductionYear = item.ProductionYear, + IsThemeMedia = item.IsThemeMedia }; info.PrimaryImageTag = GetImageCacheTag(item, ImageType.Primary); diff --git a/MediaBrowser.Server.Implementations/Sorting/VideoBitRateComparer.cs b/MediaBrowser.Server.Implementations/Sorting/VideoBitRateComparer.cs deleted file mode 100644 index cbf6ebac6..000000000 --- a/MediaBrowser.Server.Implementations/Sorting/VideoBitRateComparer.cs +++ /dev/null @@ -1,41 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Sorting; -using MediaBrowser.Model.Querying; - -namespace MediaBrowser.Server.Implementations.Sorting -{ - class VideoBitRateComparer : IBaseItemComparer - { - /// <summary> - /// Compares the specified x. - /// </summary> - /// <param name="x">The x.</param> - /// <param name="y">The y.</param> - /// <returns>System.Int32.</returns> - public int Compare(BaseItem x, BaseItem y) - { - return GetValue(x).CompareTo(GetValue(y)); - } - - private int GetValue(BaseItem item) - { - var video = item as Video; - - if (video != null) - { - return video.VideoBitRate ?? 0; - } - - return 0; - } - - /// <summary> - /// Gets the name. - /// </summary> - /// <value>The name.</value> - public string Name - { - get { return ItemSortBy.VideoBitRate; } - } - } -} diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 3f10220f2..ba1e2641b 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -278,13 +278,9 @@ namespace MediaBrowser.XbmcMetadata.Parsers { var val = reader.ReadElementContentAsString(); - var hasOriginalTitle = item as IHasOriginalTitle; - if (hasOriginalTitle != null) + if (!string.IsNullOrEmpty(val)) { - if (!string.IsNullOrEmpty(hasOriginalTitle.OriginalTitle)) - { - hasOriginalTitle.OriginalTitle = val; - } + item.OriginalTitle = val; } break; } diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs index c342c209a..fc5987815 100644 --- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs @@ -485,13 +485,9 @@ namespace MediaBrowser.XbmcMetadata.Savers writer.WriteElementString("title", item.Name ?? string.Empty); - var hasOriginalTitle = item as IHasOriginalTitle; - if (hasOriginalTitle != null) + if (!string.IsNullOrWhiteSpace(item.OriginalTitle)) { - if (!string.IsNullOrEmpty(hasOriginalTitle.OriginalTitle)) - { - writer.WriteElementString("originaltitle", hasOriginalTitle.OriginalTitle ?? string.Empty); - } + writer.WriteElementString("originaltitle", item.OriginalTitle); } var people = libraryManager.GetPeople(item); |
