feat : made scripts universal and much more complicated

This commit is contained in:
coolnsx
2023-03-07 00:58:02 +05:30
parent aac5a51c73
commit 4c0a0a934a
14 changed files with 366 additions and 168 deletions

47
youtube
View File

@@ -1,7 +1,7 @@
#!/bin/sh
# script for downloading videos/audios and/or extract part from it..
# script for downloading videos/audios from sites...
# defining shell colors for distinction
c_red="\033[1;31m"
c_green="\033[1;32m"
@@ -11,40 +11,25 @@ c_magenta="\033[1;35m"
c_cyan="\033[1;36m"
c_reset="\033[0m"
#function to download full video/audio
full(){
[ -z "$2" ] &&
yt-dlp -o "$HOME/Videos/%(title)s.%(ext)s" "$1" ||
yt-dlp -f 'ba' -x --audio-format mp3 "$1" -o "$HOME/Music/%(title)s.%(ext)s"
}
# function to download part of a video/audio..
part(){
video=$1
printf "${c_magenta}Enter Start Point(hh:mm:ss)or(mm:ss)${c_reset}:"
printf "${c_magenta}Enter Starting Point(hh:mm:ss)or(mm:ss)${c_reset}:"
read start
printf "${c_yellow}Enter End Point(hh:mm:ss)or(mm:ss):${c_cyan}"
read end
[ -z "$2" ] &&
ffmpeg -i $(yt-dlp -f b --get-url "$video") -ss $start -to $end "$HOME/Videos/$(date +%s).mp4" ||
ffmpeg -i $(yt-dlp -f 'ba' --get-url "$video") -ss $start -t $end -map a -q:a 0 "$HOME/Music/$(date +%s).mp3"
printf "${c_yellow}Enter Upto Seconds:${c_cyan}"
read dur
ffmpeg -loglevel error -stats -i $(yt-dlp -f "$3" --get-url "$1") -ss $start -t $dur /sdcard/$(date +%s).$2
}
#program starts from here..
x=$(wl-paste)
printf "${c_blue}Youtube link :${c_magenta}$x\n"
printf "${c_yellow}Download>>\n${c_blue}[a]udio only\n${c_magenta}[f]part of Audio only\n${c_green}[v]ideo\n${c_cyan}[p]art of video\n${c_red}[q]uit"
x=$(termux-clipboard-get)
[ "$1" = "v" ] && yt-dlp "$x" -o "/sdcard/%(title)s.%(ext)s" && termux-notification -c "video downloaded" && exit 0
printf "\n${c_blue} video link :${c_magenta}$x\n"
printf "${c_yellow}Download>>\n${c_blue}[a]Audio only\n${c_magenta}[f]part of Audio only\n${c_green}[v]Full video\n${c_cyan}[p]Part of video\n${c_red}[q]Quit"
printf "\n${c_reset}Enter choice:${c_green}"
read choice
case $choice in
a)
full "$x" "1" && notify-send "Audio saved to Music Directory" || notify-send -u critical "Error!!! Audio not Downloaded";;
f)
part "$x" "1" && notify-send "Audio saved to Music Directory" || notify-send -u critical "Error!!! Audio not Downloaded";;
v)
full "$x" && notify-send "Video saved to Videos Directory" || notify-send -u critical "Error!!! Video not Downloaded";;
p)
part "$x" && notify-send "Video saved to Videos Directory" || notify-send -u critical "Error!!! Video not Downloaded";;
q)
break;;
a) yt-dlp -f 'ba' -x --audio-format mp3 "$x" -o "/sdcard/%(title)s.%(ext)s" && termux-notification -c "audio downloaded";;
f) part "$x" "mp3" "ba" && termux-notification -c "audio downloaded";;
v) yt-dlp "$x" -o "/sdcard/%(title)s.%(ext)s" && termux-notification -c "video downloaded";;
p) part "$x" "mp4" "b" && termux-notification -c "video downloaded";;
q) exit 0;;
esac