mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-02 18:47:18 -05:00 
			
		
		
		
	
						commit
						25b25afbb8
					
				@ -470,7 +470,7 @@ namespace Emby.Server.Implementations.FileOrganization
 | 
			
		||||
                return new List<string>();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var episodePaths = series.GetRecursiveChildren()
 | 
			
		||||
            var episodePaths = series.GetRecursiveChildren(i => i is Episode)
 | 
			
		||||
                .OfType<Episode>()
 | 
			
		||||
                .Where(i =>
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,7 @@ using MediaBrowser.Controller.Playlists;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using MediaBrowser.Model.Querying;
 | 
			
		||||
 | 
			
		||||
namespace Emby.Server.Implementations.Library
 | 
			
		||||
{
 | 
			
		||||
@ -27,35 +28,14 @@ namespace Emby.Server.Implementations.Library
 | 
			
		||||
            return list.Concat(GetInstantMixFromGenres(item.Genres, user));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IEnumerable<Audio> GetInstantMixFromArtist(MusicArtist artist, User user)
 | 
			
		||||
        public IEnumerable<Audio> GetInstantMixFromArtist(MusicArtist item, User user)
 | 
			
		||||
        {
 | 
			
		||||
            var genres = user.RootFolder
 | 
			
		||||
                .GetRecursiveChildren(user, new InternalItemsQuery(user)
 | 
			
		||||
                {
 | 
			
		||||
                    IncludeItemTypes = new[] { typeof(Audio).Name }
 | 
			
		||||
                })
 | 
			
		||||
                .Cast<Audio>()
 | 
			
		||||
                .Where(i => i.HasAnyArtist(artist.Name))
 | 
			
		||||
                .SelectMany(i => i.Genres)
 | 
			
		||||
                .Concat(artist.Genres)
 | 
			
		||||
                .Distinct(StringComparer.OrdinalIgnoreCase);
 | 
			
		||||
 | 
			
		||||
            return GetInstantMixFromGenres(genres, user);
 | 
			
		||||
            return GetInstantMixFromGenres(item.Genres, user);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IEnumerable<Audio> GetInstantMixFromAlbum(MusicAlbum item, User user)
 | 
			
		||||
        {
 | 
			
		||||
            var genres = item
 | 
			
		||||
                .GetRecursiveChildren(user, new InternalItemsQuery(user)
 | 
			
		||||
                {
 | 
			
		||||
                    IncludeItemTypes = new[] { typeof(Audio).Name }
 | 
			
		||||
                })
 | 
			
		||||
               .Cast<Audio>()
 | 
			
		||||
               .SelectMany(i => i.Genres)
 | 
			
		||||
               .Concat(item.Genres)
 | 
			
		||||
               .DistinctNames();
 | 
			
		||||
 | 
			
		||||
            return GetInstantMixFromGenres(genres, user);
 | 
			
		||||
            return GetInstantMixFromGenres(item.Genres, user);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IEnumerable<Audio> GetInstantMixFromFolder(Folder item, User user)
 | 
			
		||||
@ -63,7 +43,7 @@ namespace Emby.Server.Implementations.Library
 | 
			
		||||
            var genres = item
 | 
			
		||||
               .GetRecursiveChildren(user, new InternalItemsQuery(user)
 | 
			
		||||
               {
 | 
			
		||||
                   IncludeItemTypes = new[] {typeof(Audio).Name}
 | 
			
		||||
                   IncludeItemTypes = new[] { typeof(Audio).Name }
 | 
			
		||||
               })
 | 
			
		||||
               .Cast<Audio>()
 | 
			
		||||
               .SelectMany(i => i.Genres)
 | 
			
		||||
@ -75,41 +55,40 @@ namespace Emby.Server.Implementations.Library
 | 
			
		||||
 | 
			
		||||
        public IEnumerable<Audio> GetInstantMixFromPlaylist(Playlist item, User user)
 | 
			
		||||
        {
 | 
			
		||||
            var genres = item
 | 
			
		||||
               .GetRecursiveChildren(user, new InternalItemsQuery(user)
 | 
			
		||||
               {
 | 
			
		||||
                   IncludeItemTypes = new[] { typeof(Audio).Name }
 | 
			
		||||
               })
 | 
			
		||||
               .Cast<Audio>()
 | 
			
		||||
               .SelectMany(i => i.Genres)
 | 
			
		||||
               .Concat(item.Genres)
 | 
			
		||||
               .DistinctNames();
 | 
			
		||||
 | 
			
		||||
            return GetInstantMixFromGenres(genres, user);
 | 
			
		||||
            return GetInstantMixFromGenres(item.Genres, user);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IEnumerable<Audio> GetInstantMixFromGenres(IEnumerable<string> genres, User user)
 | 
			
		||||
        {
 | 
			
		||||
            var genreList = genres.ToList();
 | 
			
		||||
            var genreIds = genres.DistinctNames().Select(i =>
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    return _libraryManager.GetMusicGenre(i).Id.ToString("N");
 | 
			
		||||
                }
 | 
			
		||||
                catch
 | 
			
		||||
                {
 | 
			
		||||
                    return null;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            var inputItems = _libraryManager.GetItemList(new InternalItemsQuery(user)
 | 
			
		||||
            }).Where(i => i != null);
 | 
			
		||||
 | 
			
		||||
            return GetInstantMixFromGenreIds(genreIds, user);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IEnumerable<Audio> GetInstantMixFromGenreIds(IEnumerable<string> genreIds, User user)
 | 
			
		||||
        {
 | 
			
		||||
            return _libraryManager.GetItemList(new InternalItemsQuery(user)
 | 
			
		||||
            {
 | 
			
		||||
                IncludeItemTypes = new[] { typeof(Audio).Name },
 | 
			
		||||
 | 
			
		||||
                Genres = genreList.ToArray()
 | 
			
		||||
                GenreIds = genreIds.ToArray(),
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
                Limit = 200,
 | 
			
		||||
 | 
			
		||||
            var genresDictionary = genreList.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
 | 
			
		||||
                SortBy = new[] { ItemSortBy.Random }
 | 
			
		||||
 | 
			
		||||
            return inputItems
 | 
			
		||||
                .Cast<Audio>()
 | 
			
		||||
                .Select(i => new Tuple<Audio, int>(i, i.Genres.Count(genresDictionary.ContainsKey)))
 | 
			
		||||
                .OrderByDescending(i => i.Item2)
 | 
			
		||||
                .ThenBy(i => Guid.NewGuid())
 | 
			
		||||
                .Select(i => i.Item1)
 | 
			
		||||
                .Take(200)
 | 
			
		||||
                .OrderBy(i => Guid.NewGuid());
 | 
			
		||||
            }).Cast<Audio>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IEnumerable<Audio> GetInstantMixFromItem(BaseItem item, User user)
 | 
			
		||||
@ -117,7 +96,7 @@ namespace Emby.Server.Implementations.Library
 | 
			
		||||
            var genre = item as MusicGenre;
 | 
			
		||||
            if (genre != null)
 | 
			
		||||
            {
 | 
			
		||||
                return GetInstantMixFromGenres(new[] { item.Name }, user);
 | 
			
		||||
                return GetInstantMixFromGenreIds(new[] { item.Id.ToString("N") }, user);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var playlist = item as Playlist;
 | 
			
		||||
 | 
			
		||||
@ -35,9 +35,11 @@ namespace Emby.Server.Implementations.Logging
 | 
			
		||||
 | 
			
		||||
            // Write to console just in case file logging fails
 | 
			
		||||
            _console.WriteLine("UnhandledException");
 | 
			
		||||
            _console.WriteLine(builder.ToString());
 | 
			
		||||
 | 
			
		||||
            _fileSystem.WriteAllText(path, builder.ToString());
 | 
			
		||||
            var logMessage = builder.ToString();
 | 
			
		||||
            _console.WriteLine(logMessage);
 | 
			
		||||
 | 
			
		||||
            _fileSystem.WriteAllText(path, logMessage);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -720,6 +720,13 @@ namespace MediaBrowser.Api.Playback
 | 
			
		||||
 | 
			
		||||
            state.IsInputVideo = string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase);
 | 
			
		||||
 | 
			
		||||
            var primaryImage = item.GetImageInfo(ImageType.Primary, 0) ??
 | 
			
		||||
                         item.Parents.Select(i => i.GetImageInfo(ImageType.Primary, 0)).FirstOrDefault(i => i != null);
 | 
			
		||||
            if (primaryImage != null)
 | 
			
		||||
            {
 | 
			
		||||
                state.AlbumCoverPath = primaryImage.Path;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            MediaSourceInfo mediaSource = null;
 | 
			
		||||
            if (string.IsNullOrWhiteSpace(request.LiveStreamId))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
@ -15,6 +15,8 @@ namespace MediaBrowser.Api.Playback.Hls
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Class GetHlsAudioSegment
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    // Can't require authentication just yet due to seeing some requests come from Chrome without full query string
 | 
			
		||||
    //[Authenticated]
 | 
			
		||||
    [Route("/Audio/{Id}/hls/{SegmentId}/stream.mp3", "GET")]
 | 
			
		||||
    [Route("/Audio/{Id}/hls/{SegmentId}/stream.aac", "GET")]
 | 
			
		||||
    public class GetHlsAudioSegmentLegacy
 | 
			
		||||
@ -38,6 +40,7 @@ namespace MediaBrowser.Api.Playback.Hls
 | 
			
		||||
    /// Class GetHlsVideoSegment
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Route("/Videos/{Id}/hls/{PlaylistId}/stream.m3u8", "GET")]
 | 
			
		||||
    [Authenticated]
 | 
			
		||||
    public class GetHlsPlaylistLegacy
 | 
			
		||||
    {
 | 
			
		||||
        // TODO: Deprecate with new iOS app
 | 
			
		||||
@ -52,6 +55,7 @@ namespace MediaBrowser.Api.Playback.Hls
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [Route("/Videos/ActiveEncodings", "DELETE")]
 | 
			
		||||
    [Authenticated]
 | 
			
		||||
    public class StopEncodingProcess
 | 
			
		||||
    {
 | 
			
		||||
        [ApiMember(Name = "DeviceId", Description = "The device id of the client requesting. Used to stop encoding processes when needed.", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "DELETE")]
 | 
			
		||||
@ -64,6 +68,8 @@ namespace MediaBrowser.Api.Playback.Hls
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Class GetHlsVideoSegment
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    // Can't require authentication just yet due to seeing some requests come from Chrome without full query string
 | 
			
		||||
    //[Authenticated]
 | 
			
		||||
    [Route("/Videos/{Id}/hls/{PlaylistId}/{SegmentId}.{SegmentContainer}", "GET")]
 | 
			
		||||
    public class GetHlsVideoSegmentLegacy : VideoStreamRequest
 | 
			
		||||
    {
 | 
			
		||||
@ -76,7 +82,6 @@ namespace MediaBrowser.Api.Playback.Hls
 | 
			
		||||
        public string SegmentId { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [Authenticated]
 | 
			
		||||
    public class HlsSegmentService : BaseApiService
 | 
			
		||||
    {
 | 
			
		||||
        private readonly IServerApplicationPaths _appPaths;
 | 
			
		||||
 | 
			
		||||
@ -59,42 +59,7 @@ namespace MediaBrowser.Api.Playback.Progressive
 | 
			
		||||
        {
 | 
			
		||||
            var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
 | 
			
		||||
 | 
			
		||||
            var audioTranscodeParams = new List<string>();
 | 
			
		||||
 | 
			
		||||
            var bitrate = state.OutputAudioBitrate;
 | 
			
		||||
 | 
			
		||||
            if (bitrate.HasValue)
 | 
			
		||||
            {
 | 
			
		||||
                audioTranscodeParams.Add("-ab " + bitrate.Value.ToString(UsCulture));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (state.OutputAudioChannels.HasValue)
 | 
			
		||||
            {
 | 
			
		||||
                audioTranscodeParams.Add("-ac " + state.OutputAudioChannels.Value.ToString(UsCulture));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // opus will fail on 44100
 | 
			
		||||
            if (!string.Equals(state.OutputAudioCodec, "opus", global::System.StringComparison.OrdinalIgnoreCase))
 | 
			
		||||
            {
 | 
			
		||||
                if (state.OutputAudioSampleRate.HasValue)
 | 
			
		||||
                {
 | 
			
		||||
                    audioTranscodeParams.Add("-ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            const string vn = " -vn";
 | 
			
		||||
 | 
			
		||||
            var threads = EncodingHelper.GetNumberOfThreads(state, encodingOptions, false);
 | 
			
		||||
 | 
			
		||||
            var inputModifier = EncodingHelper.GetInputModifier(state, encodingOptions);
 | 
			
		||||
 | 
			
		||||
            return string.Format("{0} {1} -threads {2}{3} {4} -id3v2_version 3 -write_id3v1 1 -y \"{5}\"",
 | 
			
		||||
                inputModifier,
 | 
			
		||||
                EncodingHelper.GetInputArgument(state, encodingOptions),
 | 
			
		||||
                threads,
 | 
			
		||||
                vn,
 | 
			
		||||
                string.Join(" ", audioTranscodeParams.ToArray()),
 | 
			
		||||
                outputPath).Trim();
 | 
			
		||||
            return EncodingHelper.GetProgressiveAudioFullCommandLine(state, encodingOptions, outputPath);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public AudioService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext, imageProcessor)
 | 
			
		||||
 | 
			
		||||
@ -112,7 +112,7 @@ namespace MediaBrowser.Controller.Entities.Audio
 | 
			
		||||
 | 
			
		||||
        public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
 | 
			
		||||
        {
 | 
			
		||||
            query.Genres = new[] { Name };
 | 
			
		||||
            query.GenreIds = new[] { Id.ToString("N") };
 | 
			
		||||
            query.IncludeItemTypes = new[] { typeof(MusicVideo).Name, typeof(Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name };
 | 
			
		||||
 | 
			
		||||
            return LibraryManager.GetItemList(query);
 | 
			
		||||
 | 
			
		||||
@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Entities
 | 
			
		||||
 | 
			
		||||
        public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
 | 
			
		||||
        {
 | 
			
		||||
            query.Genres = new[] { Name };
 | 
			
		||||
            query.GenreIds = new[] { Id.ToString("N") };
 | 
			
		||||
            query.IncludeItemTypes = new[] { typeof(Game).Name };
 | 
			
		||||
 | 
			
		||||
            return LibraryManager.GetItemList(query);
 | 
			
		||||
 | 
			
		||||
@ -93,7 +93,7 @@ namespace MediaBrowser.Controller.Entities
 | 
			
		||||
 | 
			
		||||
        public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
 | 
			
		||||
        {
 | 
			
		||||
            query.Genres = new[] { Name };
 | 
			
		||||
            query.GenreIds = new[] { Id.ToString("N") };
 | 
			
		||||
            query.ExcludeItemTypes = new[] { typeof(Game).Name, typeof(MusicVideo).Name, typeof(Audio.Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name };
 | 
			
		||||
 | 
			
		||||
            return LibraryManager.GetItemList(query);
 | 
			
		||||
 | 
			
		||||
@ -152,9 +152,7 @@ namespace MediaBrowser.Controller.Entities.Movies
 | 
			
		||||
            var currentOfficialRating = OfficialRating;
 | 
			
		||||
 | 
			
		||||
            // Gather all possible ratings
 | 
			
		||||
            var ratings = GetRecursiveChildren()
 | 
			
		||||
                .Concat(GetLinkedChildren())
 | 
			
		||||
                .Where(i => i is Movie || i is Series || i is MusicAlbum || i is Game)
 | 
			
		||||
            var ratings = GetRecursiveChildren(i => i is Movie || i is Series || i is MusicAlbum || i is Game)
 | 
			
		||||
                .Select(i => i.OfficialRating)
 | 
			
		||||
                .Where(i => !string.IsNullOrEmpty(i))
 | 
			
		||||
                .Distinct(StringComparer.OrdinalIgnoreCase)
 | 
			
		||||
 | 
			
		||||
@ -586,7 +586,7 @@ namespace MediaBrowser.Controller.Entities
 | 
			
		||||
        {
 | 
			
		||||
            query.Recursive = true;
 | 
			
		||||
            query.ParentId = queryParent.Id;
 | 
			
		||||
            query.Genres = new[] { displayParent.Name };
 | 
			
		||||
            query.GenreIds = new[] { displayParent.Id.ToString("N") };
 | 
			
		||||
            query.SetUser(user);
 | 
			
		||||
 | 
			
		||||
            query.IncludeItemTypes = new[] { typeof(Movie).Name };
 | 
			
		||||
@ -729,7 +729,7 @@ namespace MediaBrowser.Controller.Entities
 | 
			
		||||
        {
 | 
			
		||||
            query.Recursive = true;
 | 
			
		||||
            query.ParentId = queryParent.Id;
 | 
			
		||||
            query.Genres = new[] { displayParent.Name };
 | 
			
		||||
            query.GenreIds = new[] { displayParent.Id.ToString("N") };
 | 
			
		||||
            query.SetUser(user);
 | 
			
		||||
 | 
			
		||||
            query.IncludeItemTypes = new[] { typeof(Series).Name };
 | 
			
		||||
@ -905,6 +905,11 @@ namespace MediaBrowser.Controller.Entities
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (request.GenreIds.Length > 0)
 | 
			
		||||
            {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (request.HasImdbId.HasValue)
 | 
			
		||||
            {
 | 
			
		||||
                return false;
 | 
			
		||||
@ -1768,26 +1773,6 @@ namespace MediaBrowser.Controller.Entities
 | 
			
		||||
            return new List<Folder> { parent };
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private IEnumerable<BaseItem> GetRecursiveChildren(Folder parent, User user, IEnumerable<string> viewTypes)
 | 
			
		||||
        {
 | 
			
		||||
            if (parent == null || parent is UserView)
 | 
			
		||||
            {
 | 
			
		||||
                if (user == null)
 | 
			
		||||
                {
 | 
			
		||||
                    return GetMediaFolders(null, viewTypes).SelectMany(i => i.GetRecursiveChildren());
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                return GetMediaFolders(user, viewTypes).SelectMany(i => i.GetRecursiveChildren(user));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (user == null)
 | 
			
		||||
            {
 | 
			
		||||
                return parent.GetRecursiveChildren();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return parent.GetRecursiveChildren(user);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private async Task<QueryResult<BaseItem>> GetLiveTvView(Folder queryParent, User user, InternalItemsQuery query)
 | 
			
		||||
        {
 | 
			
		||||
            if (query.Recursive)
 | 
			
		||||
 | 
			
		||||
@ -1979,5 +1979,66 @@ namespace MediaBrowser.Controller.MediaEncoding
 | 
			
		||||
 | 
			
		||||
            return args;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public string GetProgressiveAudioFullCommandLine(EncodingJobInfo state, EncodingOptions encodingOptions, string outputPath)
 | 
			
		||||
        {
 | 
			
		||||
            var audioTranscodeParams = new List<string>();
 | 
			
		||||
 | 
			
		||||
            var bitrate = state.OutputAudioBitrate;
 | 
			
		||||
 | 
			
		||||
            if (bitrate.HasValue)
 | 
			
		||||
            {
 | 
			
		||||
                audioTranscodeParams.Add("-ab " + bitrate.Value.ToString(_usCulture));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (state.OutputAudioChannels.HasValue)
 | 
			
		||||
            {
 | 
			
		||||
                audioTranscodeParams.Add("-ac " + state.OutputAudioChannels.Value.ToString(_usCulture));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // opus will fail on 44100
 | 
			
		||||
            if (!string.Equals(state.OutputAudioCodec, "opus", StringComparison.OrdinalIgnoreCase))
 | 
			
		||||
            {
 | 
			
		||||
                if (state.OutputAudioSampleRate.HasValue)
 | 
			
		||||
                {
 | 
			
		||||
                    audioTranscodeParams.Add("-ar " + state.OutputAudioSampleRate.Value.ToString(_usCulture));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var albumCoverInput = string.Empty;
 | 
			
		||||
            var mapArgs = string.Empty;
 | 
			
		||||
            var metadata = string.Empty;
 | 
			
		||||
            var vn = string.Empty;
 | 
			
		||||
 | 
			
		||||
            var hasArt = !string.IsNullOrWhiteSpace(state.AlbumCoverPath);
 | 
			
		||||
            hasArt = false;
 | 
			
		||||
 | 
			
		||||
            if (hasArt)
 | 
			
		||||
            {
 | 
			
		||||
                albumCoverInput = " -i \"" + state.AlbumCoverPath + "\"";
 | 
			
		||||
                mapArgs = " -map 0:a -map 1:v -c:v copy";
 | 
			
		||||
                metadata = " -metadata:s:v title=\"Album cover\" -metadata:s:v comment=\"Cover(Front)\"";
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                vn = " -vn";
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var threads = GetNumberOfThreads(state, encodingOptions, false);
 | 
			
		||||
 | 
			
		||||
            var inputModifier = GetInputModifier(state, encodingOptions);
 | 
			
		||||
 | 
			
		||||
            return string.Format("{0} {1}{7}{8} -threads {2}{3} {4} -id3v2_version 3 -write_id3v1 1{6} -y \"{5}\"",
 | 
			
		||||
                inputModifier,
 | 
			
		||||
                GetInputArgument(state, encodingOptions),
 | 
			
		||||
                threads,
 | 
			
		||||
                vn,
 | 
			
		||||
                string.Join(" ", audioTranscodeParams.ToArray()),
 | 
			
		||||
                outputPath,
 | 
			
		||||
                metadata,
 | 
			
		||||
                albumCoverInput,
 | 
			
		||||
                mapArgs).Trim();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -56,6 +56,8 @@ namespace MediaBrowser.Controller.MediaEncoding
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public string AlbumCoverPath { get; set; }
 | 
			
		||||
 | 
			
		||||
        public string InputAudioSync { get; set; }
 | 
			
		||||
        public string InputVideoSync { get; set; }
 | 
			
		||||
        public TransportStreamTimestamp InputTimestamp { get; set; }
 | 
			
		||||
 | 
			
		||||
@ -134,34 +134,27 @@ namespace MediaBrowser.Controller.Playlists
 | 
			
		||||
            var musicGenre = item as MusicGenre;
 | 
			
		||||
            if (musicGenre != null)
 | 
			
		||||
            {
 | 
			
		||||
                var items = LibraryManager.GetItemList(new InternalItemsQuery(user)
 | 
			
		||||
                return LibraryManager.GetItemList(new InternalItemsQuery(user)
 | 
			
		||||
                {
 | 
			
		||||
                    Recursive = true,
 | 
			
		||||
                    IncludeItemTypes = new[] { typeof(Audio).Name },
 | 
			
		||||
                    Genres = new[] { musicGenre.Name }
 | 
			
		||||
                    GenreIds = new[] { musicGenre.Id.ToString("N") },
 | 
			
		||||
                    SortBy = new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName },
 | 
			
		||||
                    SortOrder = SortOrder.Ascending
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                return LibraryManager.Sort(items, user, new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, SortOrder.Ascending);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var musicArtist = item as MusicArtist;
 | 
			
		||||
            if (musicArtist != null)
 | 
			
		||||
            {
 | 
			
		||||
                Func<BaseItem, bool> filter = i =>
 | 
			
		||||
                {
 | 
			
		||||
                    var audio = i as Audio;
 | 
			
		||||
                    return audio != null && audio.HasAnyArtist(musicArtist.Name);
 | 
			
		||||
                };
 | 
			
		||||
 | 
			
		||||
                var items = user == null
 | 
			
		||||
                    ? LibraryManager.RootFolder.GetRecursiveChildren(filter)
 | 
			
		||||
                    : user.RootFolder.GetRecursiveChildren(user, new InternalItemsQuery(user)
 | 
			
		||||
                return LibraryManager.GetItemList(new InternalItemsQuery(user)
 | 
			
		||||
                {
 | 
			
		||||
                    Recursive = true,
 | 
			
		||||
                    IncludeItemTypes = new[] { typeof(Audio).Name },
 | 
			
		||||
                        ArtistIds = new[] { musicArtist.Id.ToString("N") }
 | 
			
		||||
                    ArtistIds = new[] { musicArtist.Id.ToString("N") },
 | 
			
		||||
                    SortBy = new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName },
 | 
			
		||||
                    SortOrder = SortOrder.Ascending
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                return LibraryManager.Sort(items, user, new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, SortOrder.Ascending);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var folder = item as Folder;
 | 
			
		||||
 | 
			
		||||
@ -5,8 +5,6 @@ using MediaBrowser.Controller.Session;
 | 
			
		||||
using MediaBrowser.Model.IO;
 | 
			
		||||
using MediaBrowser.Model.Logging;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using MediaBrowser.Model.Diagnostics;
 | 
			
		||||
 | 
			
		||||
namespace MediaBrowser.MediaEncoding.Encoder
 | 
			
		||||
@ -19,66 +17,9 @@ namespace MediaBrowser.MediaEncoding.Encoder
 | 
			
		||||
 | 
			
		||||
        protected override string GetCommandLineArguments(EncodingJob state)
 | 
			
		||||
        {
 | 
			
		||||
            var audioTranscodeParams = new List<string>();
 | 
			
		||||
 | 
			
		||||
            var bitrate = state.OutputAudioBitrate;
 | 
			
		||||
 | 
			
		||||
            if (bitrate.HasValue)
 | 
			
		||||
            {
 | 
			
		||||
                audioTranscodeParams.Add("-ab " + bitrate.Value.ToString(UsCulture));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (state.OutputAudioChannels.HasValue)
 | 
			
		||||
            {
 | 
			
		||||
                audioTranscodeParams.Add("-ac " + state.OutputAudioChannels.Value.ToString(UsCulture));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // opus will fail on 44100
 | 
			
		||||
            if (!string.Equals(state.OutputAudioCodec, "opus", StringComparison.OrdinalIgnoreCase))
 | 
			
		||||
            {
 | 
			
		||||
                if (state.OutputAudioSampleRate.HasValue)
 | 
			
		||||
                {
 | 
			
		||||
                    audioTranscodeParams.Add("-ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var encodingOptions = GetEncodingOptions();
 | 
			
		||||
 | 
			
		||||
            var threads = EncodingHelper.GetNumberOfThreads(state, encodingOptions, false);
 | 
			
		||||
 | 
			
		||||
            var inputModifier = EncodingHelper.GetInputModifier(state, encodingOptions);
 | 
			
		||||
 | 
			
		||||
            var albumCoverInput = string.Empty;
 | 
			
		||||
            var mapArgs = string.Empty;
 | 
			
		||||
            var metadata = string.Empty;
 | 
			
		||||
            var vn = string.Empty;
 | 
			
		||||
 | 
			
		||||
            var hasArt = !string.IsNullOrWhiteSpace(state.AlbumCoverPath);
 | 
			
		||||
            hasArt = false;
 | 
			
		||||
 | 
			
		||||
            if (hasArt)
 | 
			
		||||
            {
 | 
			
		||||
                albumCoverInput = " -i \"" + state.AlbumCoverPath + "\"";
 | 
			
		||||
                mapArgs = " -map 0:a -map 1:v -c:v copy";
 | 
			
		||||
                metadata = " -metadata:s:v title=\"Album cover\" -metadata:s:v comment=\"Cover(Front)\"";
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                vn = " -vn";
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var result = string.Format("{0} {1}{6}{7} -threads {2}{3} {4} -id3v2_version 3 -write_id3v1 1{8} -y \"{5}\"",
 | 
			
		||||
                inputModifier,
 | 
			
		||||
                EncodingHelper.GetInputArgument(state, GetEncodingOptions()),
 | 
			
		||||
                threads,
 | 
			
		||||
                vn,
 | 
			
		||||
                string.Join(" ", audioTranscodeParams.ToArray()),
 | 
			
		||||
                state.OutputFilePath,
 | 
			
		||||
                albumCoverInput,
 | 
			
		||||
                mapArgs,
 | 
			
		||||
                metadata).Trim();
 | 
			
		||||
 | 
			
		||||
            return result;
 | 
			
		||||
            return EncodingHelper.GetProgressiveAudioFullCommandLine(state, encodingOptions, state.OutputFilePath);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        protected override string GetOutputFileExtension(EncodingJob state)
 | 
			
		||||
 | 
			
		||||
@ -41,8 +41,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
 | 
			
		||||
 | 
			
		||||
        public string ItemType { get; set; }
 | 
			
		||||
 | 
			
		||||
        public string AlbumCoverPath { get; set; }
 | 
			
		||||
 | 
			
		||||
        public string GetMimeType(string outputPath)
 | 
			
		||||
        {
 | 
			
		||||
            if (!string.IsNullOrEmpty(MimeType))
 | 
			
		||||
 | 
			
		||||
@ -20,8 +20,7 @@ namespace MediaBrowser.Providers.Music
 | 
			
		||||
        {
 | 
			
		||||
            var album = (MusicAlbum)item;
 | 
			
		||||
 | 
			
		||||
            var image = album.GetRecursiveChildren()
 | 
			
		||||
                .OfType<Audio>()
 | 
			
		||||
            var image = album.GetRecursiveChildren(i => !i.IsFolder)
 | 
			
		||||
                .Select(i => i.GetImageInfo(type, 0))
 | 
			
		||||
                .FirstOrDefault(i => i != null && i.IsLocalFile);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -53,8 +53,8 @@ namespace MediaBrowser.Providers.TV
 | 
			
		||||
 | 
			
		||||
        private async Task<bool> AddDummySeasonFolders(Series series, CancellationToken cancellationToken)
 | 
			
		||||
        {
 | 
			
		||||
            var episodesInSeriesFolder = series.GetRecursiveChildren()
 | 
			
		||||
                .OfType<Episode>()
 | 
			
		||||
            var episodesInSeriesFolder = series.GetRecursiveChildren(i => i is Episode)
 | 
			
		||||
                .Cast<Episode>()
 | 
			
		||||
                .Where(i => !i.IsInSeasonFolder)
 | 
			
		||||
                .ToList();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -203,7 +203,7 @@ namespace MediaBrowser.Providers.TV
 | 
			
		||||
            CancellationToken cancellationToken)
 | 
			
		||||
        {
 | 
			
		||||
            var existingEpisodes = (from s in series
 | 
			
		||||
                                    from c in s.GetRecursiveChildren().OfType<Episode>()
 | 
			
		||||
                                    from c in s.GetRecursiveChildren(i => i is Episode).Cast<Episode>()
 | 
			
		||||
                                    select new Tuple<int, Episode>((c.ParentIndexNumber ?? 0) , c))
 | 
			
		||||
                                   .ToList();
 | 
			
		||||
 | 
			
		||||
@ -275,13 +275,16 @@ namespace MediaBrowser.Providers.TV
 | 
			
		||||
            return hasChanges;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Series DetermineAppropriateSeries(IEnumerable<Series> series, int seasonNumber)
 | 
			
		||||
        private Series DetermineAppropriateSeries(List<Series> series, int seasonNumber)
 | 
			
		||||
        {
 | 
			
		||||
            var seriesAndOffsets = series.ToList();
 | 
			
		||||
            if (series.Count == 1)
 | 
			
		||||
            {
 | 
			
		||||
                return series[0];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return seriesAndOffsets.FirstOrDefault(s => s.GetRecursiveChildren().OfType<Season>().Any(season => (season.IndexNumber) == seasonNumber)) ??
 | 
			
		||||
                            seriesAndOffsets.FirstOrDefault(s => s.GetRecursiveChildren().OfType<Season>().Any(season => (season.IndexNumber) == 1)) ??
 | 
			
		||||
                            seriesAndOffsets.OrderBy(s => s.GetRecursiveChildren().OfType<Season>().Select(season => season.IndexNumber).Min()).First();
 | 
			
		||||
            return series.FirstOrDefault(s => s.GetRecursiveChildren(i => i is Season).Any(season => (season.IndexNumber) == seasonNumber)) ??
 | 
			
		||||
                            series.FirstOrDefault(s => s.GetRecursiveChildren(i => i is Season).Any(season => (season.IndexNumber) == 1)) ??
 | 
			
		||||
                            series.OrderBy(s => s.GetRecursiveChildren(i => i is Season).Select(season => season.IndexNumber).Min()).First();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
@ -292,7 +295,7 @@ namespace MediaBrowser.Providers.TV
 | 
			
		||||
            bool allowMissingEpisodes)
 | 
			
		||||
        {
 | 
			
		||||
            var existingEpisodes = (from s in series
 | 
			
		||||
                                    from c in s.GetRecursiveChildren().OfType<Episode>()
 | 
			
		||||
                                    from c in s.GetRecursiveChildren(i => i is Episode).Cast<Episode>()
 | 
			
		||||
                                    select new { Episode = c })
 | 
			
		||||
                                   .ToList();
 | 
			
		||||
 | 
			
		||||
@ -402,7 +405,7 @@ namespace MediaBrowser.Providers.TV
 | 
			
		||||
 | 
			
		||||
                    // Season does not have a number
 | 
			
		||||
                    // Remove if there are no episodes directly in series without a season number
 | 
			
		||||
                    return i.Series.GetRecursiveChildren().OfType<Episode>().All(s => s.ParentIndexNumber.HasValue || s.IsInSeasonFolder);
 | 
			
		||||
                    return i.Series.GetRecursiveChildren(e => e is Episode).Cast<Episode>().All(s => s.ParentIndexNumber.HasValue || s.IsInSeasonFolder);
 | 
			
		||||
                })
 | 
			
		||||
                .ToList();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -257,10 +257,15 @@ namespace MediaBrowser.Server.Mono
 | 
			
		||||
            new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager, FileSystem, new ConsoleLogger()).Log(exception);
 | 
			
		||||
 | 
			
		||||
            if (!Debugger.IsAttached)
 | 
			
		||||
            {
 | 
			
		||||
                var message = LogHelper.GetLogMessage(exception).ToString();
 | 
			
		||||
 | 
			
		||||
                if (message.IndexOf("InotifyWatcher", StringComparison.OrdinalIgnoreCase) == -1)
 | 
			
		||||
                {
 | 
			
		||||
                    Environment.Exit(System.Runtime.InteropServices.Marshal.GetHRForException(exception));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Shutdown()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
@ -11,6 +11,8 @@
 | 
			
		||||
    <add key="ReleaseProgramDataPath" value="ProgramData-Server" />
 | 
			
		||||
  </appSettings>
 | 
			
		||||
  <runtime>
 | 
			
		||||
    <legacyUnhandledExceptionPolicy enabled="1" />
 | 
			
		||||
    
 | 
			
		||||
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
 | 
			
		||||
      <dependentAssembly>
 | 
			
		||||
        <assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" />
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,3 @@
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
 | 
			
		||||
[assembly: AssemblyVersion("3.2.13.4")]
 | 
			
		||||
[assembly: AssemblyVersion("3.2.13.5")]
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user