Merge pull request #295 from Diazole/286-add-dash-role-scheme
Add support for the dash role scheme. #286
This commit is contained in:
commit
75b270b52d
|
@ -31,6 +31,9 @@ namespace N_m3u8DL_RE.Common.Entity
|
|||
public string? Channels { get; set; }
|
||||
public string? Extension { get; set; }
|
||||
|
||||
//Dash
|
||||
public RoleType? Role { get; set; }
|
||||
|
||||
//补充信息-色域
|
||||
public string? VideoRange { get; set; }
|
||||
//补充信息-特征
|
||||
|
@ -74,19 +77,19 @@ namespace N_m3u8DL_RE.Common.Entity
|
|||
if (MediaType == Enum.MediaType.AUDIO)
|
||||
{
|
||||
prefixStr = $"[deepskyblue3]Aud[/] {encStr}";
|
||||
var d = $"{GroupId} | {(Bandwidth != null ? (Bandwidth / 1000) + " Kbps" : "")} | {Name} | {Codecs} | {Language} | {(Channels != null ? Channels + "CH" : "")}";
|
||||
var d = $"{GroupId} | {(Bandwidth != null ? (Bandwidth / 1000) + " Kbps" : "")} | {Name} | {Codecs} | {Language} | {(Channels != null ? Channels + "CH" : "")} | {Role}";
|
||||
returnStr = d.EscapeMarkup();
|
||||
}
|
||||
else if (MediaType == Enum.MediaType.SUBTITLES)
|
||||
{
|
||||
prefixStr = $"[deepskyblue3_1]Sub[/] {encStr}";
|
||||
var d = $"{GroupId} | {Language} | {Name} | {Codecs}";
|
||||
var d = $"{GroupId} | {Language} | {Name} | {Codecs} | {Role}";
|
||||
returnStr = d.EscapeMarkup();
|
||||
}
|
||||
else
|
||||
{
|
||||
prefixStr = $"[aqua]Vid[/] {encStr}";
|
||||
var d = $"{Resolution} | {Bandwidth / 1000} Kbps | {GroupId} | {FrameRate} | {Codecs} | {VideoRange}";
|
||||
var d = $"{Resolution} | {Bandwidth / 1000} Kbps | {GroupId} | {FrameRate} | {Codecs} | {VideoRange} | {Role}";
|
||||
returnStr = d.EscapeMarkup();
|
||||
}
|
||||
|
||||
|
@ -108,19 +111,19 @@ namespace N_m3u8DL_RE.Common.Entity
|
|||
if (MediaType == Enum.MediaType.AUDIO)
|
||||
{
|
||||
prefixStr = $"[deepskyblue3]Aud[/] {encStr}";
|
||||
var d = $"{(Bandwidth != null ? (Bandwidth / 1000) + " Kbps" : "")} | {Name} | {Language} | {(Channels != null ? Channels + "CH" : "")}";
|
||||
var d = $"{(Bandwidth != null ? (Bandwidth / 1000) + " Kbps" : "")} | {Name} | {Language} | {(Channels != null ? Channels + "CH" : "")} | {Role}";
|
||||
returnStr = d.EscapeMarkup();
|
||||
}
|
||||
else if (MediaType == Enum.MediaType.SUBTITLES)
|
||||
{
|
||||
prefixStr = $"[deepskyblue3_1]Sub[/] {encStr}";
|
||||
var d = $"{Language} | {Name} | {Codecs}";
|
||||
var d = $"{Language} | {Name} | {Codecs} | {Role}";
|
||||
returnStr = d.EscapeMarkup();
|
||||
}
|
||||
else
|
||||
{
|
||||
prefixStr = $"[aqua]Vid[/] {encStr}";
|
||||
var d = $"{Resolution} | {Bandwidth / 1000} Kbps | {FrameRate} | {VideoRange}";
|
||||
var d = $"{Resolution} | {Bandwidth / 1000} Kbps | {FrameRate} | {VideoRange} | {Role}";
|
||||
returnStr = d.EscapeMarkup();
|
||||
}
|
||||
|
||||
|
@ -150,19 +153,19 @@ namespace N_m3u8DL_RE.Common.Entity
|
|||
if (MediaType == Enum.MediaType.AUDIO)
|
||||
{
|
||||
prefixStr = $"[deepskyblue3]Aud[/] {encStr}";
|
||||
var d = $"{GroupId} | {(Bandwidth != null ? (Bandwidth / 1000) + " Kbps" : "")} | {Name} | {Codecs} | {Language} | {(Channels != null ? Channels + "CH" : "")} | {segmentsCountStr}";
|
||||
var d = $"{GroupId} | {(Bandwidth != null ? (Bandwidth / 1000) + " Kbps" : "")} | {Name} | {Codecs} | {Language} | {(Channels != null ? Channels + "CH" : "")} | {segmentsCountStr} | {Role}";
|
||||
returnStr = d.EscapeMarkup();
|
||||
}
|
||||
else if (MediaType == Enum.MediaType.SUBTITLES)
|
||||
{
|
||||
prefixStr = $"[deepskyblue3_1]Sub[/] {encStr}";
|
||||
var d = $"{GroupId} | {Language} | {Name} | {Codecs} | {Characteristics} | {segmentsCountStr}";
|
||||
var d = $"{GroupId} | {Language} | {Name} | {Codecs} | {Characteristics} | {segmentsCountStr} | {Role}";
|
||||
returnStr = d.EscapeMarkup();
|
||||
}
|
||||
else
|
||||
{
|
||||
prefixStr = $"[aqua]Vid[/] {encStr}";
|
||||
var d = $"{Resolution} | {Bandwidth / 1000} Kbps | {GroupId} | {FrameRate} | {Codecs} | {VideoRange} | {segmentsCountStr}";
|
||||
var d = $"{Resolution} | {Bandwidth / 1000} Kbps | {GroupId} | {FrameRate} | {Codecs} | {VideoRange} | {segmentsCountStr} | {Role}";
|
||||
returnStr = d.EscapeMarkup();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
namespace N_m3u8DL_RE.Common.Enum
|
||||
{
|
||||
public enum RoleType
|
||||
{
|
||||
Subtitle = 0,
|
||||
Main = 1,
|
||||
Alternate = 2,
|
||||
Supplementary = 3,
|
||||
Commentary = 4,
|
||||
Dub = 5,
|
||||
Description = 6,
|
||||
Sign = 7,
|
||||
Metadata = 8,
|
||||
}
|
||||
}
|
|
@ -459,7 +459,7 @@ namespace N_m3u8DL_RE.Common.Resource
|
|||
zhCN: "通过正则表达式选择符合要求的视频流. 你能够以:分隔形式指定如下参数:\r\n\r\n" +
|
||||
"id=REGEX:lang=REGEX:name=REGEX:codec=REGEX:res=REGEX:frame=REGEX\r\n" +
|
||||
"segsMin=number:segsMax=number:ch=REGEX:range=REGEX:url=REGEX\r\n" +
|
||||
"plistDurMin=hms:plistDurMax=hms:for=FOR\r\n\r\n" +
|
||||
"plistDurMin=hms:plistDurMax=hms:role=string:for=FOR\r\n\r\n" +
|
||||
"* for=FOR: 选择方式. best[number], worst[number], all (默认: best)\r\n\r\n" +
|
||||
"例如: \r\n" +
|
||||
"# 选择最佳视频\r\n" +
|
||||
|
@ -467,11 +467,12 @@ namespace N_m3u8DL_RE.Common.Resource
|
|||
"# 选择4K+HEVC视频\r\n" +
|
||||
"-sv res=\"3840*\":codec=hvc1:for=best\r\n" +
|
||||
"# 选择长度大于1小时20分钟30秒的视频\r\n" +
|
||||
"-sv plistDurMin=\"1h20m30s\":for=best\r\n",
|
||||
"-sv plistDurMin=\"1h20m30s\":for=best\r\n" +
|
||||
"-sv role=\"main\":for:best\r\n",
|
||||
zhTW: "通過正則表達式選擇符合要求的影片軌. 你能夠以:分隔形式指定如下參數:\r\n\r\n" +
|
||||
"id=REGEX:lang=REGEX:name=REGEX:codec=REGEX:res=REGEX:frame=REGEX\r\n" +
|
||||
"segsMin=number:segsMax=number:ch=REGEX:range=REGEX:url=REGEX\r\n" +
|
||||
"plistDurMin=hms:plistDurMax=hms:for=FOR\r\n\r\n" +
|
||||
"plistDurMin=hms:plistDurMax=hms:role=string:for=FOR\r\n\r\n" +
|
||||
"* for=FOR: 選擇方式. best[number], worst[number], all (默認: best)\r\n\r\n" +
|
||||
"例如: \r\n" +
|
||||
"# 選擇最佳影片\r\n" +
|
||||
|
@ -479,11 +480,12 @@ namespace N_m3u8DL_RE.Common.Resource
|
|||
"# 選擇4K+HEVC影片\r\n" +
|
||||
"-sv res=\"3840*\":codec=hvc1:for=best\r\n" +
|
||||
"# 選擇長度大於1小時20分鐘30秒的影片\r\n" +
|
||||
"-sv plistDurMin=\"1h20m30s\":for=best\r\n",
|
||||
"-sv plistDurMin=\"1h20m30s\":for=best\r\n" +
|
||||
"-sv role=\"main\":for:best\r\n",
|
||||
enUS: "Select video streams by regular expressions. OPTIONS is a colon separated list of:\r\n\r\n" +
|
||||
"id=REGEX:lang=REGEX:name=REGEX:codec=REGEX:res=REGEX:frame=REGEX\r\n" +
|
||||
"segsMin=number:segsMax=number:ch=REGEX:range=REGEX:url=REGEX\r\n" +
|
||||
"plistDurMin=hms:plistDurMax=hms:for=FOR\r\n\r\n" +
|
||||
"plistDurMin=hms:plistDurMax=hms:role=string:for=FOR\r\n\r\n" +
|
||||
"* for=FOR: Select type. best[number], worst[number], all (Default: best)\r\n\r\n" +
|
||||
"Examples: \r\n" +
|
||||
"# select best video\r\n" +
|
||||
|
@ -491,7 +493,8 @@ namespace N_m3u8DL_RE.Common.Resource
|
|||
"# select 4K+HEVC video\r\n" +
|
||||
"-sv res=\"3840*\":codec=hvc1:for=best\r\n" +
|
||||
"# Select best video with duration longer than 1 hour 20 minutes 30 seconds\r\n" +
|
||||
"-sv plistDurMin=\"1h20m30s\":for=best\r\n"
|
||||
"-sv plistDurMin=\"1h20m30s\":for=best\r\n" +
|
||||
"-sv role=\"main\":for:best\r\n"
|
||||
),
|
||||
["cmd_selectAudio"] = new TextContainer
|
||||
(
|
||||
|
@ -514,7 +517,8 @@ namespace N_m3u8DL_RE.Common.Resource
|
|||
"# 选择最佳英语音轨\r\n" +
|
||||
"-sa lang=en:for=best\r\n" +
|
||||
"# 选择最佳的2条英语(或日语)音轨\r\n" +
|
||||
"-sa lang=\"ja|en\":for=best2\r\n",
|
||||
"-sa lang=\"ja|en\":for=best2\r\n" +
|
||||
"-sa role=\"main\":for:best\r\n",
|
||||
zhTW: "通過正則表達式選擇符合要求的音軌. 參考 --select-video\r\n\r\n" +
|
||||
"例如: \r\n" +
|
||||
"# 選擇所有音訊\r\n" +
|
||||
|
@ -522,7 +526,8 @@ namespace N_m3u8DL_RE.Common.Resource
|
|||
"# 選擇最佳英語音軌\r\n" +
|
||||
"-sa lang=en:for=best\r\n" +
|
||||
"# 選擇最佳的2條英語(或日語)音軌\r\n" +
|
||||
"-sa lang=\"ja|en\":for=best2\r\n",
|
||||
"-sa lang=\"ja|en\":for=best2\r\n" +
|
||||
"-sa role=\"main\":for:best\r\n",
|
||||
enUS: "Select audio streams by regular expressions. ref --select-video\r\n\r\n" +
|
||||
"Examples: \r\n" +
|
||||
"# select all\r\n" +
|
||||
|
@ -530,7 +535,8 @@ namespace N_m3u8DL_RE.Common.Resource
|
|||
"# select best eng audio\r\n" +
|
||||
"-sa lang=en:for=best\r\n" +
|
||||
"# select best 2, and language is ja or en\r\n" +
|
||||
"-sa lang=\"ja|en\":for=best2\r\n"
|
||||
"-sa lang=\"ja|en\":for=best2\r\n" +
|
||||
"-sa role=\"main\":for:best\r\n"
|
||||
),
|
||||
["cmd_selectSubtitle"] = new TextContainer
|
||||
(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using N_m3u8DL_RE.Common.Entity;
|
||||
using N_m3u8DL_RE.Common.Entity;
|
||||
using N_m3u8DL_RE.Common.Enum;
|
||||
using N_m3u8DL_RE.Common.Util;
|
||||
using N_m3u8DL_RE.Parser.Config;
|
||||
|
@ -189,10 +189,17 @@ namespace N_m3u8DL_RE.Parser.Extractor
|
|||
if (role != null)
|
||||
{
|
||||
var v = role.Attribute("value")?.Value;
|
||||
if (v == "subtitle")
|
||||
streamSpec.MediaType = MediaType.SUBTITLES;
|
||||
if (mType != null && mType.Contains("ttml"))
|
||||
streamSpec.Extension = "ttml";
|
||||
if (Enum.TryParse(v, true, out RoleType roleType))
|
||||
{
|
||||
streamSpec.Role = roleType;
|
||||
|
||||
if (roleType == RoleType.Subtitle)
|
||||
{
|
||||
streamSpec.MediaType = MediaType.SUBTITLES;
|
||||
if (mType != null && mType.Contains("ttml"))
|
||||
streamSpec.Extension = "ttml";
|
||||
}
|
||||
}
|
||||
}
|
||||
streamSpec.Playlist.IsLive = isLive;
|
||||
//设置刷新间隔 timeShiftBufferDepth / 2
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using N_m3u8DL_RE.Common.Enum;
|
||||
using N_m3u8DL_RE.Common.Enum;
|
||||
using N_m3u8DL_RE.Common.Log;
|
||||
using N_m3u8DL_RE.Common.Resource;
|
||||
using N_m3u8DL_RE.Common.Util;
|
||||
|
@ -367,6 +367,10 @@ namespace N_m3u8DL_RE.CommandLine
|
|||
if (!string.IsNullOrEmpty(plistDurMax))
|
||||
streamFilter.PlaylistMaxDur = OtherUtil.ParseSeconds(plistDurMax);
|
||||
|
||||
var role = p.GetValue("role");
|
||||
if (System.Enum.TryParse(role, true, out RoleType roleType))
|
||||
streamFilter.Role = roleType;
|
||||
|
||||
return streamFilter;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace N_m3u8DL_RE.Entity
|
|||
public long? SegmentsMaxCount { get; set; }
|
||||
public double? PlaylistMinDur { get; set; }
|
||||
public double? PlaylistMaxDur { get; set; }
|
||||
public RoleType? Role { get; set; }
|
||||
|
||||
public string For { get; set; } = "best";
|
||||
|
||||
|
@ -43,6 +44,7 @@ namespace N_m3u8DL_RE.Entity
|
|||
if (SegmentsMaxCount != null) sb.Append($"SegmentsMaxCount: {SegmentsMaxCount} ");
|
||||
if (PlaylistMinDur != null) sb.Append($"PlaylistMinDur: {PlaylistMinDur} ");
|
||||
if (PlaylistMaxDur != null) sb.Append($"PlaylistMaxDur: {PlaylistMaxDur} ");
|
||||
if (Role.HasValue) sb.Append($"Role: {Role} ");
|
||||
|
||||
return sb.ToString() + $"For: {For}";
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ namespace N_m3u8DL_RE.Util
|
|||
inputs = inputs.Where(i => i.Playlist?.TotalDuration > filter.PlaylistMinDur);
|
||||
if (filter.PlaylistMaxDur != null)
|
||||
inputs = inputs.Where(i => i.Playlist?.TotalDuration < filter.PlaylistMaxDur);
|
||||
if (filter.Role.HasValue)
|
||||
inputs = inputs.Where(i => i.Role == filter.Role);
|
||||
|
||||
var bestNumberStr = filter.For.Replace("best", "");
|
||||
var worstNumberStr = filter.For.Replace("worst", "");
|
||||
|
|
Loading…
Reference in New Issue