@@ -326,7 +326,15 @@ private static String[] getPath(String name) throws IOException {
326
326
while (!pathSuccess ) {
327
327
if (hint ) System .out .println ("\n 请输入保存路径:" );
328
328
savePath = input ();
329
- File file = new File (savePath );
329
+ File file ;
330
+ if (savePath .startsWith ("~" )) {
331
+ String userHomeDir = Paths .get (System .getProperty ("user.home" )).toAbsolutePath ().toString ();
332
+ if (debug ) System .out .println ("检测到路径以“~”开头,已找到用户主目录:" + userHomeDir );
333
+ file = new File (userHomeDir , savePath .substring (1 ));
334
+ savePath = file .getAbsolutePath ();
335
+ } else {
336
+ file = new File (savePath );
337
+ }
330
338
if (!file .exists ()) {
331
339
if (hint ) System .out .println ("该目录不存在,请决定是否创建该目录(输入“Y”代表是,输入“N”代表否):" );
332
340
if (input ().equalsIgnoreCase ("Y" )) {
@@ -386,14 +394,15 @@ private static void download(Object[] details, String[] path) throws IOException
386
394
}
387
395
}
388
396
while (ffmpegSuccess == 0 ) {
389
- if (hint ) System .out .println ("\n 请输入 ffmpeg.exe 目录(跳过合并请填“#”):" );
397
+
398
+ if (hint ) System .out .println ("\n 请输入 ffmpeg(.exe) 的绝对路径(跳过合并请填“#”):" );
390
399
String ffmpegPath = input ();
391
400
if (ffmpegPath .equals ("#" )) {
392
401
ffmpegSuccess = -1 ;
393
402
break ;
394
403
}
395
- ffmpeg = ffmpegPath .endsWith ("ffmpeg.exe" ) ? new File (ffmpegPath ) : new File (ffmpegPath , " ffmpeg.exe" );
396
- ffmpegSuccess = ffmpeg .exists () ? 1 : 0 ;
404
+ ffmpeg = ( ffmpegPath .endsWith ("ffmpeg.exe" ) || (! System . getProperty ( "os.name" ). toLowerCase (). contains ( "windows" ) && ffmpegPath . endsWith ( "ffmpeg" ))) ? new File (ffmpegPath ) : new File (ffmpegPath , System . getProperty ( "os.name" ). toLowerCase (). contains ( "windows" ) ? " ffmpeg.exe" : "ffmpeg " );
405
+ ffmpegSuccess = ffmpeg .exists () && ! ffmpeg . isDirectory () ? 1 : 0 ;
397
406
if (ffmpegSuccess == 1 ) {
398
407
if (hint ) System .out .println ("请决定是否保存 FFmpeg 路径(输入“Y”代表是,输入“N”代表否):" );
399
408
if (input ().equalsIgnoreCase ("Y" )) {
@@ -408,7 +417,7 @@ private static void download(Object[] details, String[] path) throws IOException
408
417
}
409
418
}
410
419
if (ffmpegSuccess == 0 ) {
411
- System .out .println ("该目录不存在 ffmpeg.exe" );
420
+ System .out .println ("无法找到 ffmpeg( .exe) " );
412
421
}
413
422
}
414
423
boolean videoSuccess , audioSuccess ;
0 commit comments