重定向后应该同时更改默认BaseUrl

This commit is contained in:
nilaoda 2022-11-13 00:07:29 +08:00
parent 004575c152
commit 7bba10aa0d
1 changed files with 10 additions and 3 deletions

View File

@ -29,9 +29,15 @@ namespace N_m3u8DL_RE.Parser.Extractor
public DASHExtractor2(ParserConfig parserConfig) public DASHExtractor2(ParserConfig parserConfig)
{ {
this.ParserConfig = parserConfig; this.ParserConfig = parserConfig;
this.MpdUrl = parserConfig.Url ?? string.Empty; SetInitUrl();
if (!string.IsNullOrEmpty(parserConfig.BaseUrl)) }
this.BaseUrl = parserConfig.BaseUrl;
private void SetInitUrl()
{
this.MpdUrl = ParserConfig.Url ?? string.Empty;
if (!string.IsNullOrEmpty(ParserConfig.BaseUrl))
this.BaseUrl = ParserConfig.BaseUrl;
else else
this.BaseUrl = this.MpdUrl; this.BaseUrl = this.MpdUrl;
} }
@ -484,6 +490,7 @@ namespace N_m3u8DL_RE.Parser.Extractor
if (streamSpecs.Count == 0) return; if (streamSpecs.Count == 0) return;
var (rawText, url) = await HTTPUtil.GetWebSourceAndNewUrlAsync(ParserConfig.OriginalUrl, ParserConfig.Headers); var (rawText, url) = await HTTPUtil.GetWebSourceAndNewUrlAsync(ParserConfig.OriginalUrl, ParserConfig.Headers);
ParserConfig.Url = url; ParserConfig.Url = url;
SetInitUrl();
var newStreams = await ExtractStreamsAsync(rawText); var newStreams = await ExtractStreamsAsync(rawText);
foreach (var streamSpec in streamSpecs) foreach (var streamSpec in streamSpecs)
{ {