I am trying to download a youtube video using yt-dlp. The python file uses yt-dlp to download a youtube video by passing a URL of the video manually into python script using the subprocess.Open
function.
import subprocess
from moviepy.editor import *
import os
import moviepy.editor as mp
# Download files through url and saves it in yt-vidoes dir
command = "yt-dlp "
URL = 'https://www.youtube.com/watch?v=C_rsdqKA6ok'
parameters = ' --output yt-videos/%(title)s'
def download_video():
downloading = subprocess.Popen(command + URL)
downloading.wait()
print(downloading.returncode)
download_video()
It is working fine on Windows but on Ubuntu I get this error:
Traceback (most recent call last):
File "/home/purelogics/Arslan/shorts_bot/moveis/movies.py", line 17, in <module>
download_video()
File "/home/purelogics/Arslan/shorts_bot/moveis/movies.py", line 13, in download_video
downloading = subprocess.Popen(command + URL)
File "/home/linuxbrew/.linuxbrew/Cellar/python@3.10/3.10.8/lib/python3.10/subprocess.py", line 971, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/linuxbrew/.linuxbrew/Cellar/python@3.10/3.10.8/lib/python3.10/subprocess.py", line 1847, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'yt-dlp https://www.youtube.com/watch?v=C_rsdqKA6ok'