Skip to content

Commit

Permalink
subprocess: don't use shell (#1254)
Browse files Browse the repository at this point in the history
There is no need to.
  • Loading branch information
dotlambda authored Apr 11, 2021
1 parent a0b1147 commit 739a08a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions spotdl/download/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@


def has_correct_version(skip_version_check: bool = False, ffmpeg_path: str = "ffmpeg") -> bool:
process = subprocess.Popen(
['ffmpeg', '-version'],
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8"
)

output = "".join(process.communicate())

if process.returncode == 127:
try:
process = subprocess.Popen(
['ffmpeg', '-version'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8"
)
except FileNotFoundError:
print("FFmpeg was not found, spotDL cannot continue.", file=sys.stderr)
return False

output = "".join(process.communicate())

if skip_version_check is False:
result = re.search(r"ffmpeg version \w?(\d+\.)?(\d+)", output)

Expand Down

0 comments on commit 739a08a

Please sign in to comment.