优化playlist加载逻辑
This commit is contained in:
parent
c681a2997f
commit
46aff16455
|
@ -9,7 +9,7 @@ using N_m3u8DL_RE.Common.Enum;
|
|||
|
||||
namespace N_m3u8DL_RE.Parser.Extractor
|
||||
{
|
||||
internal interface IExtractor
|
||||
public interface IExtractor
|
||||
{
|
||||
ExtractorType ExtractorType { get; }
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace N_m3u8DL_RE.Parser
|
|||
{
|
||||
public class StreamExtractor
|
||||
{
|
||||
private IExtractor extractor;
|
||||
public IExtractor Extractor { get; private set; }
|
||||
private ParserConfig parserConfig = new ParserConfig();
|
||||
private string rawText;
|
||||
private static SemaphoreSlim semaphore = new SemaphoreSlim(1, 1);
|
||||
|
@ -56,13 +56,13 @@ namespace N_m3u8DL_RE.Parser
|
|||
if (rawText.StartsWith(HLSTags.ext_m3u))
|
||||
{
|
||||
Logger.InfoMarkUp(ResString.matchHLS);
|
||||
extractor = new HLSExtractor(parserConfig);
|
||||
Extractor = new HLSExtractor(parserConfig);
|
||||
}
|
||||
else if (rawText.Contains("</MPD>") && rawText.Contains("<MPD"))
|
||||
{
|
||||
Logger.InfoMarkUp(ResString.matchDASH);
|
||||
//extractor = new DASHExtractor(parserConfig);
|
||||
extractor = new DASHExtractor2(parserConfig);
|
||||
Extractor = new DASHExtractor2(parserConfig);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ namespace N_m3u8DL_RE.Parser
|
|||
{
|
||||
await semaphore.WaitAsync();
|
||||
Logger.Info(ResString.parsingStream);
|
||||
return await extractor.ExtractStreamsAsync(rawText);
|
||||
return await Extractor.ExtractStreamsAsync(rawText);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ namespace N_m3u8DL_RE.Parser
|
|||
{
|
||||
await semaphore.WaitAsync();
|
||||
Logger.Info(ResString.parsingStream);
|
||||
await extractor.FetchPlayListAsync(streamSpecs);
|
||||
await Extractor.FetchPlayListAsync(streamSpecs);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -246,8 +246,9 @@ namespace N_m3u8DL_RE
|
|||
if (!selectedStreams.Any())
|
||||
throw new Exception(ResString.noStreamsToDownload);
|
||||
|
||||
//选中流中若有没加载出playlist的,加载playlist
|
||||
if (selectedStreams.Any(s => s.Playlist == null))
|
||||
//HLS: 选中流中若有没加载出playlist的,加载playlist
|
||||
//DASH: 加载playlist (调用url预处理器)
|
||||
if (selectedStreams.Any(s => s.Playlist == null) || extractor.Extractor.ExtractorType == ExtractorType.MPEG_DASH)
|
||||
await extractor.FetchPlayListAsync(selectedStreams);
|
||||
|
||||
//无法识别的加密方式,自动开启二进制合并
|
||||
|
|
Loading…
Reference in New Issue