mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-04 03:27:21 -05:00 
			
		
		
		
	add error handling
This commit is contained in:
		
							parent
							
								
									bf07a47132
								
							
						
					
					
						commit
						af4473e27f
					
				@ -720,12 +720,12 @@ namespace MediaBrowser.Api.Playback
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            state.IsInputVideo = string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase);
 | 
					            state.IsInputVideo = string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var primaryImage = item.GetImageInfo(ImageType.Primary, 0) ??
 | 
					            //var primaryImage = item.GetImageInfo(ImageType.Primary, 0) ??
 | 
				
			||||||
                         item.Parents.Select(i => i.GetImageInfo(ImageType.Primary, 0)).FirstOrDefault(i => i != null);
 | 
					            //             item.Parents.Select(i => i.GetImageInfo(ImageType.Primary, 0)).FirstOrDefault(i => i != null);
 | 
				
			||||||
            if (primaryImage != null)
 | 
					            //if (primaryImage != null)
 | 
				
			||||||
            {
 | 
					            //{
 | 
				
			||||||
                state.AlbumCoverPath = primaryImage.Path;
 | 
					            //    state.AlbumCoverPath = primaryImage.Path;
 | 
				
			||||||
            }
 | 
					            //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            MediaSourceInfo mediaSource = null;
 | 
					            MediaSourceInfo mediaSource = null;
 | 
				
			||||||
            if (string.IsNullOrWhiteSpace(request.LiveStreamId))
 | 
					            if (string.IsNullOrWhiteSpace(request.LiveStreamId))
 | 
				
			||||||
 | 
				
			|||||||
@ -591,41 +591,46 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
            .ToList();
 | 
					            .ToList();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private static MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, Video i, MediaSourceType type)
 | 
					        private static MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, Video media, MediaSourceType type)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var mediaStreams = MediaSourceManager.GetMediaStreams(i.Id)
 | 
					            if (media == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                throw new ArgumentNullException("media");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var mediaStreams = MediaSourceManager.GetMediaStreams(media.Id)
 | 
				
			||||||
                .ToList();
 | 
					                .ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var locationType = i.LocationType;
 | 
					            var locationType = media.LocationType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var info = new MediaSourceInfo
 | 
					            var info = new MediaSourceInfo
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Id = i.Id.ToString("N"),
 | 
					                Id = media.Id.ToString("N"),
 | 
				
			||||||
                IsoType = i.IsoType,
 | 
					                IsoType = media.IsoType,
 | 
				
			||||||
                Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File,
 | 
					                Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File,
 | 
				
			||||||
                MediaStreams = mediaStreams,
 | 
					                MediaStreams = mediaStreams,
 | 
				
			||||||
                Name = GetMediaSourceName(i, mediaStreams),
 | 
					                Name = GetMediaSourceName(media, mediaStreams),
 | 
				
			||||||
                Path = enablePathSubstitution ? GetMappedPath(i, i.Path, locationType) : i.Path,
 | 
					                Path = enablePathSubstitution ? GetMappedPath(media, media.Path, locationType) : media.Path,
 | 
				
			||||||
                RunTimeTicks = i.RunTimeTicks,
 | 
					                RunTimeTicks = media.RunTimeTicks,
 | 
				
			||||||
                Video3DFormat = i.Video3DFormat,
 | 
					                Video3DFormat = media.Video3DFormat,
 | 
				
			||||||
                VideoType = i.VideoType,
 | 
					                VideoType = media.VideoType,
 | 
				
			||||||
                Container = i.Container,
 | 
					                Container = media.Container,
 | 
				
			||||||
                Size = i.Size,
 | 
					                Size = media.Size,
 | 
				
			||||||
                Timestamp = i.Timestamp,
 | 
					                Timestamp = media.Timestamp,
 | 
				
			||||||
                Type = type,
 | 
					                Type = type,
 | 
				
			||||||
                PlayableStreamFileNames = i.PlayableStreamFileNames.ToList(),
 | 
					                PlayableStreamFileNames = media.PlayableStreamFileNames.ToList(),
 | 
				
			||||||
                SupportsDirectStream = i.VideoType == VideoType.VideoFile,
 | 
					                SupportsDirectStream = media.VideoType == VideoType.VideoFile,
 | 
				
			||||||
                IsRemote = i.IsShortcut
 | 
					                IsRemote = media.IsShortcut
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (info.Protocol == MediaProtocol.File)
 | 
					            if (info.Protocol == MediaProtocol.File)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                info.ETag = i.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N");
 | 
					                info.ETag = media.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (i.IsShortcut)
 | 
					            if (media.IsShortcut)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                info.Path = i.ShortcutPath;
 | 
					                info.Path = media.ShortcutPath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (info.Path.StartsWith("Http", StringComparison.OrdinalIgnoreCase))
 | 
					                if (info.Path.StartsWith("Http", StringComparison.OrdinalIgnoreCase))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
@ -647,16 +652,16 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if (string.IsNullOrEmpty(info.Container))
 | 
					            if (string.IsNullOrEmpty(info.Container))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (i.VideoType == VideoType.VideoFile || i.VideoType == VideoType.Iso)
 | 
					                if (media.VideoType == VideoType.VideoFile || media.VideoType == VideoType.Iso)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (!string.IsNullOrWhiteSpace(i.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual)
 | 
					                    if (!string.IsNullOrWhiteSpace(media.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        info.Container = System.IO.Path.GetExtension(i.Path).TrimStart('.');
 | 
					                        info.Container = System.IO.Path.GetExtension(media.Path).TrimStart('.');
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            info.Bitrate = i.TotalBitrate;
 | 
					            info.Bitrate = media.TotalBitrate;
 | 
				
			||||||
            info.InferTotalBitrate();
 | 
					            info.InferTotalBitrate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return info;
 | 
					            return info;
 | 
				
			||||||
 | 
				
			|||||||
@ -2011,12 +2011,11 @@ namespace MediaBrowser.Controller.MediaEncoding
 | 
				
			|||||||
            var vn = string.Empty;
 | 
					            var vn = string.Empty;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var hasArt = !string.IsNullOrWhiteSpace(state.AlbumCoverPath);
 | 
					            var hasArt = !string.IsNullOrWhiteSpace(state.AlbumCoverPath);
 | 
				
			||||||
            hasArt = false;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (hasArt)
 | 
					            if (hasArt)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                albumCoverInput = " -i \"" + state.AlbumCoverPath + "\"";
 | 
					                albumCoverInput = " -i \"" + state.AlbumCoverPath + "\"";
 | 
				
			||||||
                mapArgs = " -map 0:a -map 1:v -c:v copy";
 | 
					                mapArgs = " -map 0:a -map 1:v -c:1:v copy";
 | 
				
			||||||
                metadata = " -metadata:s:v title=\"Album cover\" -metadata:s:v comment=\"Cover(Front)\"";
 | 
					                metadata = " -metadata:s:v title=\"Album cover\" -metadata:s:v comment=\"Cover(Front)\"";
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user