11using MediaBrowser . Controller . Entities ;
2- using MediaBrowser . Model . Entities ; // 包含 MediaStream, VideoRange 等定义
2+ using MediaBrowser . Model . Entities ;
33using System . Collections . Generic ;
44using System . Linq ;
55using System ;
@@ -15,7 +15,7 @@ public static List<string> GetMediaInfoTags(BaseItem item, SmartTagsConfig confi
1515 {
1616 var tags = new List < string > ( ) ;
1717
18- // 获取所有流信息 (Emby 已经刮削好的)
18+ // 获取所有流信息
1919 var streams = item . GetMediaStreams ( ) ;
2020 var videoStream = streams . FirstOrDefault ( s => s . Type == MediaStreamType . Video ) ;
2121 var audioStreams = streams . Where ( s => s . Type == MediaStreamType . Audio ) . ToList ( ) ;
@@ -27,41 +27,36 @@ public static List<string> GetMediaInfoTags(BaseItem item, SmartTagsConfig confi
2727 if ( width >= 3800 ) tags . Add ( "4K" ) ;
2828 else if ( width >= 1900 ) tags . Add ( "1080p" ) ;
2929 else if ( width >= 1200 ) tags . Add ( "720p" ) ;
30- // SD 画质一般不打标签,避免污染
3130 }
3231
3332 // 2. HDR / 杜比视界标签
3433 if ( config . EnableHdrTags && videoStream != null )
3534 {
36- // 检查 Dolby Vision
37- // Emby 的 VideoRange 字段可能包含 "DolbyVision" 或者 VideoRangeType 字段
38- // 这里采用宽松匹配,覆盖多数情况
3935 bool isDv = false ;
4036
41- // 检查 VideoRangeType (新版 Emby) 或 VideoRange (旧版/通用)
42- // 注意:不同版本的 Emby 字段可能略有不同,字符串匹配最稳妥
43- string range = videoStream . VideoRange ? . ToString ( ) ?? "" ;
44- string rangeType = videoStream . VideoRangeType ? . ToString ( ) ?? "" ;
45- string title = videoStream . DisplayTitle ?? "" ; // 有时文件名/标题里有
37+ // 修正点:VideoRange 是 string 类型,直接获取字符串。
38+ // 移除不存在的 VideoRangeType。
39+ string range = videoStream . VideoRange ?? "" ;
40+ string title = videoStream . DisplayTitle ?? "" ;
4641
47- if ( range . Contains ( "Dolby" , StringComparison . OrdinalIgnoreCase ) ||
48- rangeType . Contains ( "Dolby" , StringComparison . OrdinalIgnoreCase ) ||
49- rangeType . Contains ( "DOVI" , StringComparison . OrdinalIgnoreCase ) )
42+ // 检查 Dolby Vision
43+ // 通过字符串匹配 "Dolby" 或 "DOVI"
44+ if ( range . IndexOf ( "Dolby" , StringComparison . OrdinalIgnoreCase ) >= 0 ||
45+ range . IndexOf ( "DOVI" , StringComparison . OrdinalIgnoreCase ) >= 0 ||
46+ title . IndexOf ( "Dolby Vision" , StringComparison . OrdinalIgnoreCase ) >= 0 )
5047 {
5148 tags . Add ( "Dolby Vision" ) ;
5249 isDv = true ;
5350 }
5451
55- // 检查 HDR (如果不是 DV,或者想同时标记)
56- // 通常 DV 也算 HDR,但用户可能只想要一个最强的。
57- // 策略:如果是 HDR 但不是 DV,标记 HDR。
58- if ( videoStream . VideoRange == VideoRange . HDR ||
59- range . Contains ( "HDR" , StringComparison . OrdinalIgnoreCase ) )
52+ // 检查 HDR
53+ // 修正点:不使用 VideoRange.HDR 枚举,而是检查字符串是否包含 HDR 关键词
54+ // 常见的 HDR 字符串值可能是 "HDR", "HDR10", "SMPTE ST 2086", "PQ", "HLG" 等
55+ if ( ! isDv )
6056 {
61- // 只有当没有标记 DV 时,才标记普通的 HDR (可选策略,或者共存)
62- // 这里我们选择共存策略:如果是 DV,它通常也是 HDR。
63- // 但为了标签简洁,如果有了 Dolby Vision,通常不需要再打 HDR 标签,除非是 HDR10+
64- if ( ! isDv )
57+ if ( range . IndexOf ( "HDR" , StringComparison . OrdinalIgnoreCase ) >= 0 ||
58+ range . IndexOf ( "PQ" , StringComparison . OrdinalIgnoreCase ) >= 0 ||
59+ range . IndexOf ( "HLG" , StringComparison . OrdinalIgnoreCase ) >= 0 )
6560 {
6661 tags . Add ( "HDR" ) ;
6762 }
@@ -76,10 +71,8 @@ public static List<string> GetMediaInfoTags(BaseItem item, SmartTagsConfig confi
7671 string profile = audio . Profile ? . ToLower ( ) ?? "" ;
7772 string codec = audio . Codec ? . ToLower ( ) ?? "" ;
7873 string title = audio . DisplayTitle ? . ToLower ( ) ?? "" ;
79- string layout = audio . ChannelLayout ? . ToLower ( ) ?? "" ; // 5.1, 7.1
8074
8175 // Atmos (全景声)
82- // 通常在 Title 或 Profile 中出现
8376 if ( title . Contains ( "atmos" ) || profile . Contains ( "atmos" ) )
8477 {
8578 if ( ! tags . Contains ( "Atmos" ) ) tags . Add ( "Atmos" ) ;
@@ -107,4 +100,4 @@ public static List<string> GetMediaInfoTags(BaseItem item, SmartTagsConfig confi
107100
108101 return tags ;
109102 }
110- }
103+ }
0 commit comments