1
1
from __future__ import annotations
2
2
3
- import os
4
3
import re
5
4
import subprocess
6
5
import sys
6
+ from os .path import exists , isdir , isfile , lexists , splitext
7
7
8
8
from auto_editor .ffwrapper import FFmpeg
9
9
from auto_editor .utils .func import get_stdout
@@ -27,7 +27,7 @@ def download_video(my_input: str, args: Args, ffmpeg: FFmpeg, log: Log) -> str:
27
27
download_format = "bestvideo[ext=mp4]+bestaudio[ext=m4a]"
28
28
29
29
if args .output_format is None :
30
- output_format = re .sub (r"\W+" , "-" , os . path . splitext (my_input )[0 ]) + ".%(ext)s"
30
+ output_format = re .sub (r"\W+" , "-" , splitext (my_input )[0 ]) + ".%(ext)s"
31
31
else :
32
32
output_format = args .output_format
33
33
@@ -57,10 +57,10 @@ def download_video(my_input: str, args: Args, ffmpeg: FFmpeg, log: Log) -> str:
57
57
msg += "pip or your favorite package manager and make sure it's in PATH."
58
58
log .error (msg )
59
59
60
- if not os . path . isfile (location ):
60
+ if not isfile (location ):
61
61
subprocess .run ([yt_dlp_path ] + cmd )
62
62
63
- if not os . path . isfile (location ):
63
+ if not isfile (location ):
64
64
log .error (f"Download file wasn't created: { location } " )
65
65
66
66
return location
@@ -73,11 +73,16 @@ def valid_input(inputs: list[str], ffmpeg: FFmpeg, args: Args, log: Log) -> list
73
73
if my_input .startswith ("http://" ) or my_input .startswith ("https://" ):
74
74
result .append (download_video (my_input , args , ffmpeg , log ))
75
75
else :
76
- _ , ext = os . path . splitext (my_input )
76
+ _ , ext = splitext (my_input )
77
77
if ext == "" :
78
- if os . path . isdir (my_input ):
78
+ if isdir (my_input ):
79
79
log .error ("Input must be a file or a URL, not a directory." )
80
- log .error ("Input file must have an extension." )
80
+ if exists (my_input ):
81
+ log .error (f"Input file must have an extension: { my_input } " )
82
+ if lexists (my_input ):
83
+ log .error (f"Input file is a broken symbolic link: { my_input } " )
84
+ if my_input .startswith ("-" ):
85
+ log .error (f"Option/Input file doesn't exist: { my_input } " )
81
86
result .append (my_input )
82
87
83
88
return result
0 commit comments