修正JsonArray读取方式

This commit is contained in:
nilaoda 2022-06-19 23:56:34 +08:00
parent dd3f4fc81d
commit d563e0b87d
1 changed files with 9 additions and 6 deletions

View File

@ -316,7 +316,7 @@ namespace N_m3u8DL_RE.Parser.Extractor
if (representationMsInfo.ContainsKey("S")) if (representationMsInfo.ContainsKey("S"))
{ {
var array = representationMsInfo["S"].GetValue<JsonArray>(); var array = representationMsInfo["S"].AsArray();
for (int i = 0; i < array.Count; i++) for (int i = 0; i < array.Count; i++)
{ {
var s = array[i]; var s = array[i];
@ -342,7 +342,7 @@ namespace N_m3u8DL_RE.Parser.Extractor
var segmentIndex = 0; var segmentIndex = 0;
var timescale = representationMsInfo["Timescale"].GetValue<int>(); var timescale = representationMsInfo["Timescale"].GetValue<int>();
foreach (var s in representationMsInfo["S"].GetValue<JsonArray>()) foreach (var s in representationMsInfo["S"].AsArray())
{ {
var duration = DoubleOrNull(s["d"], timescale); var duration = DoubleOrNull(s["d"], timescale);
for (int j = 0; j < s["r"].GetValue<long>() + 1; j++) for (int j = 0; j < s["r"].GetValue<long>() + 1; j++)
@ -364,7 +364,7 @@ namespace N_m3u8DL_RE.Parser.Extractor
var fragments = new JsonArray(); var fragments = new JsonArray();
var segmentDuration = DoubleOrNull(representationMsInfo["SegmentDuration"].GetValue<double>(), representationMsInfo.ContainsKey("SegmentDuration") ? representationMsInfo["Timescale"].GetValue<int>() : 1); var segmentDuration = DoubleOrNull(representationMsInfo["SegmentDuration"].GetValue<double>(), representationMsInfo.ContainsKey("SegmentDuration") ? representationMsInfo["Timescale"].GetValue<int>() : 1);
foreach (var jsonNode in representationMsInfo["SegmentUrls"].GetValue<JsonArray>()) foreach (var jsonNode in representationMsInfo["SegmentUrls"].AsArray())
{ {
var segmentUrl = jsonNode.GetValue<string>(); var segmentUrl = jsonNode.GetValue<string>();
if (segmentDuration != -1) if (segmentDuration != -1)
@ -529,10 +529,13 @@ namespace N_m3u8DL_RE.Parser.Extractor
}; };
//统一添加EncryptInfo //统一添加EncryptInfo
if (playlist.MediaInit != null)
{
playlist.MediaInit.EncryptInfo = new EncryptInfo() playlist.MediaInit.EncryptInfo = new EncryptInfo()
{ {
Method = EncryptMethod.UNKNOWN Method = EncryptMethod.UNKNOWN
}; };
}
foreach (var seg in playlist.MediaParts[0].MediaSegments) foreach (var seg in playlist.MediaParts[0].MediaSegments)
{ {
seg.EncryptInfo = new EncryptInfo() seg.EncryptInfo = new EncryptInfo()