diff --git a/src/N_m3u8DL-RE.Parser/StreamExtractor.cs b/src/N_m3u8DL-RE.Parser/StreamExtractor.cs index 9851491..6c46f39 100644 --- a/src/N_m3u8DL-RE.Parser/StreamExtractor.cs +++ b/src/N_m3u8DL-RE.Parser/StreamExtractor.cs @@ -19,6 +19,7 @@ namespace N_m3u8DL_RE.Parser private IExtractor extractor; private ParserConfig parserConfig = new ParserConfig(); private string rawText; + private static SemaphoreSlim semaphore = new SemaphoreSlim(1, 1); public StreamExtractor() { @@ -79,8 +80,16 @@ namespace N_m3u8DL_RE.Parser /// public async Task> ExtractStreamsAsync() { - Logger.Info(ResString.parsingStream); - return await extractor.ExtractStreamsAsync(rawText); + try + { + await semaphore.WaitAsync(); + Logger.Info(ResString.parsingStream); + return await extractor.ExtractStreamsAsync(rawText); + } + finally + { + semaphore.Release(); + } } /// @@ -89,8 +98,16 @@ namespace N_m3u8DL_RE.Parser /// public async Task FetchPlayListAsync(List streamSpecs) { - Logger.Info(ResString.parsingStream); - await extractor.FetchPlayListAsync(streamSpecs); + try + { + await semaphore.WaitAsync(); + Logger.Info(ResString.parsingStream); + await extractor.FetchPlayListAsync(streamSpecs); + } + finally + { + semaphore.Release(); + } } } }