YT download instrument update for python

frdel committed May 19, 2025 at 14:35 UTC 8dd823c0e4e4770ab249489891f9779c22f3600c
4 files changed +24 -4
instruments/default/.DS_Store
Binary files /dev/null and b/instruments/default/.DS_Store differ
instruments/default/yt_download/download_video.py new
+12
@@ -0,0 +1,12 @@
1 +import sys
2 +import yt_dlp # type: ignore
3 +
4 +if len(sys.argv) != 2:
5 + print("Usage: python3 download_video.py <url>")
6 + sys.exit(1)
7 +
8 +url = sys.argv[1]
9 +
10 +ydl_opts = {}
11 +with yt_dlp.YoutubeDL(ydl_opts) as ydl:
12 + ydl.download([url])
instruments/default/yt_download/yt_download.md
+7 -2
@@ -2,5 +2,10 @@
2 Download a YouTube video
3 # Solution
4 1. If folder is specified, cd to it
5 -2. Run instrument "bash /a0/instruments/default/yt_download/yt_download.sh <url>" with your video URL
6 -3. Wait for the terminal to finish
\ No newline at end of file
5 +2. Run the shell script with your video URL:
6 +
7 +```bash
8 +bash /a0/instruments/default/yt_download/yt_download.sh <url>
9 +```
10 +3. Replace `<url>` with your video URL.
11 +4. The script will handle the installation of yt-dlp and the download process.
instruments/default/yt_download/yt_download.sh
+5 -2
@@ -3,5 +3,8 @@
3 # Install yt-dlp and ffmpeg
4 sudo apt-get update && sudo apt-get install -y yt-dlp ffmpeg
5
6 -# Download the best video and audio, and merge them
7 -yt-dlp -f bestvideo+bestaudio --merge-output-format mp4 "$1"
\ No newline at end of file
6 +# Install yt-dlp using pip
7 +pip install --upgrade yt-dlp
8 +
9 +# Call the Python script to download the video
10 +python3 /a0/instruments/default/yt_download/download_video.py "$1"