From: Arthur Taft Date: Sat, 8 Feb 2025 03:30:19 +0000 (-0700) Subject: Re-organize and add Linux Support X-Git-Url: https://gitweb.arthurtaft.net/yt-dlp-wrapper.git/commitdiff_plain/795ebfda4485f98a96e00b549f2b6427acc3f03b?hp=a4de5147e9d32b0f26f8c1ba60f57485eec5ce15 Re-organize and add Linux Support Changed directory structure to hold windows and linux files, added bash script for linux --- diff --git a/linux/bin/yt-dlp b/linux/bin/yt-dlp new file mode 100644 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 index 0000000..ed83050 --- /dev/null +++ b/linux/yt-dlp-wrapper.sh @@ -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 diff --git a/bin/ffmpeg.exe b/windows/bin/ffmpeg.exe similarity index 100% rename from bin/ffmpeg.exe rename to windows/bin/ffmpeg.exe diff --git a/bin/yt-dlp.exe b/windows/bin/yt-dlp.exe similarity index 100% rename from bin/yt-dlp.exe rename to windows/bin/yt-dlp.exe diff --git a/yt-dlp-wrapper.ps1 b/windows/yt-dlp-wrapper.ps1 similarity index 100% rename from yt-dlp-wrapper.ps1 rename to windows/yt-dlp-wrapper.ps1