소스 검색

support video_ts.nfo

Luke Pulverenti 10 년 전
부모
커밋
d2949d6e03

+ 8 - 1
Emby.Drawing/ImageMagick/ImageMagickEncoder.cs

@@ -115,9 +115,16 @@ namespace Emby.Drawing.ImageMagick
             }
         }
 
+        private bool HasTransparency(string path)
+        {
+            var ext = Path.GetExtension(path);
+
+            return string.Equals(ext, ".png", StringComparison.OrdinalIgnoreCase);
+        }
+
         public void EncodeImage(string inputPath, string outputPath, int width, int height, int quality, ImageProcessingOptions options)
         {
-            if (string.IsNullOrWhiteSpace(options.BackgroundColor))
+            if (string.IsNullOrWhiteSpace(options.BackgroundColor) && !HasTransparency(inputPath))
             {
                 using (var originalImage = new MagickWand(inputPath))
                 {

+ 22 - 1
MediaBrowser.Controller/Providers/ItemInfo.cs

@@ -1,9 +1,30 @@
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Model.Entities;
+
 namespace MediaBrowser.Controller.Providers
 {
     public class ItemInfo
     {
-        public string Path { get; set; }
+        public ItemInfo()
+        {
+        }
+
+        public ItemInfo(IHasMetadata item)
+        {
+            Path = item.Path;
+            ContainingFolderPath = item.ContainingFolderPath;
+            IsInMixedFolder = item.IsInMixedFolder;
 
+            var video = item as Video;
+            if (video != null)
+            {
+                VideoType = video.VideoType;
+            }
+        }
+
+        public string Path { get; set; }
+        public string ContainingFolderPath { get; set; }
+        public VideoType VideoType { get; set; }
         public bool IsInMixedFolder { get; set; }
     }
 }

+ 1 - 1
MediaBrowser.LocalMetadata/BaseXmlProvider.cs

@@ -58,7 +58,7 @@ namespace MediaBrowser.LocalMetadata
 
         public bool HasChanged(IHasMetadata item, IDirectoryService directoryService, DateTime date)
         {
-            var file = GetXmlFile(new ItemInfo { IsInMixedFolder = item.IsInMixedFolder, Path = item.Path }, directoryService);
+            var file = GetXmlFile(new ItemInfo(item), directoryService);
 
             if (file == null)
             {

+ 3 - 25
MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs

@@ -2,13 +2,10 @@
 using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.LiveTv;
 using MediaBrowser.Controller.MediaEncoding;
 using MediaBrowser.Controller.Session;
 using MediaBrowser.MediaEncoding.Subtitles;
 using MediaBrowser.Model.Configuration;
-using MediaBrowser.Model.Dlna;
-using MediaBrowser.Model.Drawing;
 using MediaBrowser.Model.Dto;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.IO;
@@ -39,7 +36,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
         protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
 
-        public BaseEncoder(MediaEncoder mediaEncoder,
+        protected BaseEncoder(MediaEncoder mediaEncoder,
             ILogger logger,
             IServerConfigurationManager configurationManager,
             IFileSystem fileSystem,
@@ -64,7 +61,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
             IProgress<double> progress,
             CancellationToken cancellationToken)
         {
-            var encodingJob = await new EncodingJobFactory(Logger, LibraryManager, MediaSourceManager)
+            var encodingJob = await new EncodingJobFactory(Logger, LibraryManager, MediaSourceManager, ConfigurationManager)
                 .CreateJob(options, IsVideoEncoder, progress, cancellationToken).ConfigureAwait(false);
 
             encodingJob.OutputFilePath = GetOutputFilePath(encodingJob);
@@ -305,25 +302,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
             return job.Options.CpuCoreLimit ?? 0;
         }
 
-        protected EncodingQuality GetQualitySetting()
-        {
-            var quality = GetEncodingOptions().EncodingQuality;
-
-            if (quality == EncodingQuality.Auto)
-            {
-                var cpuCount = Environment.ProcessorCount;
-
-                if (cpuCount >= 4)
-                {
-                    //return EncodingQuality.HighQuality;
-                }
-
-                return EncodingQuality.HighSpeed;
-            }
-
-            return quality;
-        }
-
         protected string GetInputModifier(EncodingJob job, bool genPts = true)
         {
             var inputModifier = string.Empty;
@@ -543,7 +521,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
             var isVc1 = state.VideoStream != null &&
                 string.Equals(state.VideoStream.Codec, "vc1", StringComparison.OrdinalIgnoreCase);
 
-            var qualitySetting = GetQualitySetting();
+            var qualitySetting = state.Quality;
 
             if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase))
             {

+ 2 - 1
MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs

@@ -1,5 +1,6 @@
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.MediaEncoding;
+using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Dlna;
 using MediaBrowser.Model.Drawing;
 using MediaBrowser.Model.Dto;
@@ -24,7 +25,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
         public Stream LogFileStream { get; set; }
         public IProgress<double> Progress { get; set; }
         public TaskCompletionSource<bool> TaskCompletionSource;
-
+        public EncodingQuality Quality { get; set; }
         public EncodingJobOptions Options { get; set; }
         public string InputContainer { get; set; }
         public MediaSourceInfo MediaSource { get; set; }

+ 33 - 4
MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs

@@ -1,8 +1,7 @@
-using System.IO;
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Common.Configuration;
 using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.LiveTv;
 using MediaBrowser.Controller.MediaEncoding;
+using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Dlna;
 using MediaBrowser.Model.Dto;
 using MediaBrowser.Model.Entities;
@@ -22,14 +21,16 @@ namespace MediaBrowser.MediaEncoding.Encoder
         private readonly ILogger _logger;
         private readonly ILibraryManager _libraryManager;
         private readonly IMediaSourceManager _mediaSourceManager;
+        private readonly IConfigurationManager _config;
 
         protected static readonly CultureInfo UsCulture = new CultureInfo("en-US");
         
-        public EncodingJobFactory(ILogger logger, ILibraryManager libraryManager, IMediaSourceManager mediaSourceManager)
+        public EncodingJobFactory(ILogger logger, ILibraryManager libraryManager, IMediaSourceManager mediaSourceManager, IConfigurationManager config)
         {
             _logger = logger;
             _libraryManager = libraryManager;
             _mediaSourceManager = mediaSourceManager;
+            _config = config;
         }
 
         public async Task<EncodingJob> CreateJob(EncodingJobOptions options, bool isVideoRequest, IProgress<double> progress, CancellationToken cancellationToken)
@@ -95,6 +96,10 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
             TryStreamCopy(state, request);
 
+            state.Quality = options.Context == EncodingContext.Static ? 
+                EncodingQuality.MaxQuality :
+                GetQualitySetting();
+
             return state;
         }
 
@@ -194,6 +199,30 @@ namespace MediaBrowser.MediaEncoding.Encoder
             state.MediaSource = mediaSource;
         }
 
+        protected EncodingQuality GetQualitySetting()
+        {
+            var quality = GetEncodingOptions().EncodingQuality;
+
+            if (quality == EncodingQuality.Auto)
+            {
+                var cpuCount = Environment.ProcessorCount;
+
+                if (cpuCount >= 4)
+                {
+                    //return EncodingQuality.HighQuality;
+                }
+
+                return EncodingQuality.HighSpeed;
+            }
+
+            return quality;
+        }
+
+        protected EncodingOptions GetEncodingOptions()
+        {
+            return _config.GetConfiguration<EncodingOptions>("encoding");
+        }
+
         /// <summary>
         /// Infers the video codec.
         /// </summary>

+ 1 - 1
MediaBrowser.Providers/Manager/MetadataService.cs

@@ -378,7 +378,7 @@ namespace MediaBrowser.Providers.Manager
                 var providerName = provider.GetType().Name;
                 Logger.Debug("Running {0} for {1}", providerName, logName);
 
-                var itemInfo = new ItemInfo { Path = item.Path, IsInMixedFolder = item.IsInMixedFolder };
+                var itemInfo = new ItemInfo(item);
 
                 try
                 {

+ 0 - 16
MediaBrowser.WebDashboard/Api/PackageCreator.cs

@@ -437,8 +437,6 @@ namespace MediaBrowser.WebDashboard.Api
                                 "connectlogin.js",
                                 "dashboardgeneral.js",
                                 "dashboardpage.js",
-                                "device.js",
-                                "devices.js",
                                 "devicesupload.js",
                                 "directorybrowser.js",
                                 "dlnaprofile.js",
@@ -458,16 +456,10 @@ namespace MediaBrowser.WebDashboard.Api
                                 "favorites.js",
                                 "forgotpassword.js",
                                 "forgotpasswordpin.js",
-                                "gamesrecommendedpage.js",
-                                "gamesystemspage.js",
-                                "gamespage.js",
-                                "gamegenrepage.js",
-                                "gamestudiospage.js",
                                 "homelatest.js",
                                 "indexpage.js",
                                 "itembynamedetailpage.js",
                                 "itemdetailpage.js",
-                                "itemlistpage.js",
                                 "kids.js",
                                 "librarypathmapping.js",
                                 "reports.js",
@@ -506,9 +498,7 @@ namespace MediaBrowser.WebDashboard.Api
                                 "musicalbums.js",
                                 "musicalbumartists.js",
                                 "musicartists.js",
-                                "musicgenres.js",
                                 "musicrecommended.js",
-                                "musicvideos.js",
 
                                 "mypreferencesdisplay.js",
                                 "mypreferenceslanguages.js",
@@ -529,22 +519,16 @@ namespace MediaBrowser.WebDashboard.Api
                                 "scheduledtaskspage.js",
                                 "search.js",
                                 "selectserver.js",
-                                "serversecurity.js",
                                 "songs.js",
                                 "streamingsettings.js",
                                 "supporterkeypage.js",
                                 "supporterpage.js",
                                 "syncactivity.js",
                                 "syncsettings.js",
-                                "episodes.js",
                                 "thememediaplayer.js",
-                                "tvgenres.js",
                                 "tvlatest.js",
-                                "tvpeople.js",
                                 "tvrecommended.js",
                                 "tvshows.js",
-                                "tvstudios.js",
-                                "tvupcoming.js",
                                 "useredit.js",
                                 "usernew.js",
                                 "myprofile.js",

+ 3 - 0
MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj

@@ -219,6 +219,9 @@
     <Content Include="dashboard-ui\cordovaindex.html">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
+    <Content Include="dashboard-ui\thirdparty\cordova\imagestore.js">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
     <Content Include="dashboard-ui\thirdparty\cordova\remotecontrols.js">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>

+ 5 - 0
MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs

@@ -952,6 +952,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
                                     var userData = GetOrAdd(userDataList, userDataUserId);
 
                                     userData.PlayCount = parsedValue;
+
+                                    if (parsedValue > 0)
+                                    {
+                                        userData.Played = true;
+                                    }
                                 }
                             }
                         }

+ 1 - 1
MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs

@@ -59,7 +59,7 @@ namespace MediaBrowser.XbmcMetadata.Providers
 
         public bool HasChanged(IHasMetadata item, IDirectoryService directoryService, DateTime date)
         {
-            var file = GetXmlFile(new ItemInfo { IsInMixedFolder = item.IsInMixedFolder, Path = item.Path }, directoryService);
+            var file = GetXmlFile(new ItemInfo(item), directoryService);
 
             if (file == null)
             {

+ 5 - 15
MediaBrowser.XbmcMetadata/Providers/BaseVideoNfoProvider.cs

@@ -5,8 +5,10 @@ using MediaBrowser.Controller.Providers;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.XbmcMetadata.Parsers;
+using MediaBrowser.XbmcMetadata.Savers;
 using System.Collections.Generic;
 using System.IO;
+using System.Linq;
 using System.Threading;
 
 namespace MediaBrowser.XbmcMetadata.Providers
@@ -35,21 +37,9 @@ namespace MediaBrowser.XbmcMetadata.Providers
 
         protected override FileSystemInfo GetXmlFile(ItemInfo info, IDirectoryService directoryService)
         {
-            var path = GetMovieSavePath(info, FileSystem);
-
-            return directoryService.GetFile(path);
-        }
-
-        public static string GetMovieSavePath(ItemInfo item, IFileSystem fileSystem)
-        {
-            if (Directory.Exists(item.Path))
-            {
-                var path = item.Path;
-
-                return Path.Combine(path, Path.GetFileName(path) + ".nfo");
-            }
-
-            return Path.ChangeExtension(item.Path, ".nfo");
+            return MovieNfoSaver.GetMovieSavePaths(info, FileSystem)
+                .Select(directoryService.GetFile)
+                .FirstOrDefault(i => i != null);
         }
     }
 }

+ 19 - 6
MediaBrowser.XbmcMetadata/Savers/MovieNfoSaver.cs

@@ -4,10 +4,12 @@ using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities.Movies;
 using MediaBrowser.Controller.Entities.TV;
 using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Providers;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Logging;
 using System.Collections.Generic;
 using System.IO;
+using System.Linq;
 using System.Xml;
 
 namespace MediaBrowser.XbmcMetadata.Savers
@@ -20,21 +22,32 @@ namespace MediaBrowser.XbmcMetadata.Savers
 
         protected override string GetLocalSavePath(IHasMetadata item)
         {
-            return GetMovieSavePath(item, FileSystem);
+            return GetMovieSavePaths(new ItemInfo(item), FileSystem).FirstOrDefault();
         }
 
-        public static string GetMovieSavePath(IHasMetadata item, IFileSystem fileSystem)
+        public static List<string> GetMovieSavePaths(ItemInfo item, IFileSystem fileSystem)
         {
-            var video = (Video)item;
+            var list = new List<string>();
 
-            if (video.VideoType == VideoType.Dvd || video.VideoType == VideoType.BluRay || video.VideoType == VideoType.HdDvd)
+            if (item.VideoType == VideoType.Dvd)
             {
                 var path = item.ContainingFolderPath;
 
-                return Path.Combine(path, Path.GetFileName(path) + ".nfo");
+                list.Add(Path.Combine(path, "VIDEO_TS.nfo"));
             }
 
-            return Path.ChangeExtension(item.Path, ".nfo");
+            if (item.VideoType == VideoType.Dvd || item.VideoType == VideoType.BluRay || item.VideoType == VideoType.HdDvd)
+            {
+                var path = item.ContainingFolderPath;
+
+                list.Add(Path.Combine(path, Path.GetFileName(path) + ".nfo"));
+            }
+            else
+            {
+                list.Add(Path.ChangeExtension(item.Path, ".nfo"));
+            }
+
+            return list;
         }
 
         protected override string GetRootElementName(IHasMetadata item)