mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-03 19:17:24 -05:00 
			
		
		
		
	fixed subtitle downloading
This commit is contained in:
		
							parent
							
								
									0b7e398772
								
							
						
					
					
						commit
						374dd8d441
					
				@ -11,6 +11,7 @@ namespace MediaBrowser.Controller.Providers
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        List<FileSystemInfo> GetFileSystemEntries(string path);
 | 
					        List<FileSystemInfo> GetFileSystemEntries(string path);
 | 
				
			||||||
        IEnumerable<FileSystemInfo> GetFiles(string path);
 | 
					        IEnumerable<FileSystemInfo> GetFiles(string path);
 | 
				
			||||||
 | 
					        IEnumerable<FileSystemInfo> GetFiles(string path, bool clearCache);
 | 
				
			||||||
        FileSystemInfo GetFile(string path);
 | 
					        FileSystemInfo GetFile(string path);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -26,9 +27,21 @@ namespace MediaBrowser.Controller.Providers
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public List<FileSystemInfo> GetFileSystemEntries(string path)
 | 
					        public List<FileSystemInfo> GetFileSystemEntries(string path)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return GetFileSystemEntries(path, false);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<FileSystemInfo> GetFileSystemEntries(string path, bool clearCache)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            List<FileSystemInfo> entries;
 | 
					            List<FileSystemInfo> entries;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (clearCache)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                List<FileSystemInfo> removed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                _cache.TryRemove(path, out removed);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!_cache.TryGetValue(path, out entries))
 | 
					            if (!_cache.TryGetValue(path, out entries))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                //_logger.Debug("Getting files for " + path);
 | 
					                //_logger.Debug("Getting files for " + path);
 | 
				
			||||||
@ -50,7 +63,12 @@ namespace MediaBrowser.Controller.Providers
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        public IEnumerable<FileSystemInfo> GetFiles(string path)
 | 
					        public IEnumerable<FileSystemInfo> GetFiles(string path)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            return GetFileSystemEntries(path).Where(i => (i.Attributes & FileAttributes.Directory) != FileAttributes.Directory);
 | 
					            return GetFiles(path, false);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public IEnumerable<FileSystemInfo> GetFiles(string path, bool clearCache)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return GetFileSystemEntries(path, clearCache).Where(i => (i.Attributes & FileAttributes.Directory) != FileAttributes.Directory);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public FileSystemInfo GetFile(string path)
 | 
					        public FileSystemInfo GetFile(string path)
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
using System;
 | 
					using MediaBrowser.Model.Dto;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Diagnostics;
 | 
					using System.Diagnostics;
 | 
				
			||||||
using System.Runtime.Serialization;
 | 
					using System.Runtime.Serialization;
 | 
				
			||||||
@ -137,6 +138,24 @@ namespace MediaBrowser.Model.Entities
 | 
				
			|||||||
        /// <value>The artists.</value>
 | 
					        /// <value>The artists.</value>
 | 
				
			||||||
        public List<string> Artists { get; set; }
 | 
					        public List<string> Artists { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Gets or sets the media streams.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <value>The media streams.</value>
 | 
				
			||||||
 | 
					        public List<MediaStream> MediaStreams { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Gets or sets the chapter images item identifier.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <value>The chapter images item identifier.</value>
 | 
				
			||||||
 | 
					        public string ChapterImagesItemId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Gets or sets the chapters.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <value>The chapters.</value>
 | 
				
			||||||
 | 
					        public List<ChapterInfoDto> Chapters { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Gets a value indicating whether this instance has primary image.
 | 
					        /// Gets a value indicating whether this instance has primary image.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
@ -150,6 +169,8 @@ namespace MediaBrowser.Model.Entities
 | 
				
			|||||||
        public BaseItemInfo()
 | 
					        public BaseItemInfo()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Artists = new List<string>();
 | 
					            Artists = new List<string>();
 | 
				
			||||||
 | 
					            MediaStreams = new List<MediaStream>();
 | 
				
			||||||
 | 
					            Chapters = new List<ChapterInfoDto>();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -173,7 +173,7 @@ namespace MediaBrowser.Providers.MediaInfo
 | 
				
			|||||||
                {
 | 
					                {
 | 
				
			||||||
                    var prober = new FFProbeVideoInfo(_logger, _isoManager, _mediaEncoder, _itemRepo, _blurayExaminer, _localization, _appPaths, _json, _encodingManager, _fileSystem, _config, _subtitleManager);
 | 
					                    var prober = new FFProbeVideoInfo(_logger, _isoManager, _mediaEncoder, _itemRepo, _blurayExaminer, _localization, _appPaths, _json, _encodingManager, _fileSystem, _config, _subtitleManager);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    return !video.SubtitleFiles.SequenceEqual(prober.GetSubtitleFiles(video, directoryService).Select(i => i.FullName).OrderBy(i => i), StringComparer.OrdinalIgnoreCase);
 | 
					                    return !video.SubtitleFiles.SequenceEqual(prober.GetSubtitleFiles(video, directoryService, false).Select(i => i.FullName).OrderBy(i => i), StringComparer.OrdinalIgnoreCase);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -417,7 +417,7 @@ namespace MediaBrowser.Providers.MediaInfo
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public IEnumerable<FileSystemInfo> GetSubtitleFiles(Video video, IDirectoryService directoryService)
 | 
					        public IEnumerable<FileSystemInfo> GetSubtitleFiles(Video video, IDirectoryService directoryService, bool clearCache)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var containingPath = video.ContainingFolderPath;
 | 
					            var containingPath = video.ContainingFolderPath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -426,7 +426,7 @@ namespace MediaBrowser.Providers.MediaInfo
 | 
				
			|||||||
                throw new ArgumentException(string.Format("Cannot search for items that don't have a path: {0} {1}", video.Name, video.Id));
 | 
					                throw new ArgumentException(string.Format("Cannot search for items that don't have a path: {0} {1}", video.Name, video.Id));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var files = directoryService.GetFiles(containingPath);
 | 
					            var files = directoryService.GetFiles(containingPath, clearCache);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var videoFileNameWithoutExtension = Path.GetFileNameWithoutExtension(video.Path);
 | 
					            var videoFileNameWithoutExtension = Path.GetFileNameWithoutExtension(video.Path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -460,7 +460,7 @@ namespace MediaBrowser.Providers.MediaInfo
 | 
				
			|||||||
        /// <param name="currentStreams">The current streams.</param>
 | 
					        /// <param name="currentStreams">The current streams.</param>
 | 
				
			||||||
        private async Task AddExternalSubtitles(Video video, List<MediaStream> currentStreams, IDirectoryService directoryService, CancellationToken cancellationToken)
 | 
					        private async Task AddExternalSubtitles(Video video, List<MediaStream> currentStreams, IDirectoryService directoryService, CancellationToken cancellationToken)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var externalSubtitleStreams = GetExternalSubtitleStreams(video, currentStreams.Count, directoryService).ToList();
 | 
					            var externalSubtitleStreams = GetExternalSubtitleStreams(video, currentStreams.Count, directoryService, false).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ((_config.Configuration.SubtitleOptions.DownloadEpisodeSubtitles &&
 | 
					            if ((_config.Configuration.SubtitleOptions.DownloadEpisodeSubtitles &&
 | 
				
			||||||
                video is Episode) ||
 | 
					                video is Episode) ||
 | 
				
			||||||
@ -480,7 +480,7 @@ namespace MediaBrowser.Providers.MediaInfo
 | 
				
			|||||||
                // Rescan
 | 
					                // Rescan
 | 
				
			||||||
                if (downloadedLanguages.Count > 0)
 | 
					                if (downloadedLanguages.Count > 0)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    externalSubtitleStreams = GetExternalSubtitleStreams(video, currentStreams.Count, directoryService).ToList();
 | 
					                    externalSubtitleStreams = GetExternalSubtitleStreams(video, currentStreams.Count, directoryService, true).ToList();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -491,9 +491,10 @@ namespace MediaBrowser.Providers.MediaInfo
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private IEnumerable<MediaStream> GetExternalSubtitleStreams(Video video, 
 | 
					        private IEnumerable<MediaStream> GetExternalSubtitleStreams(Video video, 
 | 
				
			||||||
            int startIndex, 
 | 
					            int startIndex, 
 | 
				
			||||||
            IDirectoryService directoryService)
 | 
					            IDirectoryService directoryService,
 | 
				
			||||||
 | 
					            bool clearCache)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var files = GetSubtitleFiles(video, directoryService);
 | 
					            var files = GetSubtitleFiles(video, directoryService, clearCache);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var streams = new List<MediaStream>();
 | 
					            var streams = new List<MediaStream>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -91,9 +91,9 @@ namespace MediaBrowser.Providers.MediaInfo
 | 
				
			|||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // There's already an audio stream for this language
 | 
					            // There's already a default audio stream for this language
 | 
				
			||||||
            if (skipIfAudioTrackMatches &&
 | 
					            if (skipIfAudioTrackMatches &&
 | 
				
			||||||
                internalMediaStreams.Any(i => i.Type == MediaStreamType.Audio && string.Equals(i.Language, language, StringComparison.OrdinalIgnoreCase)))
 | 
					                internalMediaStreams.Any(i => i.Type == MediaStreamType.Audio && i.IsDefault && string.Equals(i.Language, language, StringComparison.OrdinalIgnoreCase)))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
				
			|||||||
@ -120,7 +120,13 @@ namespace MediaBrowser.Providers.Subtitles
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if (results.Count == 0)
 | 
					            if (results.Count == 0)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                throw new ResourceNotFoundException("Subtitle with Id " + ossId + " was not found.");
 | 
					                var msg = string.Format("Subtitle with Id {0} was not found. Name: {1}. Status: {2}. Message: {3}",
 | 
				
			||||||
 | 
					                    ossId,
 | 
				
			||||||
 | 
					                    resultDownLoad.Name ?? string.Empty,
 | 
				
			||||||
 | 
					                    resultDownLoad.Message ?? string.Empty,
 | 
				
			||||||
 | 
					                    resultDownLoad.Status ?? string.Empty);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                throw new ResourceNotFoundException(msg);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var data = Convert.FromBase64String(results.First().Data);
 | 
					            var data = Convert.FromBase64String(results.First().Data);
 | 
				
			||||||
@ -245,7 +251,7 @@ namespace MediaBrowser.Providers.Subtitles
 | 
				
			|||||||
                        ProviderName = Name,
 | 
					                        ProviderName = Name,
 | 
				
			||||||
                        Language = i.SubLanguageID,
 | 
					                        Language = i.SubLanguageID,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        Id = i.SubFormat + "-" + i.SubLanguageID + "-" + i.IDSubtitle,
 | 
					                        Id = i.SubFormat + "-" + i.SubLanguageID + "-" + i.IDSubtitleFile,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        Name = i.SubFileName,
 | 
					                        Name = i.SubFileName,
 | 
				
			||||||
                        DateCreated = DateTime.Parse(i.SubAddDate, _usCulture),
 | 
					                        DateCreated = DateTime.Parse(i.SubAddDate, _usCulture),
 | 
				
			||||||
 | 
				
			|||||||
@ -14,12 +14,12 @@ using MediaBrowser.Model.Entities;
 | 
				
			|||||||
using MediaBrowser.Model.Logging;
 | 
					using MediaBrowser.Model.Logging;
 | 
				
			||||||
using MediaBrowser.Model.Notifications;
 | 
					using MediaBrowser.Model.Notifications;
 | 
				
			||||||
using MediaBrowser.Model.Tasks;
 | 
					using MediaBrowser.Model.Tasks;
 | 
				
			||||||
 | 
					using MediaBrowser.Model.Updates;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
using System.Threading;
 | 
					using System.Threading;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using MediaBrowser.Model.Updates;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
 | 
					namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -40,6 +40,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
 | 
				
			|||||||
        private readonly ISessionManager _sessionManager;
 | 
					        private readonly ISessionManager _sessionManager;
 | 
				
			||||||
        private readonly IServerApplicationHost _appHost;
 | 
					        private readonly IServerApplicationHost _appHost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private Timer LibraryUpdateTimer { get; set; }
 | 
				
			||||||
 | 
					        private readonly object _libraryChangedSyncLock = new object();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public Notifications(IInstallationManager installationManager, IUserManager userManager, ILogger logger, ITaskManager taskManager, INotificationManager notificationManager, IServerConfigurationManager config, ILibraryManager libraryManager, ISessionManager sessionManager, IServerApplicationHost appHost)
 | 
					        public Notifications(IInstallationManager installationManager, IUserManager userManager, ILogger logger, ITaskManager taskManager, INotificationManager notificationManager, IServerConfigurationManager config, ILibraryManager libraryManager, ISessionManager sessionManager, IServerApplicationHost appHost)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _installationManager = installationManager;
 | 
					            _installationManager = installationManager;
 | 
				
			||||||
@ -210,21 +213,55 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
 | 
				
			|||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        async void _libraryManager_ItemAdded(object sender, ItemChangeEventArgs e)
 | 
					        private readonly List<BaseItem> _itemsAdded = new List<BaseItem>();
 | 
				
			||||||
 | 
					        void _libraryManager_ItemAdded(object sender, ItemChangeEventArgs e)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (e.Item.LocationType == LocationType.FileSystem)
 | 
					            if (e.Item.LocationType == LocationType.FileSystem && !e.Item.IsFolder)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var type = NotificationType.NewLibraryContent.ToString();
 | 
					                lock (_libraryChangedSyncLock)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (LibraryUpdateTimer == null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, 5000,
 | 
				
			||||||
 | 
					                                                       Timeout.Infinite);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        LibraryUpdateTimer.Change(5000, Timeout.Infinite);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var item = e.Item;
 | 
					                    _itemsAdded.Add(e.Item);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private async void LibraryUpdateTimerCallback(object state)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            List<BaseItem> items;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            lock (_libraryChangedSyncLock)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                items = _itemsAdded.ToList();
 | 
				
			||||||
 | 
					                _itemsAdded.Clear();
 | 
				
			||||||
 | 
					                DisposeLibraryUpdateTimer();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item = items.FirstOrDefault();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (item != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
                var notification = new NotificationRequest
 | 
					                var notification = new NotificationRequest
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    NotificationType = type
 | 
					                    NotificationType = NotificationType.NewLibraryContent.ToString()
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                notification.Variables["Name"] = item.Name;
 | 
					                notification.Variables["Name"] = item.Name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (items.Count > 1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    notification.Name = items.Count + " new library items.";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                await SendNotification(notification).ConfigureAwait(false);
 | 
					                await SendNotification(notification).ConfigureAwait(false);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -313,6 +350,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        public void Dispose()
 | 
					        public void Dispose()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            DisposeLibraryUpdateTimer();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            _installationManager.PluginInstalled -= _installationManager_PluginInstalled;
 | 
					            _installationManager.PluginInstalled -= _installationManager_PluginInstalled;
 | 
				
			||||||
            _installationManager.PluginUpdated -= _installationManager_PluginUpdated;
 | 
					            _installationManager.PluginUpdated -= _installationManager_PluginUpdated;
 | 
				
			||||||
            _installationManager.PackageInstallationFailed -= _installationManager_PackageInstallationFailed;
 | 
					            _installationManager.PackageInstallationFailed -= _installationManager_PackageInstallationFailed;
 | 
				
			||||||
@ -328,5 +367,14 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
 | 
				
			|||||||
            _appHost.HasUpdateAvailableChanged -= _appHost_HasUpdateAvailableChanged;
 | 
					            _appHost.HasUpdateAvailableChanged -= _appHost_HasUpdateAvailableChanged;
 | 
				
			||||||
            _appHost.ApplicationUpdated -= _appHost_ApplicationUpdated;
 | 
					            _appHost.ApplicationUpdated -= _appHost_ApplicationUpdated;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void DisposeLibraryUpdateTimer()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (LibraryUpdateTimer != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                LibraryUpdateTimer.Dispose();
 | 
				
			||||||
 | 
					                LibraryUpdateTimer = null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -715,6 +715,6 @@
 | 
				
			|||||||
	"LabelAudioLanguagePreferenceHelp": "If empty, the default audio track will be selected, regardless of language.",
 | 
						"LabelAudioLanguagePreferenceHelp": "If empty, the default audio track will be selected, regardless of language.",
 | 
				
			||||||
	"LabelDownloadLanguages": "Download languages:",
 | 
						"LabelDownloadLanguages": "Download languages:",
 | 
				
			||||||
	"ButtonRegister": "Register",
 | 
						"ButtonRegister": "Register",
 | 
				
			||||||
	"LabelSkipIfAudioTrackPresent": "Skip if the video has an audio track with the download language",
 | 
						"LabelSkipIfAudioTrackPresent": "Skip if the default audio track matches the download language",
 | 
				
			||||||
	"LabelSkipIfAudioTrackPresentHelp": "Uncheck this to ensure all videos have subtitles, regardless of audio language."
 | 
						"LabelSkipIfAudioTrackPresentHelp": "Uncheck this to ensure all videos have subtitles, regardless of audio language."
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -48,6 +48,7 @@ namespace MediaBrowser.Server.Implementations.Session
 | 
				
			|||||||
        private readonly IMusicManager _musicManager;
 | 
					        private readonly IMusicManager _musicManager;
 | 
				
			||||||
        private readonly IDtoService _dtoService;
 | 
					        private readonly IDtoService _dtoService;
 | 
				
			||||||
        private readonly IImageProcessor _imageProcessor;
 | 
					        private readonly IImageProcessor _imageProcessor;
 | 
				
			||||||
 | 
					        private readonly IItemRepository _itemRepo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Gets or sets the configuration manager.
 | 
					        /// Gets or sets the configuration manager.
 | 
				
			||||||
@ -90,7 +91,7 @@ namespace MediaBrowser.Server.Implementations.Session
 | 
				
			|||||||
        /// <param name="logger">The logger.</param>
 | 
					        /// <param name="logger">The logger.</param>
 | 
				
			||||||
        /// <param name="userRepository">The user repository.</param>
 | 
					        /// <param name="userRepository">The user repository.</param>
 | 
				
			||||||
        /// <param name="libraryManager">The library manager.</param>
 | 
					        /// <param name="libraryManager">The library manager.</param>
 | 
				
			||||||
        public SessionManager(IUserDataManager userDataRepository, IServerConfigurationManager configurationManager, ILogger logger, IUserRepository userRepository, ILibraryManager libraryManager, IUserManager userManager, IMusicManager musicManager, IDtoService dtoService, IImageProcessor imageProcessor)
 | 
					        public SessionManager(IUserDataManager userDataRepository, IServerConfigurationManager configurationManager, ILogger logger, IUserRepository userRepository, ILibraryManager libraryManager, IUserManager userManager, IMusicManager musicManager, IDtoService dtoService, IImageProcessor imageProcessor, IItemRepository itemRepo)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _userDataRepository = userDataRepository;
 | 
					            _userDataRepository = userDataRepository;
 | 
				
			||||||
            _configurationManager = configurationManager;
 | 
					            _configurationManager = configurationManager;
 | 
				
			||||||
@ -101,6 +102,7 @@ namespace MediaBrowser.Server.Implementations.Session
 | 
				
			|||||||
            _musicManager = musicManager;
 | 
					            _musicManager = musicManager;
 | 
				
			||||||
            _dtoService = dtoService;
 | 
					            _dtoService = dtoService;
 | 
				
			||||||
            _imageProcessor = imageProcessor;
 | 
					            _imageProcessor = imageProcessor;
 | 
				
			||||||
 | 
					            _itemRepo = itemRepo;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
@ -279,7 +281,7 @@ namespace MediaBrowser.Server.Implementations.Session
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if (!string.IsNullOrWhiteSpace(info.ItemId) && libraryItem != null)
 | 
					            if (!string.IsNullOrWhiteSpace(info.ItemId) && libraryItem != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                info.Item = GetItemInfo(libraryItem, runtimeTicks);
 | 
					                info.Item = GetItemInfo(libraryItem, runtimeTicks, libraryItem, info.MediaSourceId);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            session.NowPlayingItem = info.Item;
 | 
					            session.NowPlayingItem = info.Item;
 | 
				
			||||||
@ -1172,9 +1174,11 @@ namespace MediaBrowser.Server.Implementations.Session
 | 
				
			|||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        /// <param name="item">The item.</param>
 | 
					        /// <param name="item">The item.</param>
 | 
				
			||||||
        /// <param name="runtimeTicks">The now playing runtime ticks.</param>
 | 
					        /// <param name="runtimeTicks">The now playing runtime ticks.</param>
 | 
				
			||||||
 | 
					        /// <param name="chapterOwner">The chapter owner.</param>
 | 
				
			||||||
 | 
					        /// <param name="mediaSourceId">The media source identifier.</param>
 | 
				
			||||||
        /// <returns>BaseItemInfo.</returns>
 | 
					        /// <returns>BaseItemInfo.</returns>
 | 
				
			||||||
        /// <exception cref="System.ArgumentNullException">item</exception>
 | 
					        /// <exception cref="System.ArgumentNullException">item</exception>
 | 
				
			||||||
        private BaseItemInfo GetItemInfo(BaseItem item, long? runtimeTicks)
 | 
					        private BaseItemInfo GetItemInfo(BaseItem item, long? runtimeTicks, BaseItem chapterOwner, string mediaSourceId)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (item == null)
 | 
					            if (item == null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@ -1322,6 +1326,22 @@ namespace MediaBrowser.Server.Implementations.Session
 | 
				
			|||||||
                info.LogoItemId = GetDtoId(logoItem);
 | 
					                info.LogoItemId = GetDtoId(logoItem);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (chapterOwner != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                info.ChapterImagesItemId = chapterOwner.Id.ToString("N");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                info.Chapters = _itemRepo.GetChapters(chapterOwner.Id).Select(i => _dtoService.GetChapterInfoDto(i, chapterOwner)).ToList();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!string.IsNullOrWhiteSpace(mediaSourceId))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                info.MediaStreams = _itemRepo.GetMediaStreams(new MediaStreamQuery
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ItemId = new Guid(mediaSourceId)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }).ToList();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return info;
 | 
					            return info;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1347,7 +1367,7 @@ namespace MediaBrowser.Server.Implementations.Session
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            var item = _libraryManager.GetItemById(new Guid(itemId));
 | 
					            var item = _libraryManager.GetItemById(new Guid(itemId));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var info = GetItemInfo(item, item.RunTimeTicks);
 | 
					            var info = GetItemInfo(item, item.RunTimeTicks, null, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ReportNowViewingItem(sessionId, info);
 | 
					            ReportNowViewingItem(sessionId, info);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -496,7 +496,7 @@ namespace MediaBrowser.ServerApplication
 | 
				
			|||||||
            DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager);
 | 
					            DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager);
 | 
				
			||||||
            RegisterSingleInstance(DtoService);
 | 
					            RegisterSingleInstance(DtoService);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            SessionManager = new SessionManager(UserDataManager, ServerConfigurationManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor);
 | 
					            SessionManager = new SessionManager(UserDataManager, ServerConfigurationManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, ItemRepository);
 | 
				
			||||||
            RegisterSingleInstance(SessionManager);
 | 
					            RegisterSingleInstance(SessionManager);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var newsService = new Server.Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
 | 
					            var newsService = new Server.Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user