#!/bin/sh # This scripts allows you to download media from any site that is supported by youtube-dl o any of their forks, # is written to be used with qutebrowser, but also can be use on it's own. # In order to use it with qutebroser add in your config this line, edit the keybinding as you like # config.bind('Y', 'hint links spawn bash -c "qute-dl "$1"" _ {hint-url}') # The script has to be in your $PATH otherwise you'll need to add their dir to the line, some like this # config.bind('Y', 'hint links spawn bash -c "/path/to/script/qute-dl "$1"" _ {hint-url}') # # If you just want to use it without qutebrowser just add the url of the media you want to download as first argument to the script, some like # qute-dl url # dm="dmenu" dm1="dmenu" dr="/home/$USER/Musica/" if [ -d "$dr" ] then cd $dr else mkdir /home/$USER/Musica cd $dr fi # func Choose Between Availables Formats AudioPossibleFormats() { format=$(yt-dlp --list-formats "$url" | grep "audio only" | awk '{print $1 "-" $2}' | $dm -p "Choose Possible Formats: " ) fm=$(echo "$format" | awk '{print $1}') name=$($dm1 -p "Add name: " <&-) yt-dlp -o "$name.%(ext)s" "$fm" "$url" } # Func choose quality video to download ChooseQualityVideo() { options=$(yt-dlp --list-formats "$url" | grep -v "audio only" | grep -v "images" | awk 'NR==6 , NR==end {print $1 " " $2 " " $7}' | $dm -p "Choose Quality: ") qy=$(echo "$options" | awk '{print $1}') name=$($dm1 -p "Add name: " <&-) yt-dlp -o "$name.%(ext)s" "$qy" "$url" } url="$1" # Download audio ad(){ da=$(printf "BestQualityMP3\nChooseBetweenAvailablesFormats" | $dm -p "Audio Options: ") case "$da" in BestQualityMP3) name=$($dm1 -p "Add name: " <&-) yt-dlp -o "$name.%(ext)s" --extract-audio --audio-quality 0 --audio-format mp3 "$url" ;; ChooseBetweenAvailablesFormats) AudioPossibleFormats ;; esac } # Func Download video vd() { qv="$(printf "BestQuality\n1080p\n720p\n480p\nChooseQuality" | $dm -p "Quality Options: " )" case "$qv" in BestQuality) name=$($dm1 -p "Add name: " <&-) yt-dlp -o "$name.%(ext)s" -f bv+ba/b "$url" ;; 1080p) name=$($dm1 -p "Add name: " <&-) yt-dlp -o "$name.%(ext)s" -f bv[height=1080]+ba/best[height=1080] "$url" ;; 720p) name=$($dm1 -p "Add name: " <&-) yt-dlp -o "$name.%(ext)s" -f bv[height=720]+ba/b[height=720] "$url" ;; 480p) name=$($dm1 -p "Add name: " <&-) yt-dlp -o "$name.%(ext)s" -f bv[height=480]+ba/b[height=480] "$url" ;; ChooseQuality) ChooseQualityVideo ;; esac } noti() { herbe ""$url" has been downloaded" } op="$(printf "Video\nAudio" | $dm -p "Choose option:")" case "$op" in Video)vd && noti ;; Audio)ad && noti ;; esac