You've already forked N_m3u8DL-CLI
mirror of
https://github.com/nilaoda/N_m3u8DL-CLI
synced 2025-09-12 19:20:49 +02:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
71282bda30 | ||
![]() |
41ee8aebdf | ||
![]() |
a4537bc093 | ||
![]() |
b8a60b3917 | ||
![]() |
8091dd290f | ||
![]() |
d48e84e611 | ||
![]() |
9f5423a437 | ||
![]() |
ce7e38770a | ||
![]() |
8fdb2e918e | ||
![]() |
d4b7d240c1 | ||
![]() |
484d2941ed | ||
![]() |
a0f2b66575 | ||
![]() |
65cc0681e2 | ||
![]() |
7d980ec9a2 | ||
![]() |
ec5892c05a | ||
![]() |
9aed50fbf9 | ||
![]() |
d657b455cd | ||
![]() |
cda6575605 |
@@ -32,7 +32,7 @@ namespace N_m3u8DL_CLI
|
||||
/*===============================================================================*/
|
||||
static Version ver = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||
static string nowVer = $"{ver.Major}.{ver.Minor}.{ver.Build}";
|
||||
static string nowDate = "20201125";
|
||||
static string nowDate = "20201202";
|
||||
public static void WriteInit()
|
||||
{
|
||||
Console.Clear();
|
||||
|
@@ -30,12 +30,12 @@ namespace N_m3u8DL_CLI
|
||||
var SList = new List<Dictionary<string, dynamic>>();
|
||||
foreach (XmlElement s in sE)
|
||||
{
|
||||
var r = string.IsNullOrEmpty(s.GetAttribute("r")) ? 0 : Convert.ToInt32(s.GetAttribute("r"));
|
||||
var r = string.IsNullOrEmpty(s.GetAttribute("r")) ? 0 : Convert.ToInt64(s.GetAttribute("r"));
|
||||
MultisegmentInfo["TotalNumber"] += 1 + r;
|
||||
SList.Add(new Dictionary<string, dynamic>()
|
||||
{
|
||||
["t"] = string.IsNullOrEmpty(s.GetAttribute("t")) ? 0 : Convert.ToInt32(s.GetAttribute("t")),
|
||||
["d"] = Convert.ToInt32(s.GetAttribute("d")),
|
||||
["t"] = string.IsNullOrEmpty(s.GetAttribute("t")) ? 0 : Convert.ToInt64(s.GetAttribute("t")),
|
||||
["d"] = Convert.ToInt64(s.GetAttribute("d")),
|
||||
["r"] = r
|
||||
});
|
||||
}
|
||||
@@ -246,13 +246,31 @@ namespace N_m3u8DL_CLI
|
||||
return str;
|
||||
}
|
||||
|
||||
string PadNumber(string template, string key, long value)
|
||||
{
|
||||
string ReplaceFirst(string text, string search, string replace)
|
||||
{
|
||||
int pos = text.IndexOf(search);
|
||||
if (pos < 0)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
return text.Substring(0, pos) + replace + text.Substring(pos + search.Length);
|
||||
}
|
||||
|
||||
template = template.Replace("{{" + key + "}}", "");
|
||||
var m = Regex.Match(template, "{0:D(\\d+)}");
|
||||
return ReplaceFirst(template, m.Value, value.ToString("0".PadRight(Convert.ToInt32(m.Groups[1].Value), '0')));
|
||||
}
|
||||
|
||||
if (representationMsInfo.ContainsKey("Initialization"))
|
||||
{
|
||||
var initializationTemplate = PrepareTemplate("Initialization", new string[] { "Bandwidth" });
|
||||
var initializationUrl = "";
|
||||
if (initializationTemplate.Contains("{0:D"))
|
||||
{
|
||||
initializationUrl = string.Format(initializationTemplate, bandwidth).Replace("{{Bandwidth}}", "");
|
||||
if (initializationTemplate.Contains("{{Bandwidth}}"))
|
||||
initializationUrl = PadNumber(initializationTemplate, "Bandwidth", bandwidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -260,6 +278,7 @@ namespace N_m3u8DL_CLI
|
||||
}
|
||||
representationMsInfo["InitializationUrl"] = CombineURL(baseUrl, initializationUrl);
|
||||
}
|
||||
|
||||
string LocationKey(string location)
|
||||
{
|
||||
return Regex.IsMatch(location, "^https?://") ? "url" : "path";
|
||||
@@ -284,13 +303,15 @@ namespace N_m3u8DL_CLI
|
||||
var segUrl = "";
|
||||
if (mediaTemplate.Contains("{0:D"))
|
||||
{
|
||||
segUrl = string.Format(mediaTemplate, bandwidth).Replace("{{Bandwidth}}", "");
|
||||
segUrl = string.Format(mediaTemplate, i).Replace("{{Number}}", "");
|
||||
if (mediaTemplate.Contains("{{Bandwidth}}"))
|
||||
segUrl = PadNumber(mediaTemplate, "Bandwidth", bandwidth);
|
||||
if (mediaTemplate.Contains("{{Number}}"))
|
||||
segUrl = PadNumber(mediaTemplate, "Number", i);
|
||||
}
|
||||
else
|
||||
{
|
||||
segUrl = mediaTemplate.Replace("{{Bandwidth}}", bandwidth.ToString());
|
||||
segUrl = mediaTemplate.Replace("{{Number}}", i.ToString());
|
||||
segUrl = segUrl.Replace("{{Number}}", i.ToString());
|
||||
}
|
||||
fragments.Add(new Dictionary<string, dynamic>()
|
||||
{
|
||||
@@ -304,8 +325,8 @@ namespace N_m3u8DL_CLI
|
||||
{
|
||||
var fragments = new List<Dictionary<string, dynamic>>();
|
||||
|
||||
var segmentTime = 0;
|
||||
var segmentD = 0;
|
||||
var segmentTime = 0L;
|
||||
var segmentD = 0L;
|
||||
var segmentNumber = representationMsInfo["StartNumber"];
|
||||
|
||||
void addSegmentUrl()
|
||||
@@ -313,15 +334,18 @@ namespace N_m3u8DL_CLI
|
||||
var segUrl = "";
|
||||
if (mediaTemplate.Contains("{0:D"))
|
||||
{
|
||||
segUrl = string.Format(mediaTemplate, bandwidth).Replace("{{Bandwidth}}", "");
|
||||
segUrl = string.Format(mediaTemplate, segmentNumber).Replace("{{Number}}", "");
|
||||
segUrl = string.Format(mediaTemplate, segmentTime).Replace("{{Time}}", "");
|
||||
if (mediaTemplate.Contains("{{Bandwidth}}"))
|
||||
segUrl = PadNumber(mediaTemplate, "Bandwidth", bandwidth);
|
||||
if (mediaTemplate.Contains("{{Number}}"))
|
||||
segUrl = PadNumber(mediaTemplate, "Number", segmentNumber);
|
||||
if (mediaTemplate.Contains("{{Time}}"))
|
||||
segUrl = PadNumber(mediaTemplate, "Time", segmentTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
segUrl = mediaTemplate.Replace("{{Bandwidth}}", bandwidth.ToString());
|
||||
segUrl = mediaTemplate.Replace("{{Number}}", segmentNumber.ToString());
|
||||
segUrl = mediaTemplate.Replace("{{Time}}", segmentTime.ToString());
|
||||
segUrl = segUrl.Replace("{{Number}}", segmentNumber.ToString());
|
||||
segUrl = segUrl.Replace("{{Time}}", segmentTime.ToString());
|
||||
}
|
||||
fragments.Add(new Dictionary<string, dynamic>()
|
||||
{
|
||||
@@ -559,7 +583,7 @@ namespace N_m3u8DL_CLI
|
||||
if (!Directory.Exists(downDir + "(Audio)"))
|
||||
Directory.CreateDirectory(downDir + "(Audio)");
|
||||
var _path = Path.Combine(downDir + "(Audio)", "mpdAudio.m3u8");
|
||||
File.Copy(new Uri(audioPath).LocalPath, _path);
|
||||
File.Copy(new Uri(audioPath).LocalPath, _path, true);
|
||||
audioPath = new Uri(_path).ToString();
|
||||
content = $"#EXTM3U\r\n" +
|
||||
$"#EXT-X-MEDIA:TYPE=AUDIO,URI=\"{audioPath}\",GROUP-ID=\"default-audio-group\",NAME=\"stream_0\",AUTOSELECT=YES,CHANNELS=\"0\"\r\n" +
|
||||
@@ -600,7 +624,7 @@ namespace N_m3u8DL_CLI
|
||||
{
|
||||
var dur = seg.ContainsKey("duration") ? seg["duration"] : 0.0;
|
||||
var url = seg.ContainsKey("url") ? seg["url"] : seg["path"];
|
||||
sb.AppendLine($"#EXTINF:{dur}");
|
||||
sb.AppendLine($"#EXTINF:{dur.ToString("0.00")}");
|
||||
sb.AppendLine(url);
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -12,6 +13,8 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
@@ -38,6 +41,9 @@
|
||||
<ApplicationIcon>logo_3Iv_icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Costura, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.JScript" />
|
||||
<Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
@@ -130,4 +136,12 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\Fody.6.0.0\build\Fody.targets" Condition="Exists('..\packages\Fody.6.0.0\build\Fody.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Fody.6.0.0\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.0.0\build\Fody.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
@@ -118,7 +118,7 @@ namespace N_m3u8DL_CLI
|
||||
m3u8Content = DecodeImooc.DecodeM3u8(m3u8Content);
|
||||
}
|
||||
|
||||
if (m3u8Content.Trim().StartsWith("<?xml version") && m3u8Content.Contains("<MPD"))
|
||||
if (m3u8Content.Contains("</MPD>") && m3u8Content.Contains("<MPD"))
|
||||
{
|
||||
var mpdSavePath = Path.Combine(DownDir, "dash.mpd");
|
||||
//输出mpd文件
|
||||
|
@@ -51,20 +51,10 @@ namespace N_m3u8DL_CLI.NetCore
|
||||
{
|
||||
SetConsoleCtrlHandler(cancelHandler, true);
|
||||
ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate;
|
||||
string loc = "zh-CN";
|
||||
string loc = "en-US";
|
||||
string currLoc = Thread.CurrentThread.CurrentUICulture.Name;
|
||||
if (currLoc == "zh-TW" || currLoc == "zh-HK" || currLoc == "zh-MO")
|
||||
{
|
||||
loc = "zh-TW";
|
||||
}
|
||||
else if (loc == "zh-CN" || loc == "zh-SG")
|
||||
{
|
||||
loc = "zh-CN";
|
||||
}
|
||||
else
|
||||
{
|
||||
loc = "en-US";
|
||||
}
|
||||
if (currLoc == "zh-TW" || currLoc == "zh-HK" || currLoc == "zh-MO") loc = "zh-TW";
|
||||
else if (currLoc == "zh-CN" || currLoc == "zh-SG") loc = "zh-CN";
|
||||
//设置语言
|
||||
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(loc);
|
||||
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(loc);
|
||||
|
@@ -293,4 +293,10 @@
|
||||
- 修改芒果TV请求头
|
||||
2020年11月25日
|
||||
- 修正MPD判断最高清晰度的逻辑
|
||||
- 在MPD输入下支持选择音轨
|
||||
- 在MPD输入下支持选择音轨
|
||||
- 修复BUG
|
||||
2020年11月26日
|
||||
- 优化MPD识别方案
|
||||
- 修复MPD情况下时间戳溢出问题
|
||||
2020年12月2日
|
||||
- FIX Language Bug
|
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Fody" version="6.0.0" targetFramework="net46" developmentDependency="true" />
|
||||
<package id="Costura.Fody" version="4.1.0" targetFramework="net46" />
|
||||
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net46" />
|
||||
<package id="NiL.JS" version="2.5.1428" targetFramework="net46" />
|
||||
</packages>
|
Reference in New Issue
Block a user