Merge branch 'nilaoda:main' into main
This commit is contained in:
commit
04e7d403ce
|
@ -22,6 +22,8 @@ namespace N_m3u8DL_RE.Parser.Processor.HLS
|
||||||
private static partial Regex OrderFixRegex();
|
private static partial Regex OrderFixRegex();
|
||||||
[GeneratedRegex("#EXT-X-MAP.*\\.apple\\.com/")]
|
[GeneratedRegex("#EXT-X-MAP.*\\.apple\\.com/")]
|
||||||
private static partial Regex ATVRegex();
|
private static partial Regex ATVRegex();
|
||||||
|
[GeneratedRegex("(#EXT-X-KEY:[\\s\\S]*?)(#EXT-X-DISCONTINUITY|#EXT-X-ENDLIST)")]
|
||||||
|
private static partial Regex ATVRegex2();
|
||||||
|
|
||||||
public override bool CanProcess(ExtractorType extractorType, string rawText, ParserConfig parserConfig) => extractorType == ExtractorType.HLS;
|
public override bool CanProcess(ExtractorType extractorType, string rawText, ParserConfig parserConfig) => extractorType == ExtractorType.HLS;
|
||||||
|
|
||||||
|
@ -80,7 +82,7 @@ namespace N_m3u8DL_RE.Parser.Processor.HLS
|
||||||
if (m3u8Content.Contains("#EXT-X-DISCONTINUITY") && m3u8Content.Contains("#EXT-X-MAP") && (m3u8Url.Contains(".apple.com/") || ATVRegex().IsMatch(m3u8Content)))
|
if (m3u8Content.Contains("#EXT-X-DISCONTINUITY") && m3u8Content.Contains("#EXT-X-MAP") && (m3u8Url.Contains(".apple.com/") || ATVRegex().IsMatch(m3u8Content)))
|
||||||
{
|
{
|
||||||
//只取加密部分即可
|
//只取加密部分即可
|
||||||
Regex ykmap = DNSPRegex();
|
Regex ykmap = ATVRegex2();
|
||||||
if (ykmap.IsMatch(m3u8Content))
|
if (ykmap.IsMatch(m3u8Content))
|
||||||
{
|
{
|
||||||
m3u8Content = "#EXTM3U\r\n" + ykmap.Match(m3u8Content).Groups[1].Value + "\r\n#EXT-X-ENDLIST";
|
m3u8Content = "#EXTM3U\r\n" + ykmap.Match(m3u8Content).Groups[1].Value + "\r\n#EXT-X-ENDLIST";
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace N_m3u8DL_RE.CommandLine
|
||||||
{
|
{
|
||||||
internal partial class CommandInvoker
|
internal partial class CommandInvoker
|
||||||
{
|
{
|
||||||
public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20221212";
|
public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20221220";
|
||||||
|
|
||||||
[GeneratedRegex("((best|worst)\\d*|all)")]
|
[GeneratedRegex("((best|worst)\\d*|all)")]
|
||||||
private static partial Regex ForStrRegex();
|
private static partial Regex ForStrRegex();
|
||||||
|
|
|
@ -323,7 +323,7 @@ namespace N_m3u8DL_RE.DownloadManager
|
||||||
//校验分片数量
|
//校验分片数量
|
||||||
if (DownloaderConfig.MyOptions.CheckSegmentsCount && FileDic.Values.Any(s => s == null))
|
if (DownloaderConfig.MyOptions.CheckSegmentsCount && FileDic.Values.Any(s => s == null))
|
||||||
{
|
{
|
||||||
Logger.WarnMarkUp(ResString.segmentCountCheckNotPass, totalCount, FileDic.Values.Where(s => s != null).Count());
|
Logger.ErrorMarkUp(ResString.segmentCountCheckNotPass, totalCount, FileDic.Values.Where(s => s != null).Count());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,6 +670,8 @@ namespace N_m3u8DL_RE.DownloadManager
|
||||||
var task = kp.Value;
|
var task = kp.Value;
|
||||||
var result = await DownloadStreamAsync(kp.Key, task, SpeedContainerDic[task.Id]);
|
var result = await DownloadStreamAsync(kp.Key, task, SpeedContainerDic[task.Id]);
|
||||||
Results[kp.Key] = result;
|
Results[kp.Key] = result;
|
||||||
|
//失败不再下载后续
|
||||||
|
if (!result) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -799,7 +799,7 @@ namespace N_m3u8DL_RE.DownloadManager
|
||||||
//创建任务
|
//创建任务
|
||||||
var dic = SelectedSteams.Select(item =>
|
var dic = SelectedSteams.Select(item =>
|
||||||
{
|
{
|
||||||
var task = ctx.AddTask(item.ToShortString(), autoStart: false, maxValue: 0);
|
var task = ctx.AddTask(item.ToShortShortString(), autoStart: false, maxValue: 0);
|
||||||
SpeedContainerDic[task.Id] = new SpeedContainer(); //速度计算
|
SpeedContainerDic[task.Id] = new SpeedContainer(); //速度计算
|
||||||
LastFileNameDic[task.Id] = "";
|
LastFileNameDic[task.Id] = "";
|
||||||
DateTimeDic[task.Id] = 0L;
|
DateTimeDic[task.Id] = 0L;
|
||||||
|
|
|
@ -85,12 +85,19 @@ namespace N_m3u8DL_RE.Downloader
|
||||||
cancellationTokenSource = new();
|
cancellationTokenSource = new();
|
||||||
var des = Path.ChangeExtension(path, null);
|
var des = Path.ChangeExtension(path, null);
|
||||||
|
|
||||||
//已下载过跳过
|
//已下载跳过
|
||||||
if (File.Exists(des))
|
if (File.Exists(des))
|
||||||
{
|
{
|
||||||
return new DownloadResult() { ActualContentLength = 0, ActualFilePath = des };
|
return new DownloadResult() { ActualContentLength = 0, ActualFilePath = des };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//已解密跳过
|
||||||
|
var dec = Path.Combine(Path.GetDirectoryName(des)!, Path.GetFileNameWithoutExtension(des) + "_dec" + Path.GetExtension(des));
|
||||||
|
if (File.Exists(dec))
|
||||||
|
{
|
||||||
|
return new DownloadResult() { ActualContentLength = 0, ActualFilePath = dec };
|
||||||
|
}
|
||||||
|
|
||||||
//另起线程进行监控
|
//另起线程进行监控
|
||||||
using var watcher = Task.Factory.StartNew(async () =>
|
using var watcher = Task.Factory.StartNew(async () =>
|
||||||
{
|
{
|
||||||
|
@ -128,6 +135,10 @@ namespace N_m3u8DL_RE.Downloader
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.WarnMarkUp($"[grey]{ex.Message.EscapeMarkup()}[/]");
|
||||||
|
}
|
||||||
//throw new Exception("download failed", ex);
|
//throw new Exception("download failed", ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<LangVersion>preview</LangVersion>
|
<LangVersion>preview</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>0.1.5</Version>
|
<Version>0.1.5.2</Version>
|
||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
|
@ -7,17 +7,26 @@ namespace N_m3u8DL_RE.Util
|
||||||
{
|
{
|
||||||
internal class MP4DecryptUtil
|
internal class MP4DecryptUtil
|
||||||
{
|
{
|
||||||
|
private static string ZeroKid = "00000000000000000000000000000000";
|
||||||
public static async Task<bool> DecryptAsync(bool shakaPackager, string bin, string[]? keys, string source, string dest, string? kid, string init = "")
|
public static async Task<bool> DecryptAsync(bool shakaPackager, string bin, string[]? keys, string source, string dest, string? kid, string init = "")
|
||||||
{
|
{
|
||||||
if (keys == null || keys.Length == 0) return false;
|
if (keys == null || keys.Length == 0) return false;
|
||||||
|
|
||||||
var keyPair = keys.First();
|
string? keyPair = null;
|
||||||
|
string? trackId = null;
|
||||||
if (!string.IsNullOrEmpty(kid))
|
if (!string.IsNullOrEmpty(kid))
|
||||||
{
|
{
|
||||||
var test = keys.Where(k => k.StartsWith(kid));
|
var test = keys.Where(k => k.StartsWith(kid));
|
||||||
if (test.Any()) keyPair = test.First();
|
if (test.Any()) keyPair = test.First();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Apple
|
||||||
|
if (kid == ZeroKid)
|
||||||
|
{
|
||||||
|
keyPair = keys.First();
|
||||||
|
trackId = "1";
|
||||||
|
}
|
||||||
|
|
||||||
if (keyPair == null) return false;
|
if (keyPair == null) return false;
|
||||||
|
|
||||||
//shakaPackager 无法单独解密init文件
|
//shakaPackager 无法单独解密init文件
|
||||||
|
@ -37,12 +46,19 @@ namespace N_m3u8DL_RE.Util
|
||||||
enc = tmpFile;
|
enc = tmpFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = $"--enable_raw_key_decryption input=\"{enc}\",stream=0,output=\"{dest}\" " +
|
cmd = $"--quiet --enable_raw_key_decryption input=\"{enc}\",stream=0,output=\"{dest}\" " +
|
||||||
$"--keys key_id={keyPair.Split(':')[0]}:key={keyPair.Split(':')[1]}";
|
$"--keys {(trackId != null ? $"label={trackId}:" : "")}key_id={(trackId != null ? ZeroKid : kid)}:key={keyPair.Split(':')[1]}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (trackId == null)
|
||||||
{
|
{
|
||||||
cmd = string.Join(" ", keys.Select(k => $"--key {k}"));
|
cmd = string.Join(" ", keys.Select(k => $"--key {k}"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmd = string.Join(" ", keys.Select(k => $"--key {trackId}:{k.Split(':')[1]}"));
|
||||||
|
}
|
||||||
if (init != "")
|
if (init != "")
|
||||||
{
|
{
|
||||||
cmd += $" --fragments-info \"{init}\" ";
|
cmd += $" --fragments-info \"{init}\" ";
|
||||||
|
@ -69,8 +85,8 @@ namespace N_m3u8DL_RE.Util
|
||||||
{
|
{
|
||||||
FileName = name,
|
FileName = name,
|
||||||
Arguments = arg,
|
Arguments = arg,
|
||||||
RedirectStandardOutput = true,
|
//RedirectStandardOutput = true,
|
||||||
RedirectStandardError = true,
|
//RedirectStandardError = true,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
UseShellExecute = false
|
UseShellExecute = false
|
||||||
})!.WaitForExitAsync();
|
})!.WaitForExitAsync();
|
||||||
|
|
Loading…
Reference in New Issue