mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-10-31 10:37:22 -04:00 
			
		
		
		
	improve merge/split video feature
This commit is contained in:
		
							parent
							
								
									b5ab7776f1
								
							
						
					
					
						commit
						ceee0cdcca
					
				| @ -114,12 +114,14 @@ namespace MediaBrowser.Api | |||||||
| 
 | 
 | ||||||
|             foreach (var link in video.GetLinkedAlternateVersions()) |             foreach (var link in video.GetLinkedAlternateVersions()) | ||||||
|             { |             { | ||||||
|                 link.PrimaryVersionId = null; |                 link.SetPrimaryVersionId(null); | ||||||
|  |                 link.LinkedAlternateVersions = Video.EmptyLinkedChildArray; | ||||||
| 
 | 
 | ||||||
|                 link.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None); |                 link.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             video.LinkedAlternateVersions = Video.EmptyLinkedChildArray; |             video.LinkedAlternateVersions = Video.EmptyLinkedChildArray; | ||||||
|  |             video.SetPrimaryVersionId(null); | ||||||
|             video.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None); |             video.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -174,7 +176,7 @@ namespace MediaBrowser.Api | |||||||
| 
 | 
 | ||||||
|             foreach (var item in items.Where(i => i.Id != primaryVersion.Id)) |             foreach (var item in items.Where(i => i.Id != primaryVersion.Id)) | ||||||
|             { |             { | ||||||
|                 item.PrimaryVersionId = primaryVersion.Id.ToString("N"); |                 item.SetPrimaryVersionId(primaryVersion.Id.ToString("N")); | ||||||
| 
 | 
 | ||||||
|                 item.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None); |                 item.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -84,6 +84,20 @@ namespace MediaBrowser.Controller.Entities | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         public void SetPrimaryVersionId(string id) | ||||||
|  |         { | ||||||
|  |             if (string.IsNullOrWhiteSpace(id)) | ||||||
|  |             { | ||||||
|  |                 PrimaryVersionId = null; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 PrimaryVersionId = id; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             PresentationUniqueKey = CreatePresentationUniqueKey(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         public override string CreatePresentationUniqueKey() |         public override string CreatePresentationUniqueKey() | ||||||
|         { |         { | ||||||
|             if (!string.IsNullOrWhiteSpace(PrimaryVersionId)) |             if (!string.IsNullOrWhiteSpace(PrimaryVersionId)) | ||||||
| @ -667,8 +681,6 @@ namespace MediaBrowser.Controller.Entities | |||||||
|                 throw new ArgumentNullException("media"); |                 throw new ArgumentNullException("media"); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             var mediaStreams = MediaSourceManager.GetMediaStreams(media.Id); |  | ||||||
| 
 |  | ||||||
|             var locationType = media.LocationType; |             var locationType = media.LocationType; | ||||||
| 
 | 
 | ||||||
|             var info = new MediaSourceInfo |             var info = new MediaSourceInfo | ||||||
| @ -676,8 +688,8 @@ namespace MediaBrowser.Controller.Entities | |||||||
|                 Id = media.Id.ToString("N"), |                 Id = media.Id.ToString("N"), | ||||||
|                 IsoType = media.IsoType, |                 IsoType = media.IsoType, | ||||||
|                 Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File, |                 Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File, | ||||||
|                 MediaStreams = mediaStreams, |                 MediaStreams = MediaSourceManager.GetMediaStreams(media.Id), | ||||||
|                 Name = GetMediaSourceName(media, mediaStreams), |                 Name = GetMediaSourceName(media), | ||||||
|                 Path = enablePathSubstitution ? GetMappedPath(media, media.Path, locationType) : media.Path, |                 Path = enablePathSubstitution ? GetMappedPath(media, media.Path, locationType) : media.Path, | ||||||
|                 RunTimeTicks = media.RunTimeTicks, |                 RunTimeTicks = media.RunTimeTicks, | ||||||
|                 Video3DFormat = media.Video3DFormat, |                 Video3DFormat = media.Video3DFormat, | ||||||
| @ -740,12 +752,20 @@ namespace MediaBrowser.Controller.Entities | |||||||
|             return info; |             return info; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         private static string GetMediaSourceName(Video video, List<MediaStream> mediaStreams) |         private static string GetMediaSourceName(Video video) | ||||||
|         { |         { | ||||||
|             var terms = new List<string>(); |             var terms = new List<string>(); | ||||||
| 
 | 
 | ||||||
|             var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video); |             var locationType = video.LocationType; | ||||||
|             var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio); |             var path = video.Path; | ||||||
|  |             if ((locationType == LocationType.FileSystem || locationType == LocationType.Offline) && !string.IsNullOrWhiteSpace(path)) | ||||||
|  |             { | ||||||
|  |                 terms.Add(System.IO.Path.GetFileName(path)); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 terms.Add(video.Name); | ||||||
|  |             } | ||||||
| 
 | 
 | ||||||
|             if (video.Video3DFormat.HasValue) |             if (video.Video3DFormat.HasValue) | ||||||
|             { |             { | ||||||
| @ -779,50 +799,6 @@ namespace MediaBrowser.Controller.Entities | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if (videoStream != null) |  | ||||||
|             { |  | ||||||
|                 if (videoStream.Width.HasValue) |  | ||||||
|                 { |  | ||||||
|                     if (videoStream.Width.Value >= 3800) |  | ||||||
|                     { |  | ||||||
|                         terms.Add("4K"); |  | ||||||
|                     } |  | ||||||
|                     else if (videoStream.Width.Value >= 1900) |  | ||||||
|                     { |  | ||||||
|                         terms.Add("1080P"); |  | ||||||
|                     } |  | ||||||
|                     else if (videoStream.Width.Value >= 1270) |  | ||||||
|                     { |  | ||||||
|                         terms.Add("720P"); |  | ||||||
|                     } |  | ||||||
|                     else if (videoStream.Width.Value >= 700) |  | ||||||
|                     { |  | ||||||
|                         terms.Add("480P"); |  | ||||||
|                     } |  | ||||||
|                     else |  | ||||||
|                     { |  | ||||||
|                         terms.Add("SD"); |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             if (videoStream != null && !string.IsNullOrWhiteSpace(videoStream.Codec)) |  | ||||||
|             { |  | ||||||
|                 terms.Add(videoStream.Codec.ToUpper()); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             if (audioStream != null) |  | ||||||
|             { |  | ||||||
|                 var audioCodec = string.Equals(audioStream.Codec, "dca", StringComparison.OrdinalIgnoreCase) |  | ||||||
|                     ? audioStream.Profile |  | ||||||
|                     : audioStream.Codec; |  | ||||||
| 
 |  | ||||||
|                 if (!string.IsNullOrEmpty(audioCodec)) |  | ||||||
|                 { |  | ||||||
|                     terms.Add(audioCodec.ToUpper()); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             return string.Join("/", terms.ToArray(terms.Count)); |             return string.Join("/", terms.ToArray(terms.Count)); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user