Skip to content

Commit

Permalink
文件名特殊字符处理
Browse files Browse the repository at this point in the history
  • Loading branch information
nilaoda committed Dec 16, 2019
1 parent cc4efed commit bc349b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 12 additions & 2 deletions N_m3u8DL-CLI/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class Global


/*===============================================================================*/
static string nowVer = "2.4.1";
static string nowDate = "20191130";
static string nowVer = "2.4.2";
static string nowDate = "20191216";
public static void WriteInit()
{
Console.Clear();
Expand Down Expand Up @@ -77,6 +77,16 @@ public static void CheckUpdate()
}
}

public static string GetValidFileName(string input, string re = ".")
{
string title = input;
foreach (char invalidChar in Path.GetInvalidFileNameChars())
{
title = title.Replace(invalidChar.ToString(), re);
}
return title;
}

// parseInt(s, radix)
public static int GetNum(string str, int numBase)
{
Expand Down
6 changes: 5 additions & 1 deletion N_m3u8DL-CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ namespace N_m3u8DL_CLI.NetCore
/// - 增加disableIntegrityCheck选项
/// 2019年10月24日
/// - 捕获Ctrl+C退出,移动光标到正确位置
/// 2019年11月30日
/// - 完善芒果TV请求头的自动添加
/// 2019年12月16日
/// - 处理文件名特殊字符
/// </summary>
///

Expand Down Expand Up @@ -392,7 +396,7 @@ static void Main(string[] args)
}
if (arguments.Has("--saveName"))
{
fileName = arguments.Get("--saveName").Next;
fileName = Global.GetValidFileName(arguments.Get("--saveName").Next);
}
if (arguments.Has("--useKeyFile"))
{
Expand Down

0 comments on commit bc349b8

Please sign in to comment.