diff --git a/MediaBrowser.Api/Music/InstantMixService.cs b/MediaBrowser.Api/Music/InstantMixService.cs index 905ead86c..d2a4aa60c 100644 --- a/MediaBrowser.Api/Music/InstantMixService.cs +++ b/MediaBrowser.Api/Music/InstantMixService.cs @@ -54,6 +54,11 @@ namespace MediaBrowser.Api.Music public string Id { get; set; } } + [Route("/Items/{Id}/InstantMix", "GET", Summary = "Creates an instant playlist based on a given item")] + public class GetInstantMixFromItem : BaseGetSimilarItemsFromItem + { + } + [Authenticated] public class InstantMixService : BaseApiService { @@ -71,6 +76,17 @@ namespace MediaBrowser.Api.Music _libraryManager = libraryManager; } + public object Get(GetInstantMixFromItem request) + { + var item = _libraryManager.GetItemById(request.Id); + + var user = _userManager.GetUserById(request.UserId); + + var items = _musicManager.GetInstantMixFromItem(item, user); + + return GetResult(items, user, request); + } + public object Get(GetInstantMixFromArtistId request) { var item = _libraryManager.GetItemById(request.Id); diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index 1a152790a..61fd7a55a 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -1,5 +1,4 @@ -using System.Linq; -using MediaBrowser.Common.IO; +using MediaBrowser.Common.IO; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Dlna; @@ -317,6 +316,7 @@ namespace MediaBrowser.Api.Playback.Hls { if (videoStream.KeyFrames == null || videoStream.KeyFrames.Count == 0) { + Logger.Debug("Cannot stream copy video due to missing keyframe info"); return false; } @@ -326,8 +326,9 @@ namespace MediaBrowser.Api.Playback.Hls var length = frame - previousSegment; // Don't allow really long segments because this could result in long download times - if (length > 10000) + if (length > 12000) { + Logger.Debug("Cannot stream copy video due to long segment length of {0}ms", length); return false; } previousSegment = frame; diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index a333fc6e9..594b5ca93 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -419,6 +419,10 @@ namespace MediaBrowser.Controller.Entities return _sortName ?? (_sortName = CreateSortName()); } + set + { + _sortName = value; + } } public string GetInternalMetadataPath() diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 53667c6e1..0af4972f7 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -97,7 +97,8 @@ namespace MediaBrowser.Controller.Entities public int? MaxParentalRating { get; set; } public bool? IsCurrentSchema { get; set; } - + public bool? HasDeadParentId { get; set; } + public InternalItemsQuery() { Tags = new string[] { }; diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index d30b105a5..d21a9dc3b 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -244,7 +244,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { foreach (var stream in mediaInfo.MediaStreams) { - if (stream.Type == MediaStreamType.Video && string.Equals(stream.Codec, "h264", StringComparison.OrdinalIgnoreCase)) + if (stream.Type == MediaStreamType.Video && string.Equals(stream.Codec, "h264", StringComparison.OrdinalIgnoreCase) && !stream.IsInterlaced) { try { @@ -282,7 +282,9 @@ namespace MediaBrowser.MediaEncoding.Encoder private async Task> GetKeyFrames(string inputPath, int videoStreamIndex, CancellationToken cancellationToken) { - const string args = "-i {0} -select_streams v:{1} -show_packets -print_format compact -show_entries packet=flags -show_entries packet=pts_time"; + inputPath = inputPath.Split(new[] { ':' }, 2).Last().Trim('"'); + + const string args = "-show_packets -print_format compact -select_streams v:{1} -show_entries packet=flags -show_entries packet=pts_time \"{0}\""; var process = new Process { @@ -330,7 +332,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { StopProcess(processWrapper, 100, true); } - + //_logger.Debug("Found keyframes {0}", string.Join(",", lines.ToArray())); return lines; } } @@ -347,7 +349,12 @@ namespace MediaBrowser.MediaEncoding.Encoder var line = await reader.ReadLineAsync().ConfigureAwait(false); - var values = (line ?? string.Empty).Split('|') + if (string.IsNullOrWhiteSpace(line)) + { + continue; + } + + var values = line.Split('|') .Where(i => !string.IsNullOrWhiteSpace(i)) .Select(i => i.Split('=')) .Where(i => i.Length == 2) diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index c2524378e..6107c0fbe 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -320,32 +320,11 @@ namespace MediaBrowser.Model.ApiClient Task GetUserViews(string userId, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Gets the instant mix from song async. + /// Gets the instant mix from item asynchronous. /// /// The query. - /// Task{ItemsResult}. - Task GetInstantMixFromSongAsync(SimilarItemsQuery query); - - /// - /// Gets the instant mix from album async. - /// - /// The query. - /// Task{ItemsResult}. - Task GetInstantMixFromAlbumAsync(SimilarItemsQuery query); - - /// - /// Gets the instant mix from artist async. - /// - /// The query. - /// Task{ItemsResult}. - Task GetInstantMixFromArtistAsync(SimilarItemsQuery query); - - /// - /// Gets the instant mix from music genre async. - /// - /// The query. - /// Task{ItemsResult}. - Task GetInstantMixFromMusicGenreAsync(SimilarItemsQuery query); + /// Task<ItemsResult>. + Task GetInstantMixFromItemAsync(SimilarItemsQuery query); /// /// Gets the similar movies async. diff --git a/MediaBrowser.Providers/Folders/DefaultImageProvider.cs b/MediaBrowser.Providers/Folders/DefaultImageProvider.cs new file mode 100644 index 000000000..1fbe20d7f --- /dev/null +++ b/MediaBrowser.Providers/Folders/DefaultImageProvider.cs @@ -0,0 +1,147 @@ +using MediaBrowser.Common.Net; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Providers; +using MediaBrowser.Providers.Genres; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Providers.Folders +{ + public class DefaultImageProvider : IRemoteImageProvider, IHasItemChangeMonitor + { + private readonly IHttpClient _httpClient; + + public DefaultImageProvider(IHttpClient httpClient) + { + _httpClient = httpClient; + } + + public IEnumerable GetSupportedImages(IHasImages item) + { + return new List + { + ImageType.Primary, + ImageType.Thumb + }; + } + + public Task> GetImages(IHasImages item, CancellationToken cancellationToken) + { + var view = item as UserView; + + if (view != null) + { + return GetImages(view.ViewType, cancellationToken); + } + + var folder = (ICollectionFolder)item; + return GetImages(folder.CollectionType, cancellationToken); + } + + private Task> GetImages(string viewType, CancellationToken cancellationToken) + { + var url = GetImageUrl(viewType); + + var list = new List(); + + if (!string.IsNullOrWhiteSpace(url)) + { + list.AddRange(new List{ + new RemoteImageInfo + { + ProviderName = Name, + Url = url, + Type = ImageType.Primary + }, + + new RemoteImageInfo + { + ProviderName = Name, + Url = url, + Type = ImageType.Thumb + } + }); + } + + return Task.FromResult>(list); + } + + private string GetImageUrl(string viewType) + { + const string urlPrefix = "https://raw.githubusercontent.com/MediaBrowser/Emby.Resources/master/images/folders/"; + + if (string.Equals(viewType, CollectionType.Books, StringComparison.OrdinalIgnoreCase)) + { + //return urlPrefix + "books.png"; + } + if (string.Equals(viewType, CollectionType.Games, StringComparison.OrdinalIgnoreCase)) + { + //return urlPrefix + "games.png"; + } + if (string.Equals(viewType, CollectionType.Music, StringComparison.OrdinalIgnoreCase)) + { + //return urlPrefix + "music.png"; + } + if (string.Equals(viewType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase)) + { + //return urlPrefix + "photos.png"; + } + if (string.Equals(viewType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) + { + //return urlPrefix + "tv.png"; + } + if (string.Equals(viewType, CollectionType.Channels, StringComparison.OrdinalIgnoreCase)) + { + //return urlPrefix + "channels.png"; + } + if (string.Equals(viewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase)) + { + return urlPrefix + "livetv.png"; + } + if (string.Equals(viewType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) + { + //return urlPrefix + "movies.png"; + } + + return null; + //return urlPrefix + "generic.png"; + } + + public string Name + { + get { return "Default Image Provider"; } + } + + public bool Supports(IHasImages item) + { + var view = item as UserView; + + if (view != null) + { + return !view.UserId.HasValue; + } + + return item is ICollectionFolder; + } + + public Task GetImageResponse(string url, CancellationToken cancellationToken) + { + return _httpClient.GetResponse(new HttpRequestOptions + { + CancellationToken = cancellationToken, + Url = url, + ResourcePool = GenreImageProvider.ImageDownloadResourcePool + }); + } + + public bool HasChanged(IHasMetadata item, MetadataStatus status, IDirectoryService directoryService) + { + return GetSupportedImages(item).Any(i => !item.HasImage(i)); + } + } +} diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj index 444567afa..1d323e567 100644 --- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj +++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj @@ -83,6 +83,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs index 973519a77..8a659fb65 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs @@ -41,7 +41,7 @@ namespace MediaBrowser.Server.Implementations.Connect _timer = new Timer(TimerCallback, null, TimeSpan.FromSeconds(5), TimeSpan.FromHours(3)); } - private readonly string[] _ipLookups = { "http://bot.whatismyipaddress.com", "https://connect.mediabrowser.tv/service/ip" }; + private readonly string[] _ipLookups = { "http://bot.whatismyipaddress.com", "https://connect.emby.media/service/ip" }; private async void TimerCallback(object state) { diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index 4569503c0..7cd96c5f3 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -371,7 +371,7 @@ namespace MediaBrowser.Server.Implementations.Connect private string GetConnectUrl(string handler) { - return "https://connect.mediabrowser.tv/service/" + handler; + return "https://connect.emby.media/service/" + handler; } public async Task LinkUser(string userId, string connectUsername) diff --git a/MediaBrowser.Server.Implementations/Library/MusicManager.cs b/MediaBrowser.Server.Implementations/Library/MusicManager.cs index b83256342..683e6c5cc 100644 --- a/MediaBrowser.Server.Implementations/Library/MusicManager.cs +++ b/MediaBrowser.Server.Implementations/Library/MusicManager.cs @@ -52,6 +52,18 @@ namespace MediaBrowser.Server.Implementations.Library return GetInstantMixFromGenres(genres, user); } + public IEnumerable