You've already forked N_m3u8DL-CLI
mirror of
https://github.com/nilaoda/N_m3u8DL-CLI
synced 2025-09-10 12:40:52 +02:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6c2e13b800 | ||
![]() |
086fc57958 |
@@ -152,6 +152,7 @@ namespace N_m3u8DL_CLI
|
|||||||
//开始调用下载
|
//开始调用下载
|
||||||
LOGGER.WriteLine("Start Downloading");
|
LOGGER.WriteLine("Start Downloading");
|
||||||
LOGGER.PrintLine("开始下载文件", LOGGER.Warning);
|
LOGGER.PrintLine("开始下载文件", LOGGER.Warning);
|
||||||
|
|
||||||
//下载MAP文件(若有)
|
//下载MAP文件(若有)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -225,6 +226,8 @@ namespace N_m3u8DL_CLI
|
|||||||
if (Global.HadReadInfo == false)
|
if (Global.HadReadInfo == false)
|
||||||
{
|
{
|
||||||
string href = DownDir + "\\Part_" + 0.ToString(partsPadZero) + "\\" + firstSeg["index"].Value<int>().ToString(segsPadZero) + ".ts";
|
string href = DownDir + "\\Part_" + 0.ToString(partsPadZero) + "\\" + firstSeg["index"].Value<int>().ToString(segsPadZero) + ".ts";
|
||||||
|
if (File.Exists(DownDir + "\\!MAP.ts"))
|
||||||
|
href = DownDir + "\\!MAP.ts";
|
||||||
Global.GzipHandler(href);
|
Global.GzipHandler(href);
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
foreach (string ss in (string[])Global.GetVideoInfo(href).ToArray(typeof(string)))
|
foreach (string ss in (string[])Global.GetVideoInfo(href).ToArray(typeof(string)))
|
||||||
@@ -521,7 +524,7 @@ namespace N_m3u8DL_CLI
|
|||||||
|
|
||||||
FFmpeg.OutPutPath = Path.Combine(Directory.GetParent(DownDir).FullName, DownName);
|
FFmpeg.OutPutPath = Path.Combine(Directory.GetParent(DownDir).FullName, DownName);
|
||||||
FFmpeg.ReportFile = driverName + "\\:" + exePath.Remove(0, exePath.IndexOf(':') + 1).Replace("\\", "/") + "/Logs/" + Path.GetFileNameWithoutExtension(LOGGER.LOGFILE) + fflogName;
|
FFmpeg.ReportFile = driverName + "\\:" + exePath.Remove(0, exePath.IndexOf(':') + 1).Replace("\\", "/") + "/Logs/" + Path.GetFileNameWithoutExtension(LOGGER.LOGFILE) + fflogName;
|
||||||
|
|
||||||
//合并分段
|
//合并分段
|
||||||
LOGGER.PrintLine("合并分段中...");
|
LOGGER.PrintLine("合并分段中...");
|
||||||
for (int i = 0; i < PartsCount; i++)
|
for (int i = 0; i < PartsCount; i++)
|
||||||
@@ -570,7 +573,7 @@ namespace N_m3u8DL_CLI
|
|||||||
FFmpeg.Merge(Global.GetFiles(DownDir, ".ts"), MuxFormat, MuxFastStart);
|
FFmpeg.Merge(Global.GetFiles(DownDir, ".ts"), MuxFormat, MuxFastStart);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
JObject json = JObject.Parse(MuxSetJson);
|
JObject json = JObject.Parse(File.ReadAllText(MuxSetJson, Encoding.UTF8));
|
||||||
string muxFormat = json["muxFormat"].Value<string>();
|
string muxFormat = json["muxFormat"].Value<string>();
|
||||||
bool fastStart = Convert.ToBoolean(json["fastStart"].Value<string>());
|
bool fastStart = Convert.ToBoolean(json["fastStart"].Value<string>());
|
||||||
string poster = json["poster"].Value<string>();
|
string poster = json["poster"].Value<string>();
|
||||||
|
@@ -30,8 +30,8 @@ namespace N_m3u8DL_CLI
|
|||||||
|
|
||||||
|
|
||||||
/*===============================================================================*/
|
/*===============================================================================*/
|
||||||
static string nowVer = "2.4.2";
|
static string nowVer = "2.4.4";
|
||||||
static string nowDate = "20191216";
|
static string nowDate = "20191218";
|
||||||
public static void WriteInit()
|
public static void WriteInit()
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
@@ -58,7 +58,10 @@ namespace N_m3u8DL_CLI
|
|||||||
//尝试下载新版本(去码云)
|
//尝试下载新版本(去码云)
|
||||||
string url = $"https://gitee.com/nilaoda/N_m3u8DL-CLI/raw/master/N_m3u8DL-CLI_v{latestVer}.exe";
|
string url = $"https://gitee.com/nilaoda/N_m3u8DL-CLI/raw/master/N_m3u8DL-CLI_v{latestVer}.exe";
|
||||||
if (File.Exists(Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), $"N_m3u8DL-CLI_v{latestVer}.exe")))
|
if (File.Exists(Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), $"N_m3u8DL-CLI_v{latestVer}.exe")))
|
||||||
|
{
|
||||||
|
Console.Title = $"检测到更新,版本:{latestVer}! 新版下载成功,请您自行替换";
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
HttpDownloadFile(url, Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), $"N_m3u8DL-CLI_v{latestVer}.exe"));
|
HttpDownloadFile(url, Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), $"N_m3u8DL-CLI_v{latestVer}.exe"));
|
||||||
if (File.Exists(Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), $"N_m3u8DL-CLI_v{latestVer}.exe")))
|
if (File.Exists(Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), $"N_m3u8DL-CLI_v{latestVer}.exe")))
|
||||||
Console.Title = $"检测到更新,版本:{latestVer}! 新版下载成功,请您自行替换";
|
Console.Title = $"检测到更新,版本:{latestVer}! 新版下载成功,请您自行替换";
|
||||||
@@ -709,6 +712,14 @@ namespace N_m3u8DL_CLI
|
|||||||
{
|
{
|
||||||
VIDEO_TYPE = "DV";
|
VIDEO_TYPE = "DV";
|
||||||
}
|
}
|
||||||
|
else if (res.Contains("Video hevc (Main 10) (dvh1")) //优酷视频杜比视界
|
||||||
|
{
|
||||||
|
VIDEO_TYPE = "DV";
|
||||||
|
}
|
||||||
|
else if (res.Contains("Video hevc (dvh1")) //优酷视频杜比视界
|
||||||
|
{
|
||||||
|
VIDEO_TYPE = "DV";
|
||||||
|
}
|
||||||
else if (res.Contains("Video h264"))
|
else if (res.Contains("Video h264"))
|
||||||
{
|
{
|
||||||
VIDEO_TYPE = "H264";
|
VIDEO_TYPE = "H264";
|
||||||
|
@@ -48,6 +48,8 @@ namespace N_m3u8DL_CLI
|
|||||||
private static string durEnd = "";
|
private static string durEnd = "";
|
||||||
//是否自动清除优酷广告分片
|
//是否自动清除优酷广告分片
|
||||||
private static bool delAd = true;
|
private static bool delAd = true;
|
||||||
|
//标记是否已清除优酷广告分片
|
||||||
|
private static bool hasAd = false;
|
||||||
|
|
||||||
public string BaseUrl { get => baseUrl; set => baseUrl = value; }
|
public string BaseUrl { get => baseUrl; set => baseUrl = value; }
|
||||||
public string M3u8Url { get => m3u8Url; set => m3u8Url = value; }
|
public string M3u8Url { get => m3u8Url; set => m3u8Url = value; }
|
||||||
@@ -202,7 +204,16 @@ namespace N_m3u8DL_CLI
|
|||||||
//解析不连续标记,需要单独合并(timestamp不同)
|
//解析不连续标记,需要单独合并(timestamp不同)
|
||||||
else if (line.StartsWith(HLSTags.ext_x_discontinuity))
|
else if (line.StartsWith(HLSTags.ext_x_discontinuity))
|
||||||
{
|
{
|
||||||
if (segments.Count > 1)
|
//修复优酷去除广告后的遗留问题
|
||||||
|
if (hasAd && parts.Count > 0)
|
||||||
|
{
|
||||||
|
segments = (JArray)parts[parts.Count - 1];
|
||||||
|
parts.RemoveAt(parts.Count - 1);
|
||||||
|
hasAd = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//常规情况的#EXT-X-DISCONTINUITY标记,新建part
|
||||||
|
if (!hasAd && segments.Count > 1)
|
||||||
{
|
{
|
||||||
parts.Add(segments);
|
parts.Add(segments);
|
||||||
segments = new JArray();
|
segments = new JArray();
|
||||||
@@ -279,7 +290,8 @@ namespace N_m3u8DL_CLI
|
|||||||
//m3u8主体结束
|
//m3u8主体结束
|
||||||
else if (line.StartsWith(HLSTags.ext_x_endlist))
|
else if (line.StartsWith(HLSTags.ext_x_endlist))
|
||||||
{
|
{
|
||||||
parts.Add(segments);
|
if (segments.Count > 0)
|
||||||
|
parts.Add(segments);
|
||||||
segments = new JArray();
|
segments = new JArray();
|
||||||
isEndlist = true;
|
isEndlist = true;
|
||||||
}
|
}
|
||||||
@@ -308,10 +320,20 @@ namespace N_m3u8DL_CLI
|
|||||||
segments.Add(segInfo);
|
segments.Add(segInfo);
|
||||||
segInfo = new JObject();
|
segInfo = new JObject();
|
||||||
//优酷的广告分段则清除此分片
|
//优酷的广告分段则清除此分片
|
||||||
if (DelAd && segUrl.Contains("ccode") && segUrl.Contains("/ad/") && segUrl.Contains("duration"))
|
//需要注意,遇到广告说明程序对上文的#EXT-X-DISCONTINUITY做出的动作是不必要的,
|
||||||
|
//其实上下文是同一种编码,需要恢复到原先的part上
|
||||||
|
if (DelAd && segUrl.Contains("ccode=") && segUrl.Contains("/ad/") && segUrl.Contains("duration="))
|
||||||
{
|
{
|
||||||
segments.RemoveAt(segments.Count - 1);
|
segments.RemoveAt(segments.Count - 1);
|
||||||
segIndex--;
|
segIndex--;
|
||||||
|
hasAd = true;
|
||||||
|
}
|
||||||
|
//优酷广告(4K分辨率测试)
|
||||||
|
if (DelAd && segUrl.Contains("ccode=0902") && segUrl.Contains("duration="))
|
||||||
|
{
|
||||||
|
segments.RemoveAt(segments.Count - 1);
|
||||||
|
segIndex--;
|
||||||
|
hasAd = true;
|
||||||
}
|
}
|
||||||
expectSegment = false;
|
expectSegment = false;
|
||||||
}
|
}
|
||||||
|
@@ -207,6 +207,11 @@ namespace N_m3u8DL_CLI.NetCore
|
|||||||
/// - 完善芒果TV请求头的自动添加
|
/// - 完善芒果TV请求头的自动添加
|
||||||
/// 2019年12月16日
|
/// 2019年12月16日
|
||||||
/// - 处理文件名特殊字符
|
/// - 处理文件名特殊字符
|
||||||
|
/// 2019年12月18日
|
||||||
|
/// - 修复m3u8解析bug导致的无法合并问题
|
||||||
|
/// - 增加杜比视界识别场景
|
||||||
|
/// - 修复part大于1时读取json混流文件的严重错误
|
||||||
|
/// - 自动去除优酷的广告分片及前情提要
|
||||||
/// </summary>
|
/// </summary>
|
||||||
///
|
///
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user