From 1edd61bf38f26665f0d0381788d12e180230c4f3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 4 Jun 2016 13:14:03 -0400 Subject: [PATCH 1/7] update tabs --- .../Music/MusicBrainzAlbumProvider.cs | 2 +- .../Persistence/SqliteExtensions.cs | 102 ------------------ .../Migrations/FolderViewSettingMigration.cs | 5 +- 3 files changed, 5 insertions(+), 104 deletions(-) diff --git a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs index d76c89dfb8..6e57b4022a 100644 --- a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.Providers.Music private readonly IApplicationHost _appHost; private readonly ILogger _logger; - public static string MusicBrainzBaseUrl = "http://musicbrainz.fercasas.com:5000"; + public static string MusicBrainzBaseUrl = "https://www.musicbrainz.org"; public MusicBrainzAlbumProvider(IHttpClient httpClient, IApplicationHost appHost, ILogger logger) { diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs index 519731a5cc..dd2f15cfd7 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs @@ -48,13 +48,6 @@ namespace MediaBrowser.Server.Implementations.Persistence return connection; } - public static void BindGetSimilarityScore(IDbConnection connection, ILogger logger) - { - var sqlConnection = (SQLiteConnection)connection; - SimiliarToFunction.Logger = logger; - sqlConnection.BindFunction(new SimiliarToFunction()); - } - public static void BindFunction(this SQLiteConnection connection, SQLiteFunction function) { var attributes = function.GetType().GetCustomAttributes(typeof(SQLiteFunctionAttribute), true).Cast().ToArray(); @@ -65,99 +58,4 @@ namespace MediaBrowser.Server.Implementations.Persistence connection.BindFunction(attributes[0], function); } } - - [SQLiteFunction(Name = "GetSimilarityScore", Arguments = 6, FuncType = FunctionType.Scalar)] - public class SimiliarToFunction : SQLiteFunction - { - internal static ILogger Logger; - - private readonly Dictionary _personTypeScores = new Dictionary(StringComparer.OrdinalIgnoreCase) - { - { PersonType.Actor, 3}, - { PersonType.Director, 5}, - { PersonType.Composer, 2}, - { PersonType.GuestStar, 3}, - { PersonType.Writer, 2}, - { PersonType.Conductor, 2}, - { PersonType.Producer, 2}, - { PersonType.Lyricist, 2} - }; - - public override object Invoke(object[] args) - { - var score = 0; - - // Official rating equals - if ((long)args[0] == 1) - { - score += 10; - } - - // Year difference - long? yearDifference = args[1] == null ? (long?)null : (long)args[1]; - if (yearDifference.HasValue) - { - var diff = Math.Abs(yearDifference.Value); - - // Add if they came out within the same decade - if (diff < 10) - { - score += 2; - } - - // And more if within five years - if (diff < 5) - { - score += 2; - } - } - - // genres - score += Convert.ToInt32((long)args[2]) * 10; - - // tags - score += Convert.ToInt32((long)args[3]) * 10; - - // # of common keywords - score += Convert.ToInt32((long)args[4]) *10; - - // # of common studios - score += Convert.ToInt32((long)args[5]) * 3; - - // studios - //score += GetListScore(args, 7, 8, 3); - - //var rowPeopleNamesText = (args[12] as string) ?? string.Empty; - //var rowPeopleNames = rowPeopleNamesText.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); - - //foreach (var name in rowPeopleNames) - //{ - // // TODO: Send along person types - // score += 3; - //} - - //Logger.Debug("Returning score {0}", score); - return score; - } - - private int GetListScore(object[] args, int index1, int index2, int value = 10) - { - var score = 0; - - var inputGenres = args[index1] as string; - var rowGenres = args[index2] as string; - var inputGenreList = string.IsNullOrWhiteSpace(inputGenres) ? new string[] { } : inputGenres.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); - var rowGenresList = string.IsNullOrWhiteSpace(rowGenres) ? new string[] { } : rowGenres.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); - - foreach (var genre in inputGenreList) - { - if (rowGenresList.Contains(genre, StringComparer.OrdinalIgnoreCase)) - { - score += value; - } - } - - return score; - } - } } diff --git a/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs index 4049d17548..12054864b3 100644 --- a/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs +++ b/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs @@ -24,7 +24,10 @@ namespace MediaBrowser.Server.Startup.Common.Migrations { if (_config.Configuration.IsStartupWizardCompleted) { - _config.Configuration.EnableFolderView = _userManager.Users.Any(i => i.Configuration.DisplayFoldersView); + if (_userManager.Users.Any(i => i.Configuration.DisplayFoldersView)) + { + _config.Configuration.EnableFolderView = true; + } } migrationKeyList.Add(migrationKey); From 68613fcb5b50438928a0c7756022d79b6ec4753d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 4 Jun 2016 13:14:43 -0400 Subject: [PATCH 2/7] remove dead code --- .../Persistence/IDbConnector.cs | 1 - MediaBrowser.Server.Mono/Native/DbConnector.cs | 5 ----- MediaBrowser.ServerApplication/Native/DbConnector.cs | 5 ----- 3 files changed, 11 deletions(-) diff --git a/MediaBrowser.Server.Implementations/Persistence/IDbConnector.cs b/MediaBrowser.Server.Implementations/Persistence/IDbConnector.cs index 985d79a0ac..cac9fe9835 100644 --- a/MediaBrowser.Server.Implementations/Persistence/IDbConnector.cs +++ b/MediaBrowser.Server.Implementations/Persistence/IDbConnector.cs @@ -6,6 +6,5 @@ namespace MediaBrowser.Server.Implementations.Persistence public interface IDbConnector { Task Connect(string dbPath); - void BindSimilarityScoreFunction(IDbConnection connection); } } diff --git a/MediaBrowser.Server.Mono/Native/DbConnector.cs b/MediaBrowser.Server.Mono/Native/DbConnector.cs index 536cd73223..3230f92f9c 100644 --- a/MediaBrowser.Server.Mono/Native/DbConnector.cs +++ b/MediaBrowser.Server.Mono/Native/DbConnector.cs @@ -16,11 +16,6 @@ namespace MediaBrowser.Server.Mono.Native _logger = logger; } - public void BindSimilarityScoreFunction(IDbConnection connection) - { - SqliteExtensions.BindGetSimilarityScore(connection, _logger); - } - public Task Connect(string dbPath) { return SqliteExtensions.ConnectToDb(dbPath, _logger); diff --git a/MediaBrowser.ServerApplication/Native/DbConnector.cs b/MediaBrowser.ServerApplication/Native/DbConnector.cs index f93cad62cb..48ba7d0e7c 100644 --- a/MediaBrowser.ServerApplication/Native/DbConnector.cs +++ b/MediaBrowser.ServerApplication/Native/DbConnector.cs @@ -16,11 +16,6 @@ namespace MediaBrowser.ServerApplication.Native _logger = logger; } - public void BindSimilarityScoreFunction(IDbConnection connection) - { - SqliteExtensions.BindGetSimilarityScore(connection, _logger); - } - public async Task Connect(string dbPath) { try From 59d174ef9e19a4a8a1ba5d3fda325a99ac3f8313 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 4 Jun 2016 13:15:01 -0400 Subject: [PATCH 3/7] remove method call --- .../Persistence/SqliteItemRepository.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index c790e829a8..fcec820292 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -272,8 +272,6 @@ namespace MediaBrowser.Server.Implementations.Persistence new MediaStreamColumns(_connection, Logger).AddColumns(); DataExtensions.Attach(_connection, Path.Combine(_config.ApplicationPaths.DataPath, "userdata_v2.db"), "UserDataDb"); - - dbConnector.BindSimilarityScoreFunction(_connection); } private readonly string[] _retriveItemColumns = From b4737b02117d5233a5a8113ddfa3cc7d54ae689d Mon Sep 17 00:00:00 2001 From: softworkz Date: Sat, 28 May 2016 11:13:01 +0200 Subject: [PATCH 4/7] TheTvDb: Add episode url for external links --- MediaBrowser.Providers/TV/TvExternalIds.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Providers/TV/TvExternalIds.cs b/MediaBrowser.Providers/TV/TvExternalIds.cs index f5a26ba0ae..2ba3b6ff68 100644 --- a/MediaBrowser.Providers/TV/TvExternalIds.cs +++ b/MediaBrowser.Providers/TV/TvExternalIds.cs @@ -88,7 +88,7 @@ namespace MediaBrowser.Providers.TV public string UrlFormatString { - get { return null; } + get { return "https://thetvdb.com/index.php?tab=episode&id={0}"; } } public bool Supports(IHasProviderIds item) From 70b1d39445d7972be58299420f5085c3d7ebeab6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 4 Jun 2016 20:17:35 -0400 Subject: [PATCH 5/7] update buttons --- .../Persistence/SqliteItemRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index fcec820292..460a67ca72 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -975,7 +975,7 @@ namespace MediaBrowser.Server.Implementations.Persistence if (type == null) { - Logger.Debug("Unknown type {0}", typeString); + //Logger.Debug("Unknown type {0}", typeString); return null; } From a9b0816922cb03ad05ceb5f16f8d74e8113a86d9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 5 Jun 2016 14:51:18 -0400 Subject: [PATCH 6/7] update vtt headers --- MediaBrowser.Api/Subtitles/SubtitleService.cs | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/MediaBrowser.Api/Subtitles/SubtitleService.cs b/MediaBrowser.Api/Subtitles/SubtitleService.cs index 1382527e2d..1ce3a59b36 100644 --- a/MediaBrowser.Api/Subtitles/SubtitleService.cs +++ b/MediaBrowser.Api/Subtitles/SubtitleService.cs @@ -101,6 +101,7 @@ namespace MediaBrowser.Api.Subtitles [ApiMember(Name = "CopyTimestamps", Description = "CopyTimestamps", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool CopyTimestamps { get; set; } + public bool AddVttTimeMap { get; set; } } [Route("/Videos/{Id}/{MediaSourceId}/Subtitles/{Index}/subtitles.m3u8", "GET", Summary = "Gets an HLS subtitle playlist.")] @@ -193,7 +194,7 @@ namespace MediaBrowser.Api.Subtitles return ResultFactory.GetResult(builder.ToString(), MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary()); } - public object Get(GetSubtitle request) + public async Task Get(GetSubtitle request) { if (string.Equals(request.Format, "js", StringComparison.OrdinalIgnoreCase)) { @@ -212,21 +213,32 @@ namespace MediaBrowser.Api.Subtitles return ToStaticFileResult(subtitleStream.Path); } - var stream = GetSubtitles(request).Result; + using (var stream = await GetSubtitles(request).ConfigureAwait(false)) + { + using (var reader = new StreamReader(stream)) + { + var text = reader.ReadToEnd(); - return ResultFactory.GetResult(stream, MimeTypes.GetMimeType("file." + request.Format)); + if (string.Equals(request.Format, "vtt", StringComparison.OrdinalIgnoreCase)) + { + text = text.Replace("WEBVTT", "WEBVTT\nX-TIMESTAMP-MAP=MPEGTS:900000,LOCAL:00:00:00.000"); + } + + return ResultFactory.GetResult(text, MimeTypes.GetMimeType("file." + request.Format)); + } + } } - private async Task GetSubtitles(GetSubtitle request) + private Task GetSubtitles(GetSubtitle request) { - return await _subtitleEncoder.GetSubtitles(request.Id, + return _subtitleEncoder.GetSubtitles(request.Id, request.MediaSourceId, request.Index, request.Format, request.StartPositionTicks, request.EndPositionTicks, request.CopyTimestamps, - CancellationToken.None).ConfigureAwait(false); + CancellationToken.None); } public object Get(SearchRemoteSubtitles request) From aa5262de2173b7a6db345db04dd4e4e2487b12ff Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 5 Jun 2016 14:54:21 -0400 Subject: [PATCH 7/7] update subtitle urls --- MediaBrowser.Api/Subtitles/SubtitleService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Api/Subtitles/SubtitleService.cs b/MediaBrowser.Api/Subtitles/SubtitleService.cs index 1ce3a59b36..160fda065f 100644 --- a/MediaBrowser.Api/Subtitles/SubtitleService.cs +++ b/MediaBrowser.Api/Subtitles/SubtitleService.cs @@ -179,7 +179,7 @@ namespace MediaBrowser.Api.Subtitles var endPositionTicks = Math.Min(runtime, positionTicks + segmentLengthTicks); - var url = string.Format("stream.vtt?CopyTimestamps=true,StartPositionTicks={0}&EndPositionTicks={1}&api_key={2}", + var url = string.Format("stream.vtt?CopyTimestamps=true&AddVttTimeMap=true&StartPositionTicks={0}&EndPositionTicks={1}&api_key={2}", positionTicks.ToString(CultureInfo.InvariantCulture), endPositionTicks.ToString(CultureInfo.InvariantCulture), accessToken); @@ -219,7 +219,7 @@ namespace MediaBrowser.Api.Subtitles { var text = reader.ReadToEnd(); - if (string.Equals(request.Format, "vtt", StringComparison.OrdinalIgnoreCase)) + if (string.Equals(request.Format, "vtt", StringComparison.OrdinalIgnoreCase) && request.AddVttTimeMap) { text = text.Replace("WEBVTT", "WEBVTT\nX-TIMESTAMP-MAP=MPEGTS:900000,LOCAL:00:00:00.000"); }