From 07e7b13b75288e52f71f0ab171b86e14a4229d04 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Wed, 2 Jan 2019 10:55:05 +0100 Subject: [PATCH 01/20] change userid type to guid --- MediaBrowser.Model/Devices/DeviceQuery.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Model/Devices/DeviceQuery.cs b/MediaBrowser.Model/Devices/DeviceQuery.cs index 9ceea1ea8..fa2e11d4d 100644 --- a/MediaBrowser.Model/Devices/DeviceQuery.cs +++ b/MediaBrowser.Model/Devices/DeviceQuery.cs @@ -1,4 +1,6 @@  +using System; + namespace MediaBrowser.Model.Devices { public class DeviceQuery @@ -17,6 +19,6 @@ namespace MediaBrowser.Model.Devices /// Gets or sets the user identifier. /// /// The user identifier. - public string UserId { get; set; } + public Guid UserId { get; set; } } } From 96ad22a00931ffea7dba828d5a677dac3d45d83c Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 01:01:36 +0100 Subject: [PATCH 02/20] Reduce log spam and clean up EncoderValidator --- .../Encoder/EncoderValidator.cs | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index fb131f304..0f24a2370 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using MediaBrowser.Model.Diagnostics; using Microsoft.Extensions.Logging; @@ -73,7 +72,7 @@ namespace MediaBrowser.MediaEncoding.Encoder private List GetDecoders(string encoderAppPath) { - string output = string.Empty; + string output = null; try { output = GetProcessOutput(encoderAppPath, "-decoders"); @@ -83,7 +82,11 @@ namespace MediaBrowser.MediaEncoding.Encoder _logger.LogError(ex, "Error detecting available decoders"); } - var found = new List(); + if (string.IsNullOrWhiteSpace(output)) + { + return new List(); + } + var required = new[] { "mpeg2video", @@ -101,17 +104,19 @@ namespace MediaBrowser.MediaEncoding.Encoder "hevc" }; + var found = new List(); foreach (var codec in required) { var srch = " " + codec + " "; if (output.IndexOf(srch, StringComparison.OrdinalIgnoreCase) != -1) { - _logger.LogInformation("Decoder available: " + codec); found.Add(codec); } } + _logger.LogInformation("Available decoders: {Codecs}", found); + return found; } @@ -122,11 +127,16 @@ namespace MediaBrowser.MediaEncoding.Encoder { output = GetProcessOutput(encoderAppPath, "-encoders"); } - catch + catch (Exception ex) { + _logger.LogError(ex, "Error getting encoders"); + } + + if (string.IsNullOrWhiteSpace(output)) + { + return new List(); } - var found = new List(); var required = new[] { "libx264", @@ -151,26 +161,19 @@ namespace MediaBrowser.MediaEncoding.Encoder "ac3" }; - output = output ?? string.Empty; - - var index = 0; - + var found = new List(); foreach (var codec in required) { var srch = " " + codec + " "; if (output.IndexOf(srch, StringComparison.OrdinalIgnoreCase) != -1) { - if (index < required.Length - 1) - { - _logger.LogInformation("Encoder available: " + codec); - } - found.Add(codec); } - index++; } + _logger.LogInformation("Available encoders: {Codecs}", found); + return found; } From 0042b96c806ce38b575b33246bdb56dfe73adace Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 01:23:49 +0100 Subject: [PATCH 03/20] Use ValueTuple and Linq --- .../Encoder/EncoderValidator.cs | 43 ++++++------------- .../Encoder/MediaEncoder.cs | 8 ++-- 2 files changed, 17 insertions(+), 34 deletions(-) diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index 0f24a2370..400fa0b81 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; using MediaBrowser.Model.Diagnostics; using Microsoft.Extensions.Logging; @@ -17,21 +18,21 @@ namespace MediaBrowser.MediaEncoding.Encoder _processFactory = processFactory; } - public Tuple, List> Validate(string encoderPath) + public (IEnumerable decoders, IEnumerable encoders) Validate(string encoderPath) { - _logger.LogInformation("Validating media encoder at {0}", encoderPath); + _logger.LogInformation("Validating media encoder at {EncoderPath}", encoderPath); var decoders = GetDecoders(encoderPath); var encoders = GetEncoders(encoderPath); _logger.LogInformation("Encoder validation complete"); - return new Tuple, List>(decoders, encoders); + return (decoders, encoders); } public bool ValidateVersion(string encoderAppPath, bool logOutput) { - string output = string.Empty; + string output = null; try { output = GetProcessOutput(encoderAppPath, "-version"); @@ -70,7 +71,7 @@ namespace MediaBrowser.MediaEncoding.Encoder return true; } - private List GetDecoders(string encoderAppPath) + private IEnumerable GetDecoders(string encoderAppPath) { string output = null; try @@ -84,7 +85,7 @@ namespace MediaBrowser.MediaEncoding.Encoder if (string.IsNullOrWhiteSpace(output)) { - return new List(); + return Enumerable.Empty(); } var required = new[] @@ -104,23 +105,14 @@ namespace MediaBrowser.MediaEncoding.Encoder "hevc" }; - var found = new List(); - foreach (var codec in required) - { - var srch = " " + codec + " "; - - if (output.IndexOf(srch, StringComparison.OrdinalIgnoreCase) != -1) - { - found.Add(codec); - } - } + var found = required.Where(x => output.IndexOf(x, StringComparison.OrdinalIgnoreCase) != -1); _logger.LogInformation("Available decoders: {Codecs}", found); return found; } - private List GetEncoders(string encoderAppPath) + private IEnumerable GetEncoders(string encoderAppPath) { string output = null; try @@ -134,7 +126,7 @@ namespace MediaBrowser.MediaEncoding.Encoder if (string.IsNullOrWhiteSpace(output)) { - return new List(); + return Enumerable.Empty(); } var required = new[] @@ -161,16 +153,7 @@ namespace MediaBrowser.MediaEncoding.Encoder "ac3" }; - var found = new List(); - foreach (var codec in required) - { - var srch = " " + codec + " "; - - if (output.IndexOf(srch, StringComparison.OrdinalIgnoreCase) != -1) - { - found.Add(codec); - } - } + var found = required.Where(x => output.IndexOf(x, StringComparison.OrdinalIgnoreCase) != -1); _logger.LogInformation("Available encoders: {Codecs}", found); @@ -179,7 +162,7 @@ namespace MediaBrowser.MediaEncoding.Encoder private string GetProcessOutput(string path, string arguments) { - var process = _processFactory.Create(new ProcessOptions + IProcess process = _processFactory.Create(new ProcessOptions { CreateNoWindow = true, UseShellExecute = false, @@ -190,7 +173,7 @@ namespace MediaBrowser.MediaEncoding.Encoder RedirectStandardOutput = true }); - _logger.LogInformation("Running {path} {arguments}", path, arguments); + _logger.LogInformation("Running {Path} {Arguments}", path, arguments); using (process) { diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 181fc0f65..1d8cd6778 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -175,8 +175,8 @@ namespace MediaBrowser.MediaEncoding.Encoder { var result = new EncoderValidator(_logger, _processFactory).Validate(FFMpegPath); - SetAvailableDecoders(result.Item1); - SetAvailableEncoders(result.Item2); + SetAvailableDecoders(result.decoders); + SetAvailableEncoders(result.encoders); if (EnableEncoderFontFile) { @@ -401,14 +401,14 @@ namespace MediaBrowser.MediaEncoding.Encoder } private List _encoders = new List(); - public void SetAvailableEncoders(List list) + public void SetAvailableEncoders(IEnumerable list) { _encoders = list.ToList(); //_logger.Info("Supported encoders: {0}", string.Join(",", list.ToArray())); } private List _decoders = new List(); - public void SetAvailableDecoders(List list) + public void SetAvailableDecoders(IEnumerable list) { _decoders = list.ToList(); //_logger.Info("Supported decoders: {0}", string.Join(",", list.ToArray())); From 12c43cd76974fb795043c15d907251b5bb459a20 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 10:48:10 +0100 Subject: [PATCH 04/20] Use regex to check if ffmpeg output contains codec Demo of the regex: https://regex101.com/r/bn9IOy/10/ --- .../Encoder/EncoderValidator.cs | 88 +++++++++---------- 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index 400fa0b81..cafe3c64f 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Text.RegularExpressions; using MediaBrowser.Model.Diagnostics; using Microsoft.Extensions.Logging; @@ -22,8 +23,8 @@ namespace MediaBrowser.MediaEncoding.Encoder { _logger.LogInformation("Validating media encoder at {EncoderPath}", encoderPath); - var decoders = GetDecoders(encoderPath); - var encoders = GetEncoders(encoderPath); + var decoders = GetCodecs(encoderPath, Codec.Decoder); + var encoders = GetCodecs(encoderPath, Codec.Encoder); _logger.LogInformation("Encoder validation complete"); @@ -71,24 +72,7 @@ namespace MediaBrowser.MediaEncoding.Encoder return true; } - private IEnumerable GetDecoders(string encoderAppPath) - { - string output = null; - try - { - output = GetProcessOutput(encoderAppPath, "-decoders"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error detecting available decoders"); - } - - if (string.IsNullOrWhiteSpace(output)) - { - return Enumerable.Empty(); - } - - var required = new[] + private static readonly string[] requiredDecoders = new[] { "mpeg2video", "h264_qsv", @@ -105,31 +89,7 @@ namespace MediaBrowser.MediaEncoding.Encoder "hevc" }; - var found = required.Where(x => output.IndexOf(x, StringComparison.OrdinalIgnoreCase) != -1); - - _logger.LogInformation("Available decoders: {Codecs}", found); - - return found; - } - - private IEnumerable GetEncoders(string encoderAppPath) - { - string output = null; - try - { - output = GetProcessOutput(encoderAppPath, "-encoders"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error getting encoders"); - } - - if (string.IsNullOrWhiteSpace(output)) - { - return Enumerable.Empty(); - } - - var required = new[] + private static readonly string[] requiredEncoders = new[] { "libx264", "libx265", @@ -153,9 +113,43 @@ namespace MediaBrowser.MediaEncoding.Encoder "ac3" }; - var found = required.Where(x => output.IndexOf(x, StringComparison.OrdinalIgnoreCase) != -1); + private enum Codec + { + Encoder, + Decoder + } - _logger.LogInformation("Available encoders: {Codecs}", found); + private IEnumerable GetCodecs(string encoderAppPath, Codec codec) + { + string codecstr = codec == Codec.Encoder ? "encoders" : "decoders"; + string output = null; + try + { + output = GetProcessOutput(encoderAppPath, "-" + codecstr); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error detecting available {Codec}", codecstr); + } + + if (string.IsNullOrWhiteSpace(output)) + { + return Enumerable.Empty(); + } + + var required = codec == Codec.Encoder ? requiredEncoders : requiredDecoders; + + Regex regex = new Regex(@"\s\S{6}\s(?(\w|-)+)\s{3}"); + + MatchCollection matches = regex.Matches(output); + + var found = matches.Cast() + .Select(x => x.Groups["codec"].Value) + .Where(x => required.Contains(x)); + + //var found = required.Where(x => output.IndexOf(x, StringComparison.OrdinalIgnoreCase) != -1); + + _logger.LogInformation("Available {Codec}: {Codecs}", codecstr, found); return found; } From c05e8088d68a6e6f5b7ce6ed4462c072a347aed3 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 11:03:19 +0100 Subject: [PATCH 05/20] Remove extra capture group from regex https://regex101.com/r/bn9IOy/11/ --- MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index cafe3c64f..abb827e31 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -139,7 +139,7 @@ namespace MediaBrowser.MediaEncoding.Encoder var required = codec == Codec.Encoder ? requiredEncoders : requiredDecoders; - Regex regex = new Regex(@"\s\S{6}\s(?(\w|-)+)\s{3}"); + Regex regex = new Regex(@"\s\S{6}\s(?[\w|-]+)\s{3}"); MatchCollection matches = regex.Matches(output); @@ -147,8 +147,6 @@ namespace MediaBrowser.MediaEncoding.Encoder .Select(x => x.Groups["codec"].Value) .Where(x => required.Contains(x)); - //var found = required.Where(x => output.IndexOf(x, StringComparison.OrdinalIgnoreCase) != -1); - _logger.LogInformation("Available {Codec}: {Codecs}", codecstr, found); return found; From d6f3ca859eab462c12884a3e000a48a47eff6e4b Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 11:13:33 +0100 Subject: [PATCH 06/20] Change regex to multiline ex: https://regex101.com/r/bn9IOy/12 --- MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index abb827e31..0a97434e3 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -139,10 +139,8 @@ namespace MediaBrowser.MediaEncoding.Encoder var required = codec == Codec.Encoder ? requiredEncoders : requiredDecoders; - Regex regex = new Regex(@"\s\S{6}\s(?[\w|-]+)\s{3}"); - + Regex regex = new Regex(@"^\s\S{6}\s(?[\w|-]+)\s+.+$", RegexOptions.Multiline); MatchCollection matches = regex.Matches(output); - var found = matches.Cast() .Select(x => x.Groups["codec"].Value) .Where(x => required.Contains(x)); From f3030812ea8f79d4878a158695df0eb8a741b1e7 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 11:32:35 +0100 Subject: [PATCH 07/20] Use static regex --- MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index 0a97434e3..b68961889 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -139,9 +139,9 @@ namespace MediaBrowser.MediaEncoding.Encoder var required = codec == Codec.Encoder ? requiredEncoders : requiredDecoders; - Regex regex = new Regex(@"^\s\S{6}\s(?[\w|-]+)\s+.+$", RegexOptions.Multiline); - MatchCollection matches = regex.Matches(output); - var found = matches.Cast() + var found = Regex + .Matches(output, @"^\s\S{6}\s(?[\w|-]+)\s+.+$", RegexOptions.Multiline) + .Cast() .Select(x => x.Groups["codec"].Value) .Where(x => required.Contains(x)); From ec47c5b0f7883cebc54a2d50cdb8e65d4e07084f Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 15:12:52 +0100 Subject: [PATCH 08/20] Remove unused FontConfigLoader --- .../ApplicationHost.cs | 2 +- .../Encoder/FontConfigLoader.cs | 179 ------------------ .../Encoder/MediaEncoder.cs | 33 ++-- 3 files changed, 19 insertions(+), 195 deletions(-) delete mode 100644 MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index f1e1b4b2d..07705e9e4 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1240,7 +1240,7 @@ namespace Emby.Server.Implementations HttpClient, ZipClient, ProcessFactory, - 5000, false, + 5000, EnvironmentInfo); MediaEncoder = mediaEncoder; diff --git a/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs b/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs deleted file mode 100644 index c62de0b11..000000000 --- a/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using MediaBrowser.Common.Configuration; -using MediaBrowser.Common.Net; -using MediaBrowser.Common.Progress; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Net; -using Microsoft.Extensions.Logging; - -namespace MediaBrowser.MediaEncoding.Encoder -{ - public class FontConfigLoader - { - private readonly IHttpClient _httpClient; - private readonly IApplicationPaths _appPaths; - private readonly ILogger _logger; - private readonly IZipClient _zipClient; - private readonly IFileSystem _fileSystem; - - private readonly string[] _fontUrls = - { - "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/ARIALUNI.7z" - }; - - public FontConfigLoader(IHttpClient httpClient, IApplicationPaths appPaths, ILogger logger, IZipClient zipClient, IFileSystem fileSystem) - { - _httpClient = httpClient; - _appPaths = appPaths; - _logger = logger; - _zipClient = zipClient; - _fileSystem = fileSystem; - } - - /// - /// Extracts the fonts. - /// - /// The target path. - /// Task. - public async Task DownloadFonts(string targetPath) - { - try - { - var fontsDirectory = Path.Combine(targetPath, "fonts"); - - _fileSystem.CreateDirectory(fontsDirectory); - - const string fontFilename = "ARIALUNI.TTF"; - - var fontFile = Path.Combine(fontsDirectory, fontFilename); - - if (_fileSystem.FileExists(fontFile)) - { - await WriteFontConfigFile(fontsDirectory).ConfigureAwait(false); - } - else - { - // Kick this off, but no need to wait on it - var task = Task.Run(async () => - { - await DownloadFontFile(fontsDirectory, fontFilename, new SimpleProgress()).ConfigureAwait(false); - - await WriteFontConfigFile(fontsDirectory).ConfigureAwait(false); - }); - } - } - catch (HttpException ex) - { - // Don't let the server crash because of this - _logger.LogError(ex, "Error downloading ffmpeg font files"); - } - catch (Exception ex) - { - // Don't let the server crash because of this - _logger.LogError(ex, "Error writing ffmpeg font files"); - } - } - - /// - /// Downloads the font file. - /// - /// The fonts directory. - /// The font filename. - /// Task. - private async Task DownloadFontFile(string fontsDirectory, string fontFilename, IProgress progress) - { - var existingFile = _fileSystem - .GetFilePaths(_appPaths.ProgramDataPath, true) - .FirstOrDefault(i => string.Equals(fontFilename, Path.GetFileName(i), StringComparison.OrdinalIgnoreCase)); - - if (existingFile != null) - { - try - { - _fileSystem.CopyFile(existingFile, Path.Combine(fontsDirectory, fontFilename), true); - return; - } - catch (IOException ex) - { - // Log this, but don't let it fail the operation - _logger.LogError(ex, "Error copying file"); - } - } - - string tempFile = null; - - foreach (var url in _fontUrls) - { - progress.Report(0); - - try - { - tempFile = await _httpClient.GetTempFile(new HttpRequestOptions - { - Url = url, - Progress = progress - - }).ConfigureAwait(false); - - break; - } - catch (Exception ex) - { - // The core can function without the font file, so handle this - _logger.LogError(ex, "Failed to download ffmpeg font file from {url}", url); - } - } - - if (string.IsNullOrEmpty(tempFile)) - { - return; - } - - Extract7zArchive(tempFile, fontsDirectory); - - try - { - _fileSystem.DeleteFile(tempFile); - } - catch (IOException ex) - { - // Log this, but don't let it fail the operation - _logger.LogError(ex, "Error deleting temp file {path}", tempFile); - } - } - private void Extract7zArchive(string archivePath, string targetPath) - { - _logger.LogInformation("Extracting {ArchivePath} to {TargetPath}", archivePath, targetPath); - - _zipClient.ExtractAllFrom7z(archivePath, targetPath, true); - } - - /// - /// Writes the font config file. - /// - /// The fonts directory. - /// Task. - private async Task WriteFontConfigFile(string fontsDirectory) - { - const string fontConfigFilename = "fonts.conf"; - var fontConfigFile = Path.Combine(fontsDirectory, fontConfigFilename); - - if (!_fileSystem.FileExists(fontConfigFile)) - { - var contents = string.Format("{0}ArialArial Unicode MS", fontsDirectory); - - var bytes = Encoding.UTF8.GetBytes(contents); - - using (var fileStream = _fileSystem.GetFileStream(fontConfigFile, FileOpenMode.Create, FileAccessMode.Write, - FileShareMode.Read, true)) - { - await fileStream.WriteAsync(bytes, 0, bytes.Length); - } - } - } - } -} diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 1d8cd6778..a93dd9742 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -70,13 +70,27 @@ namespace MediaBrowser.MediaEncoding.Encoder private readonly string _originalFFMpegPath; private readonly string _originalFFProbePath; private readonly int DefaultImageExtractionTimeoutMs; - private readonly bool EnableEncoderFontFile; - private readonly IEnvironmentInfo _environmentInfo; - public MediaEncoder(ILogger logger, IJsonSerializer jsonSerializer, string ffMpegPath, string ffProbePath, bool hasExternalEncoder, IServerConfigurationManager configurationManager, IFileSystem fileSystem, ILiveTvManager liveTvManager, IIsoManager isoManager, ILibraryManager libraryManager, IChannelManager channelManager, ISessionManager sessionManager, Func subtitleEncoder, Func mediaSourceManager, IHttpClient httpClient, IZipClient zipClient, IProcessFactory processFactory, + public MediaEncoder(ILogger logger, + IJsonSerializer jsonSerializer, + string ffMpegPath, + string ffProbePath, + bool hasExternalEncoder, + IServerConfigurationManager configurationManager, + IFileSystem fileSystem, + ILiveTvManager liveTvManager, + IIsoManager isoManager, + ILibraryManager libraryManager, + IChannelManager channelManager, + ISessionManager sessionManager, + Func subtitleEncoder, + Func mediaSourceManager, + IHttpClient httpClient, + IZipClient zipClient, + IProcessFactory processFactory, int defaultImageExtractionTimeoutMs, - bool enableEncoderFontFile, IEnvironmentInfo environmentInfo) + IEnvironmentInfo environmentInfo) { _logger = logger; _jsonSerializer = jsonSerializer; @@ -93,7 +107,6 @@ namespace MediaBrowser.MediaEncoding.Encoder _zipClient = zipClient; _processFactory = processFactory; DefaultImageExtractionTimeoutMs = defaultImageExtractionTimeoutMs; - EnableEncoderFontFile = enableEncoderFontFile; _environmentInfo = environmentInfo; FFProbePath = ffProbePath; FFMpegPath = ffMpegPath; @@ -177,16 +190,6 @@ namespace MediaBrowser.MediaEncoding.Encoder SetAvailableDecoders(result.decoders); SetAvailableEncoders(result.encoders); - - if (EnableEncoderFontFile) - { - var directory = FileSystem.GetDirectoryName(FFMpegPath); - - if (!string.IsNullOrWhiteSpace(directory) && FileSystem.ContainsSubPath(ConfigurationManager.ApplicationPaths.ProgramDataPath, directory)) - { - new FontConfigLoader(_httpClient, ConfigurationManager.ApplicationPaths, _logger, _zipClient, FileSystem).DownloadFonts(directory).ConfigureAwait(false); - } - } } } From 3a65fb1da2009df246ae6f1252d44d24e882e554 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 12:14:31 +0100 Subject: [PATCH 09/20] Remove obsolete GetMBId --- .../Channels/ChannelManager.cs | 4 ++-- .../Extensions/BaseExtensions.cs | 20 ------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 00da46f30..c2160d338 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -901,8 +901,8 @@ namespace Emby.Server.Implementations.Channels private T GetItemById(string idString, string channelName, out bool isNew) where T : BaseItem, new() { - var id = GetIdToHash(idString, channelName).GetMBId(typeof(T)); - + var id = _libraryManager.GetNewItemId(GetIdToHash(idString, channelName), typeof(T)); + T item = null; try diff --git a/MediaBrowser.Common/Extensions/BaseExtensions.cs b/MediaBrowser.Common/Extensions/BaseExtensions.cs index d7f4424fa..520c04244 100644 --- a/MediaBrowser.Common/Extensions/BaseExtensions.cs +++ b/MediaBrowser.Common/Extensions/BaseExtensions.cs @@ -34,25 +34,5 @@ namespace MediaBrowser.Common.Extensions { return CryptographyProvider.GetMD5(str); } - - /// - /// Gets the MB id. - /// - /// The STR. - /// The type. - /// Guid. - /// type - [Obsolete("Use LibraryManager.GetNewItemId")] - public static Guid GetMBId(this string str, Type type) - { - if (type == null) - { - throw new ArgumentNullException("type"); - } - - var key = type.FullName + str.ToLower(); - - return key.GetMD5(); - } } } From 32469b3f65596e115bb04427cd1e5daafbb69312 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 12:15:05 +0100 Subject: [PATCH 10/20] Remove obsolete functions --- .../IO/SharpCifs/Smb/SmbFile.cs | 20 ---- .../Networking/IPNetwork/IPNetwork.cs | 106 +----------------- 2 files changed, 2 insertions(+), 124 deletions(-) diff --git a/Emby.Server.Implementations/IO/SharpCifs/Smb/SmbFile.cs b/Emby.Server.Implementations/IO/SharpCifs/Smb/SmbFile.cs index 151ec35c4..7fd9f0d84 100644 --- a/Emby.Server.Implementations/IO/SharpCifs/Smb/SmbFile.cs +++ b/Emby.Server.Implementations/IO/SharpCifs/Smb/SmbFile.cs @@ -3380,26 +3380,6 @@ namespace SharpCifs.Smb SetAttributes(GetAttributes() & ~AttrReadonly); } - /// - /// Returns a - /// System.Uri - /// for this SmbFile. The - /// URL may be used as any other URL might to - /// access an SMB resource. Currently only retrieving data and information - /// is supported (i.e. no doOutput). - /// - /// - /// A new - /// System.Uri - /// for this SmbFile - /// - /// System.UriFormatException - [Obsolete(@"Use getURL() instead")] - public virtual Uri ToUrl() - { - return Url; - } - /// /// Computes a hashCode for this file based on the URL string and IP /// address if the server. diff --git a/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs b/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs index 6d7785b90..8d0fb7997 100644 --- a/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs +++ b/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs @@ -189,7 +189,7 @@ namespace System.Net internal #endif - IPNetwork(BigInteger ipaddress, AddressFamily family, byte cidr) + IPNetwork(BigInteger ipaddress, AddressFamily family, byte cidr) { int maxCidr = family == Sockets.AddressFamily.InterNetwork ? 32 : 128; @@ -1164,18 +1164,6 @@ namespace System.Net } - [Obsolete("static Contains is deprecated, please use instance Contains.")] - public static bool Contains(IPNetwork network, IPAddress ipaddress) - { - - if (network == null) - { - throw new ArgumentNullException("network"); - } - - return network.Contains(ipaddress); - } - /// /// return true is network2 is fully contained in network /// @@ -1201,18 +1189,6 @@ namespace System.Net return contains; } - [Obsolete("static Contains is deprecated, please use instance Contains.")] - public static bool Contains(IPNetwork network, IPNetwork network2) - { - - if (network == null) - { - throw new ArgumentNullException("network"); - } - - return network.Contains(network2); - } - #endregion #region overlap @@ -1245,18 +1221,6 @@ namespace System.Net return overlap; } - [Obsolete("static Overlap is deprecated, please use instance Overlap.")] - public static bool Overlap(IPNetwork network, IPNetwork network2) - { - - if (network == null) - { - throw new ArgumentNullException("network"); - } - - return network.Overlap(network2); - } - #endregion #region ToString @@ -1341,18 +1305,6 @@ namespace System.Net || IPNetwork.IANA_CBLK_RESERVED1.Contains(this); } - [Obsolete("static IsIANAReserved is deprecated, please use instance IsIANAReserved.")] - public static bool IsIANAReserved(IPNetwork ipnetwork) - { - - if (ipnetwork == null) - { - throw new ArgumentNullException("ipnetwork"); - } - - return ipnetwork.IsIANAReserved(); - } - #endregion #region Subnet @@ -1371,16 +1323,6 @@ namespace System.Net return ipnetworkCollection; } - [Obsolete("static Subnet is deprecated, please use instance Subnet.")] - public static IPNetworkCollection Subnet(IPNetwork network, byte cidr) - { - if (network == null) - { - throw new ArgumentNullException("network"); - } - return network.Subnet(cidr); - } - /// /// Subnet a network into multiple nets of cidr mask /// Subnet 192.168.0.0/24 into cidr 25 gives 192.168.0.0/25, 192.168.0.128/25 @@ -1402,16 +1344,6 @@ namespace System.Net return true; } - [Obsolete("static TrySubnet is deprecated, please use instance TrySubnet.")] - public static bool TrySubnet(IPNetwork network, byte cidr, out IPNetworkCollection ipnetworkCollection) - { - if (network == null) - { - throw new ArgumentNullException("network"); - } - return network.TrySubnet(cidr, out ipnetworkCollection); - } - #if TRAVISCI public #else @@ -1476,12 +1408,6 @@ namespace System.Net return supernet; } - [Obsolete("static Supernet is deprecated, please use instance Supernet.")] - public static IPNetwork Supernet(IPNetwork network, IPNetwork network2) - { - return network.Supernet(network2); - } - /// /// Try to supernet two consecutive cidr equal subnet into a single one /// 192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23 @@ -1500,16 +1426,6 @@ namespace System.Net return parsed; } - [Obsolete("static TrySupernet is deprecated, please use instance TrySupernet.")] - public static bool TrySupernet(IPNetwork network, IPNetwork network2, out IPNetwork supernet) - { - if (network == null) - { - throw new ArgumentNullException("network"); - } - return network.TrySupernet(network2, out supernet); - } - #if TRAVISCI public #else @@ -1920,18 +1836,6 @@ namespace System.Net return sw.ToString(); } - [Obsolete("static Print is deprecated, please use instance Print.")] - public static string Print(IPNetwork ipnetwork) - { - - if (ipnetwork == null) - { - throw new ArgumentNullException("ipnetwork"); - } - - return ipnetwork.Print(); - } - #endregion #region TryGuessCidr @@ -2018,12 +1922,6 @@ namespace System.Net #region ListIPAddress - [Obsolete("static ListIPAddress is deprecated, please use instance ListIPAddress.")] - public static IPAddressCollection ListIPAddress(IPNetwork ipnetwork) - { - return ipnetwork.ListIPAddress(); - } - public IPAddressCollection ListIPAddress() { return new IPAddressCollection(this); @@ -2167,4 +2065,4 @@ namespace System.Net #endregion } -} \ No newline at end of file +} From 40563dc6cc30e45ace90db30a934478395d8c7c1 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 17:09:40 +0100 Subject: [PATCH 11/20] Remove GitHub updater and don't trow exception in release --- .../ApplicationHost.cs | 49 +--- Jellyfin.Server/CoreAppHost.cs | 4 +- Jellyfin.Server/Program.cs | 1 - MediaBrowser.Common/Updates/GithubUpdater.cs | 274 ------------------ 4 files changed, 7 insertions(+), 321 deletions(-) delete mode 100644 MediaBrowser.Common/Updates/GithubUpdater.cs diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index f1e1b4b2d..5853d20c8 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -368,7 +368,6 @@ namespace Emby.Server.Implementations protected IAuthService AuthService { get; private set; } public StartupOptions StartupOptions { get; private set; } - protected readonly string ReleaseAssetFilename; internal IPowerManagement PowerManagement { get; private set; } internal IImageEncoder ImageEncoder { get; private set; } @@ -393,7 +392,6 @@ namespace Emby.Server.Implementations StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, - string releaseAssetFilename, IEnvironmentInfo environmentInfo, IImageEncoder imageEncoder, ISystemEvents systemEvents, @@ -419,7 +417,6 @@ namespace Emby.Server.Implementations Logger = LoggerFactory.CreateLogger("App"); StartupOptions = options; - ReleaseAssetFilename = releaseAssetFilename; PowerManagement = powerManagement; ImageEncoder = imageEncoder; @@ -2292,48 +2289,12 @@ namespace Emby.Server.Implementations /// The cancellation token. /// The progress. /// Task{CheckForUpdateResult}. - public async Task CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress progress) + public Task CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress progress) { - var updateLevel = SystemUpdateLevel; - var cacheLength = updateLevel == PackageVersionClass.Release ? - TimeSpan.FromHours(12) : - TimeSpan.FromMinutes(5); - - try - { - var result = await new GithubUpdater(HttpClient, JsonSerializer).CheckForUpdateResult("MediaBrowser", - "Emby.Releases", - ApplicationVersion, - updateLevel, - ReleaseAssetFilename, - "MBServer", - UpdateTargetFileName, - cacheLength, - cancellationToken).ConfigureAwait(false); - - HasUpdateAvailable = result.IsUpdateAvailable; - - return result; - } - catch (HttpException ex) - { - // users are overreacting to this occasionally failing - if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.Forbidden) - { - HasUpdateAvailable = false; - return new CheckForUpdateResult - { - IsUpdateAvailable = false - }; - } - - throw; - } - } - - protected virtual string UpdateTargetFileName - { - get { return "Mbserver.zip"; } +#if DEBUG + throw new Exception("Unimplemented"); +#endif + return Task.FromResult(new CheckForUpdateResult()); } /// diff --git a/Jellyfin.Server/CoreAppHost.cs b/Jellyfin.Server/CoreAppHost.cs index 2fb106b3c..b54634387 100644 --- a/Jellyfin.Server/CoreAppHost.cs +++ b/Jellyfin.Server/CoreAppHost.cs @@ -11,8 +11,8 @@ namespace Jellyfin.Server { public class CoreAppHost : ApplicationHost { - public CoreAppHost(ServerApplicationPaths applicationPaths, ILoggerFactory loggerFactory, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager) - : base(applicationPaths, loggerFactory, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, networkManager) + public CoreAppHost(ServerApplicationPaths applicationPaths, ILoggerFactory loggerFactory, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager) + : base(applicationPaths, loggerFactory, options, fileSystem, powerManagement, environmentInfo, imageEncoder, systemEvents, networkManager) { } diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 0150cd533..9cc2fe103 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -73,7 +73,6 @@ namespace Jellyfin.Server options, fileSystem, new PowerManagement(), - "embyserver-mono_{version}.zip", environmentInfo, new NullImageEncoder(), new SystemEvents(_loggerFactory.CreateLogger("SystemEvents")), diff --git a/MediaBrowser.Common/Updates/GithubUpdater.cs b/MediaBrowser.Common/Updates/GithubUpdater.cs deleted file mode 100644 index 22ed788e0..000000000 --- a/MediaBrowser.Common/Updates/GithubUpdater.cs +++ /dev/null @@ -1,274 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Common.Net; -using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.Updates; - -namespace MediaBrowser.Common.Updates -{ - public class GithubUpdater - { - private readonly IHttpClient _httpClient; - private readonly IJsonSerializer _jsonSerializer; - - public GithubUpdater(IHttpClient httpClient, IJsonSerializer jsonSerializer) - { - _httpClient = httpClient; - _jsonSerializer = jsonSerializer; - } - - public async Task CheckForUpdateResult(string organzation, string repository, Version minVersion, PackageVersionClass updateLevel, string assetFilename, string packageName, string targetFilename, TimeSpan cacheLength, CancellationToken cancellationToken) - { - var url = string.Format("https://api.github.com/repos/{0}/{1}/releases", organzation, repository); - - var options = new HttpRequestOptions - { - Url = url, - EnableKeepAlive = false, - CancellationToken = cancellationToken, - UserAgent = "Emby/3.0", - BufferContent = false - }; - - if (cacheLength.Ticks > 0) - { - options.CacheMode = CacheMode.Unconditional; - options.CacheLength = cacheLength; - } - - using (var response = await _httpClient.SendAsync(options, "GET").ConfigureAwait(false)) - using (var stream = response.Content) - { - var obj = await _jsonSerializer.DeserializeFromStreamAsync(stream).ConfigureAwait(false); - - return CheckForUpdateResult(obj, minVersion, updateLevel, assetFilename, packageName, targetFilename); - } - } - - private CheckForUpdateResult CheckForUpdateResult(RootObject[] obj, Version minVersion, PackageVersionClass updateLevel, string assetFilename, string packageName, string targetFilename) - { - if (updateLevel == PackageVersionClass.Release) - { - // Technically all we need to do is check that it's not pre-release - // But let's addititional checks for -beta and -dev to handle builds that might be temporarily tagged incorrectly. - obj = obj.Where(i => !i.prerelease && !i.name.EndsWith("-beta", StringComparison.OrdinalIgnoreCase) && !i.name.EndsWith("-dev", StringComparison.OrdinalIgnoreCase)).ToArray(); - } - else if (updateLevel == PackageVersionClass.Beta) - { - obj = obj.Where(i => i.prerelease && i.name.EndsWith("-beta", StringComparison.OrdinalIgnoreCase)).ToArray(); - } - else if (updateLevel == PackageVersionClass.Dev) - { - obj = obj.Where(i => !i.prerelease || i.name.EndsWith("-beta", StringComparison.OrdinalIgnoreCase) || i.name.EndsWith("-dev", StringComparison.OrdinalIgnoreCase)).ToArray(); - } - - var availableUpdate = obj - .Select(i => CheckForUpdateResult(i, minVersion, assetFilename, packageName, targetFilename)) - .Where(i => i != null) - .OrderByDescending(i => Version.Parse(i.AvailableVersion)) - .FirstOrDefault(); - - return availableUpdate ?? new CheckForUpdateResult - { - IsUpdateAvailable = false - }; - } - - private bool MatchesUpdateLevel(RootObject i, PackageVersionClass updateLevel) - { - if (updateLevel == PackageVersionClass.Beta) - { - return i.prerelease && i.name.EndsWith("-beta", StringComparison.OrdinalIgnoreCase); - } - if (updateLevel == PackageVersionClass.Dev) - { - return !i.prerelease || i.name.EndsWith("-beta", StringComparison.OrdinalIgnoreCase) || - i.name.EndsWith("-dev", StringComparison.OrdinalIgnoreCase); - } - - // Technically all we need to do is check that it's not pre-release - // But let's addititional checks for -beta and -dev to handle builds that might be temporarily tagged incorrectly. - return !i.prerelease && !i.name.EndsWith("-beta", StringComparison.OrdinalIgnoreCase) && - !i.name.EndsWith("-dev", StringComparison.OrdinalIgnoreCase); - } - - public async Task> GetLatestReleases(string organzation, string repository, string assetFilename, CancellationToken cancellationToken) - { - var list = new List(); - - var url = string.Format("https://api.github.com/repos/{0}/{1}/releases", organzation, repository); - - var options = new HttpRequestOptions - { - Url = url, - EnableKeepAlive = false, - CancellationToken = cancellationToken, - UserAgent = "Emby/3.0", - BufferContent = false - }; - - using (var response = await _httpClient.SendAsync(options, "GET").ConfigureAwait(false)) - using (var stream = response.Content) - { - var obj = await _jsonSerializer.DeserializeFromStreamAsync(stream).ConfigureAwait(false); - - obj = obj.Where(i => (i.assets ?? new List()).Any(a => IsAsset(a, assetFilename, i.tag_name))).ToArray(); - - list.AddRange(obj.Where(i => MatchesUpdateLevel(i, PackageVersionClass.Release)).OrderByDescending(GetVersion).Take(1)); - list.AddRange(obj.Where(i => MatchesUpdateLevel(i, PackageVersionClass.Beta)).OrderByDescending(GetVersion).Take(1)); - list.AddRange(obj.Where(i => MatchesUpdateLevel(i, PackageVersionClass.Dev)).OrderByDescending(GetVersion).Take(1)); - - return list; - } - } - - public Version GetVersion(RootObject obj) - { - Version version; - if (!Version.TryParse(obj.tag_name, out version)) - { - return new Version(1, 0); - } - - return version; - } - - private CheckForUpdateResult CheckForUpdateResult(RootObject obj, Version minVersion, string assetFilename, string packageName, string targetFilename) - { - Version version; - var versionString = obj.tag_name; - if (!Version.TryParse(versionString, out version)) - { - return null; - } - - if (version < minVersion) - { - return null; - } - - var asset = (obj.assets ?? new List()).FirstOrDefault(i => IsAsset(i, assetFilename, versionString)); - - if (asset == null) - { - return null; - } - - return new CheckForUpdateResult - { - AvailableVersion = version.ToString(), - IsUpdateAvailable = version > minVersion, - Package = new PackageVersionInfo - { - classification = obj.prerelease ? - (obj.name.EndsWith("-dev", StringComparison.OrdinalIgnoreCase) ? PackageVersionClass.Dev : PackageVersionClass.Beta) : - PackageVersionClass.Release, - name = packageName, - sourceUrl = asset.browser_download_url, - targetFilename = targetFilename, - versionStr = version.ToString(), - requiredVersionStr = "1.0.0", - description = obj.body, - infoUrl = obj.html_url - } - }; - } - - private bool IsAsset(Asset asset, string assetFilename, string version) - { - var downloadFilename = Path.GetFileName(asset.browser_download_url) ?? string.Empty; - - assetFilename = assetFilename.Replace("{version}", version); - - if (downloadFilename.IndexOf(assetFilename, StringComparison.OrdinalIgnoreCase) != -1) - { - return true; - } - - return string.Equals(assetFilename, downloadFilename, StringComparison.OrdinalIgnoreCase); - } - - public class Uploader - { - public string login { get; set; } - public int id { get; set; } - public string avatar_url { get; set; } - public string gravatar_id { get; set; } - public string url { get; set; } - public string html_url { get; set; } - public string followers_url { get; set; } - public string following_url { get; set; } - public string gists_url { get; set; } - public string starred_url { get; set; } - public string subscriptions_url { get; set; } - public string organizations_url { get; set; } - public string repos_url { get; set; } - public string events_url { get; set; } - public string received_events_url { get; set; } - public string type { get; set; } - public bool site_admin { get; set; } - } - - public class Asset - { - public string url { get; set; } - public int id { get; set; } - public string name { get; set; } - public object label { get; set; } - public Uploader uploader { get; set; } - public string content_type { get; set; } - public string state { get; set; } - public int size { get; set; } - public int download_count { get; set; } - public string created_at { get; set; } - public string updated_at { get; set; } - public string browser_download_url { get; set; } - } - - public class Author - { - public string login { get; set; } - public int id { get; set; } - public string avatar_url { get; set; } - public string gravatar_id { get; set; } - public string url { get; set; } - public string html_url { get; set; } - public string followers_url { get; set; } - public string following_url { get; set; } - public string gists_url { get; set; } - public string starred_url { get; set; } - public string subscriptions_url { get; set; } - public string organizations_url { get; set; } - public string repos_url { get; set; } - public string events_url { get; set; } - public string received_events_url { get; set; } - public string type { get; set; } - public bool site_admin { get; set; } - } - - public class RootObject - { - public string url { get; set; } - public string assets_url { get; set; } - public string upload_url { get; set; } - public string html_url { get; set; } - public int id { get; set; } - public string tag_name { get; set; } - public string target_commitish { get; set; } - public string name { get; set; } - public bool draft { get; set; } - public Author author { get; set; } - public bool prerelease { get; set; } - public string created_at { get; set; } - public string published_at { get; set; } - public List assets { get; set; } - public string tarball_url { get; set; } - public string zipball_url { get; set; } - public string body { get; set; } - } - } -} From 7679ed037f4bfa31762fc1ff40cec8297105d658 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 17:54:26 +0100 Subject: [PATCH 12/20] Disable SystemUpdateTask --- Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs b/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs index 4cb97cbda..890a20ddf 100644 --- a/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs @@ -13,7 +13,7 @@ namespace Emby.Server.Implementations.ScheduledTasks /// /// Plugin Update Task /// - public class SystemUpdateTask : IScheduledTask + public class SystemUpdateTask /*: IScheduledTask*/ { /// /// The _app host From a064a93a8e6ee0fe5dd1266db8d4a84d04d83e7e Mon Sep 17 00:00:00 2001 From: Sparky Date: Wed, 2 Jan 2019 12:01:03 -0500 Subject: [PATCH 13/20] Admin and first setup pages default to dark theme Since the user facing sides of the UI (login and library) are all dark theme by default, changes the default look for the admin sides (first time setup, admin panel) as well. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index ff9e52259..9bbfd9b74 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ !* +.directory + ################# ## Eclipse ################# From 36a109cb0f5bd22daae2895948b357b366b5062f Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 18:03:03 +0100 Subject: [PATCH 14/20] Disable PluginUpdateTask --- Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs b/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs index 46a7f1f27..9b3571ac2 100644 --- a/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs @@ -16,7 +16,7 @@ namespace Emby.Server.Implementations.ScheduledTasks /// /// Plugin Update Task /// - public class PluginUpdateTask : IScheduledTask, IConfigurableScheduledTask + public class PluginUpdateTask /*: IScheduledTask, IConfigurableScheduledTask*/ { /// /// The _logger From 78dafb5399941e0e1b6110c6424d06f4477e80cc Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 18:05:04 +0100 Subject: [PATCH 15/20] Throw exception when calling unreachable function --- Emby.Server.Implementations/ApplicationHost.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 5853d20c8..98c7cf38b 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -2291,10 +2291,7 @@ namespace Emby.Server.Implementations /// Task{CheckForUpdateResult}. public Task CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress progress) { -#if DEBUG throw new Exception("Unimplemented"); -#endif - return Task.FromResult(new CheckForUpdateResult()); } /// From 141661573a7b0d221f26bbc3901cf53c34f66fd2 Mon Sep 17 00:00:00 2001 From: Sparky Date: Wed, 2 Jan 2019 12:06:53 -0500 Subject: [PATCH 16/20] Add myself to contributors file --- CONTRIBUTORS.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 3a2c229d1..e6892313c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -8,15 +8,16 @@ - [flemse](https://github.com/flemse) - [bfayers](https://github.com/bfayers) - [Bond_009](https://github.com/Bond-009) + - [sparky8251](https://github.com/sparky8251) # Emby Contributors - - [LukePulverenti](https://github.com/LukePulverenti) - - [ebr11](https://github.com/ebr11) - - [lalmanzar](https://github.com/lalmanzar) - - [schneifu](https://github.com/schneifu) - - [Mark2xv](https://github.com/Mark2xv) - - [ScottRapsey](https://github.com/ScottRapsey) + - [LukePulverenti](https://github.com/LukePulverenti) + - [ebr11](https://github.com/ebr11) + - [lalmanzar](https://github.com/lalmanzar) + - [schneifu](https://github.com/schneifu) + - [Mark2xv](https://github.com/Mark2xv) + - [ScottRapsey](https://github.com/ScottRapsey) - [skynet600](https://github.com/skynet600) - [Cheesegeezer](https://githum.com/Cheesegeezer) - [Radeon](https://github.com/radeonorama) From 3fa751e9bbef072c5bb4c39aad1aede8ced1c003 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 18:10:52 +0100 Subject: [PATCH 17/20] Remove CheckForApplicationUpdate function --- Emby.Server.Implementations/ApplicationHost.cs | 11 ----------- .../ScheduledTasks/PluginUpdateTask.cs | 5 +++-- .../ScheduledTasks/SystemUpdateTask.cs | 5 +++-- MediaBrowser.Common/IApplicationHost.cs | 6 ------ 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 98c7cf38b..fe615fab0 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -2283,17 +2283,6 @@ namespace Emby.Server.Implementations Plugins = list.ToArray(); } - /// - /// Checks for update. - /// - /// The cancellation token. - /// The progress. - /// Task{CheckForUpdateResult}. - public Task CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress progress) - { - throw new Exception("Unimplemented"); - } - /// /// Updates the application. /// diff --git a/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs b/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs index 9b3571ac2..8c562e452 100644 --- a/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common; +/*using MediaBrowser.Common; using MediaBrowser.Common.Updates; using Microsoft.Extensions.Logging; using MediaBrowser.Model.Net; @@ -16,7 +16,7 @@ namespace Emby.Server.Implementations.ScheduledTasks /// /// Plugin Update Task /// - public class PluginUpdateTask /*: IScheduledTask, IConfigurableScheduledTask*/ + public class PluginUpdateTask : IScheduledTask, IConfigurableScheduledTask { /// /// The _logger @@ -140,3 +140,4 @@ namespace Emby.Server.Implementations.ScheduledTasks public bool IsLogged => true; } } +*/ diff --git a/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs b/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs index 890a20ddf..18ff33e95 100644 --- a/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common; +/*using MediaBrowser.Common; using MediaBrowser.Common.Configuration; using Microsoft.Extensions.Logging; using System; @@ -13,7 +13,7 @@ namespace Emby.Server.Implementations.ScheduledTasks /// /// Plugin Update Task /// - public class SystemUpdateTask /*: IScheduledTask*/ + public class SystemUpdateTask : IScheduledTask { /// /// The _app host @@ -126,3 +126,4 @@ namespace Emby.Server.Implementations.ScheduledTasks } } } +*/ diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs index 32b942b60..39d69ea15 100644 --- a/MediaBrowser.Common/IApplicationHost.cs +++ b/MediaBrowser.Common/IApplicationHost.cs @@ -85,12 +85,6 @@ namespace MediaBrowser.Common /// IEnumerable{``0}. IEnumerable GetExports(bool manageLiftime = true); - /// - /// Checks for update. - /// - /// Task{CheckForUpdateResult}. - Task CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress progress); - /// /// Updates the application. /// From 1fb975c6e766ba40a637d0c9996c1d309b05e8fb Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Wed, 2 Jan 2019 18:44:06 +0100 Subject: [PATCH 18/20] Delete SystemUpdateTask.cs --- .../ScheduledTasks/SystemUpdateTask.cs | 129 ------------------ 1 file changed, 129 deletions(-) delete mode 100644 Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs diff --git a/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs b/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs deleted file mode 100644 index 18ff33e95..000000000 --- a/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs +++ /dev/null @@ -1,129 +0,0 @@ -/*using MediaBrowser.Common; -using MediaBrowser.Common.Configuration; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Common.Progress; -using MediaBrowser.Model.Tasks; - -namespace Emby.Server.Implementations.ScheduledTasks -{ - /// - /// Plugin Update Task - /// - public class SystemUpdateTask : IScheduledTask - { - /// - /// The _app host - /// - private readonly IApplicationHost _appHost; - - /// - /// Gets or sets the configuration manager. - /// - /// The configuration manager. - private IConfigurationManager ConfigurationManager { get; set; } - /// - /// Gets or sets the logger. - /// - /// The logger. - private ILogger Logger { get; set; } - - /// - /// Initializes a new instance of the class. - /// - /// The app host. - /// The configuration manager. - /// The logger. - public SystemUpdateTask(IApplicationHost appHost, IConfigurationManager configurationManager, ILogger logger) - { - _appHost = appHost; - ConfigurationManager = configurationManager; - Logger = logger; - } - - /// - /// Creates the triggers that define when the task will run - /// - /// IEnumerable{BaseTaskTrigger}. - public IEnumerable GetDefaultTriggers() - { - return new[] { - - // At startup - new TaskTriggerInfo {Type = TaskTriggerInfo.TriggerStartup}, - - // Every so often - new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks} - }; - } - - /// - /// Returns the task to be executed - /// - /// The cancellation token. - /// The progress. - /// Task. - public async Task Execute(CancellationToken cancellationToken, IProgress progress) - { - // Create a progress object for the update check - var updateInfo = await _appHost.CheckForApplicationUpdate(cancellationToken, new SimpleProgress()).ConfigureAwait(false); - - if (!updateInfo.IsUpdateAvailable) - { - Logger.LogDebug("No application update available."); - return; - } - - cancellationToken.ThrowIfCancellationRequested(); - - if (!_appHost.CanSelfUpdate) return; - - if (ConfigurationManager.CommonConfiguration.EnableAutoUpdate) - { - Logger.LogInformation("Update Revision {0} available. Updating...", updateInfo.AvailableVersion); - - await _appHost.UpdateApplication(updateInfo.Package, cancellationToken, progress).ConfigureAwait(false); - } - else - { - Logger.LogInformation("A new version of " + _appHost.Name + " is available."); - } - } - - /// - /// Gets the name of the task - /// - /// The name. - public string Name - { - get { return "Check for application updates"; } - } - - /// - /// Gets the description. - /// - /// The description. - public string Description - { - get { return "Downloads and installs application updates."; } - } - - /// - /// Gets the category. - /// - /// The category. - public string Category - { - get { return "Application"; } - } - - public string Key - { - get { return "SystemUpdateTask"; } - } - } -} -*/ From f1bf87665ffeefa0fd3e3a716312d02f20f56231 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Wed, 2 Jan 2019 18:44:19 +0100 Subject: [PATCH 19/20] Delete PluginUpdateTask.cs --- .../ScheduledTasks/PluginUpdateTask.cs | 143 ------------------ 1 file changed, 143 deletions(-) delete mode 100644 Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs diff --git a/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs b/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs deleted file mode 100644 index 8c562e452..000000000 --- a/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs +++ /dev/null @@ -1,143 +0,0 @@ -/*using MediaBrowser.Common; -using MediaBrowser.Common.Updates; -using Microsoft.Extensions.Logging; -using MediaBrowser.Model.Net; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Common.Progress; -using MediaBrowser.Model.Tasks; - -namespace Emby.Server.Implementations.ScheduledTasks -{ - /// - /// Plugin Update Task - /// - public class PluginUpdateTask : IScheduledTask, IConfigurableScheduledTask - { - /// - /// The _logger - /// - private readonly ILogger _logger; - - private readonly IInstallationManager _installationManager; - - private readonly IApplicationHost _appHost; - - public PluginUpdateTask(ILogger logger, IInstallationManager installationManager, IApplicationHost appHost) - { - _logger = logger; - _installationManager = installationManager; - _appHost = appHost; - } - - /// - /// Creates the triggers that define when the task will run - /// - /// IEnumerable{BaseTaskTrigger}. - public IEnumerable GetDefaultTriggers() - { - return new[] { - - // At startup - new TaskTriggerInfo {Type = TaskTriggerInfo.TriggerStartup}, - - // Every so often - new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks} - }; - } - - public string Key - { - get { return "PluginUpdates"; } - } - - /// - /// Update installed plugins - /// - /// The cancellation token. - /// The progress. - /// Task. - public async Task Execute(CancellationToken cancellationToken, IProgress progress) - { - progress.Report(0); - - var packagesToInstall = (await _installationManager.GetAvailablePluginUpdates(_appHost.ApplicationVersion, true, cancellationToken).ConfigureAwait(false)).ToList(); - - progress.Report(10); - - var numComplete = 0; - - foreach (var package in packagesToInstall) - { - cancellationToken.ThrowIfCancellationRequested(); - - try - { - await _installationManager.InstallPackage(package, true, new SimpleProgress(), cancellationToken).ConfigureAwait(false); - } - catch (OperationCanceledException) - { - // InstallPackage has it's own inner cancellation token, so only throw this if it's ours - if (cancellationToken.IsCancellationRequested) - { - throw; - } - } - catch (HttpException ex) - { - _logger.LogError(ex, "Error downloading {name}", package.name); - } - catch (IOException ex) - { - _logger.LogError(ex, "Error updating {name}", package.name); - } - - // Update progress - lock (progress) - { - numComplete++; - double percent = numComplete; - percent /= packagesToInstall.Count; - - progress.Report(90 * percent + 10); - } - } - - progress.Report(100); - } - - /// - /// Gets the name of the task - /// - /// The name. - public string Name - { - get { return "Check for plugin updates"; } - } - - /// - /// Gets the description. - /// - /// The description. - public string Description - { - get { return "Downloads and installs updates for plugins that are configured to update automatically."; } - } - - public string Category - { - get { return "Application"; } - } - - public bool IsHidden => true; - - public bool IsEnabled => true; - - public bool IsLogged => true; - } -} -*/ From 1d6987c7131c36fa50c8f85ab140038b71eaf83c Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Wed, 2 Jan 2019 19:13:35 +0100 Subject: [PATCH 20/20] added todo --- Emby.Server.Implementations/Devices/DeviceManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Devices/DeviceManager.cs b/Emby.Server.Implementations/Devices/DeviceManager.cs index 250316211..82df96d8b 100644 --- a/Emby.Server.Implementations/Devices/DeviceManager.cs +++ b/Emby.Server.Implementations/Devices/DeviceManager.cs @@ -145,7 +145,8 @@ namespace Emby.Server.Implementations.Devices HasUser = true }).Items; - + + // TODO: DeviceQuery doesn't seem to be used from client. Not even Swagger. if (query.SupportsSync.HasValue) { var val = query.SupportsSync.Value;