尝试从URL或文件读取文件名
This commit is contained in:
parent
6e59dfd679
commit
9bdb1c77c0
|
@ -276,12 +276,31 @@ namespace N_m3u8DL_RE
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//尝试从URL或文件读取文件名
|
||||||
|
if (string.IsNullOrEmpty(option.SaveName))
|
||||||
|
{
|
||||||
|
if (File.Exists(option.Input))
|
||||||
|
{
|
||||||
|
option.SaveName = Path.GetFileNameWithoutExtension(option.Input) + "_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var uri = new Uri(option.Input);
|
||||||
|
var name = uri.GetLeftPart(UriPartial.Path).Split('/').Last();
|
||||||
|
name = string.Join(".", name.Split('.').SkipLast(1)).Trim('.');
|
||||||
|
option.SaveName = ConvertUtil.GetValidFileName(name) + "_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//下载配置
|
//下载配置
|
||||||
var downloadConfig = new DownloaderConfig()
|
var downloadConfig = new DownloaderConfig()
|
||||||
{
|
{
|
||||||
MyOptions = option,
|
MyOptions = option,
|
||||||
Headers = parserConfig.Headers, //使用命令行解析得到的Headers
|
Headers = parserConfig.Headers, //使用命令行解析得到的Headers
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!livingFlag)
|
||||||
|
{
|
||||||
//开始下载
|
//开始下载
|
||||||
var sdm = new SimpleDownloadManager(downloadConfig);
|
var sdm = new SimpleDownloadManager(downloadConfig);
|
||||||
var result = await sdm.StartDownloadAsync(selectedStreams);
|
var result = await sdm.StartDownloadAsync(selectedStreams);
|
||||||
|
@ -290,6 +309,11 @@ namespace N_m3u8DL_RE
|
||||||
else
|
else
|
||||||
Logger.ErrorMarkUp("[white on red]Faild[/]");
|
Logger.ErrorMarkUp("[white on red]Faild[/]");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotSupportedException("Live not supported yet.");
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
string msg = Logger.LogLevel == LogLevel.DEBUG ? ex.ToString() : ex.Message;
|
string msg = Logger.LogLevel == LogLevel.DEBUG ? ex.ToString() : ex.Message;
|
||||||
|
|
Loading…
Reference in New Issue