From 17e3a0c4ab919ef66081e23219bc98376d071da0 Mon Sep 17 00:00:00 2001 From: nilaoda Date: Wed, 6 Jul 2022 15:37:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=9A=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E4=B8=8B=E7=9A=84=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE.Parser/StreamExtractor.cs | 25 +++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) 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(); + } } } }