]> Arthur Taft Gitweb - yt-dlp-wrapper.git/commitdiff
Re-organize and add Linux Support
authorArthur Taft <[email protected]>
Sat, 8 Feb 2025 03:30:19 +0000 (20:30 -0700)
committerArthur Taft <[email protected]>
Sat, 8 Feb 2025 03:30:19 +0000 (20:30 -0700)
Changed directory structure to hold windows and linux files, added bash script for linux

linux/bin/yt-dlp [new file with mode: 0644]
linux/yt-dlp-wrapper.sh [new file with mode: 0644]
windows/bin/ffmpeg.exe [moved from bin/ffmpeg.exe with 100% similarity]
windows/bin/yt-dlp.exe [moved from bin/yt-dlp.exe with 100% similarity]
windows/yt-dlp-wrapper.ps1 [moved from yt-dlp-wrapper.ps1 with 100% similarity]

diff --git a/linux/bin/yt-dlp b/linux/bin/yt-dlp
new file mode 100644 (file)
index 0000000..fde5494
Binary files /dev/null and b/linux/bin/yt-dlp differ
diff --git a/linux/yt-dlp-wrapper.sh b/linux/yt-dlp-wrapper.sh
new file mode 100644 (file)
index 0000000..ed83050
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/bash
+
+# Define variables
+current_dir="$PWD"
+exe_location="$current_dir"/bin/yt-dlp
+ffmpeg_location=/usr/bin/ffmpeg
+audio_dir="$current_dir"/audio
+video_dir="$current_dir"/video
+val=0
+url=""
+type=""
+
+# Function to hold audio download command
+audio_dl () {
+    "$exe_location" -x -f 'ba' --audio-format mp3 -o "$audio_dir/%(title)s.%(ext)s" "$url"
+}
+
+# Function to hold video download command
+video_dl () {
+    "$exe_location" -f 'bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b' -o "$video_dir/%(title)s.%(ext)s" "$url"
+}
+
+# Check if ffmpeg is installed
+if [ ! "$ffmpeg_location" ]; then
+    echo "Missing dependency ffmpeg"
+    exit 1
+fi 
+
+# Remove executable
+if [ "$exe_location" ]; then
+    rm "$exe_location"
+fi
+
+# Download new executable
+wget -q -O "$exe_location" https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp
+
+# Make executable executable
+chmod +x "$exe_location"
+
+# Check if audio directory exists, if not, create it
+if [ ! "$audio_dir" ]; then
+    mkdir audio
+fi
+
+# Check if video directory exists, if not, create it
+if [ ! "$video_dir" ]; then
+    mkdir video
+fi
+
+# While loop to contain download logic
+while [ "$val" -ne 1 ]; do
+    # Ask user if they want to download audio or video
+    read -p "Audio or Video?: " type
+
+    # Download audio
+    if [ "$type" = "audio" ]; then
+        read -p "Enter URL Here: " url
+        audio_dl
+        val=1
+    # Download video
+    elif [ "$type" = "video" ]; then
+        read -p "Enter URL Here: " url
+        video_dl
+        val=1
+    # If invlaid response is given, start over
+    else
+        echo "Must be 'Audio' or 'Video'!"
+        continue
+    fi
+done
+
+# If you made it here you get a sweet exit code 0
+exit 0
\ No newline at end of file
similarity index 100%
rename from bin/ffmpeg.exe
rename to windows/bin/ffmpeg.exe
similarity index 100%
rename from bin/yt-dlp.exe
rename to windows/bin/yt-dlp.exe