frdel commited on
Commit
aa160ef
·
1 Parent(s): 760b243

YT download instrument update for python

Browse files
instruments/default/.DS_Store ADDED
Binary file (6.15 kB). View file
 
instruments/default/yt_download/download_video.py ADDED
@@ -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 CHANGED
@@ -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
 
 
 
 
 
 
2
  Download a YouTube video
3
  # Solution
4
  1. If folder is specified, cd to it
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 CHANGED
@@ -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"
 
 
 
 
3
  # Install yt-dlp and ffmpeg
4
  sudo apt-get update && sudo apt-get install -y yt-dlp ffmpeg
5
 
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"