How to run a PyPi package command on Python

218 views Asked by At

I want to use the twitch-dl package from PyPi. After installing it, the idea is to basically run it on the terminal like this:

twitch-dl download <twitch-vod-url>

And it works well when running on the terminal but my goal is to run this command inside my Python script:

os.system('twitch-dl download <twitch-vod-url>`')

All I get is 256 as my output when I run this code. It does not download anything.

1

There are 1 answers

1
HelloMeeee On

You should try this

import subprocess
import twitchdl...

vod_url = "<twitch-vod-url>"
command = f"twitch-dl download {vod_url}"

try:
    subprocess.check_output(command, shell=True)
    print("Download completed")
except subprocess.CalledProcessError as e:
    print(f"Download failed error code as {e.returncode}")