add split feature for SNS

This commit is contained in:
CoolnsX
2021-08-27 19:13:23 +05:30
parent 6669adb3b8
commit ceb4f1194c
2 changed files with 20 additions and 4 deletions

View File

@@ -181,7 +181,7 @@ open_episode () {
case $video_url in case $video_url in
*streamtape*) *streamtape*)
# If direct download not available then scrape streamtape.com # If direct download not available then scrape streamtape.com
BROWSER=${BROWSER:-firefox} BROWSER=${BROWSER:-google-chrome-stable}
printf "scraping streamtape.com\n" printf "scraping streamtape.com\n"
video_url=$(curl -s "$video_url" | sed -n -E ' video_url=$(curl -s "$video_url" | sed -n -E '
/^<script>document/{ /^<script>document/{
@@ -198,6 +198,7 @@ open_episode () {
" "$logfile" > "${logfile}.new" && mv "${logfile}.new" "$logfile" " "$logfile" > "${logfile}.new" && mv "${logfile}.new" "$logfile"
setsid -f $player_fn "$video_url" >/dev/null 2>&1 setsid -f $player_fn "$video_url" >/dev/null 2>&1
printf "$video_url\n"
else else
printf "Downloading episode $episode ...\n" printf "Downloading episode $episode ...\n"
printf "%s\n" "$video_url" printf "%s\n" "$video_url"
@@ -219,6 +220,7 @@ open_episode () {
trap "printf '$c_reset'" INT HUP trap "printf '$c_reset'" INT HUP
dep_ch "$player_fn" "curl" "sed" "grep" dep_ch "$player_fn" "curl" "sed" "grep"
alias v="nvim"
# option parsing # option parsing
is_download=0 is_download=0

18
youtube
View File

@@ -1,5 +1,8 @@
#!/bin/sh #!/bin/sh
# script for downloading youtube videos and split it into pieces..
# defining shell colors for distinction
c_red="\033[1;31m" c_red="\033[1;31m"
c_green="\033[1;32m" c_green="\033[1;32m"
c_yellow="\033[1;33m" c_yellow="\033[1;33m"
@@ -8,7 +11,7 @@ c_magenta="\033[1;35m"
c_cyan="\033[1;36m" c_cyan="\033[1;36m"
c_reset="\033[0m" c_reset="\033[0m"
#function to download full video
full_video() full_video()
{ {
video=$1 video=$1
@@ -16,6 +19,7 @@ full_video()
} }
# function to download part of a video and also split it for SNS...
part_video() part_video()
{ {
video=$1 video=$1
@@ -23,9 +27,19 @@ part_video()
read start read start
printf "${c_yellow}Enter Upto Seconds:${c_cyan}" printf "${c_yellow}Enter Upto Seconds:${c_cyan}"
read dur read dur
ffmpeg -i $(youtube-dl -f best --get-url "$video") -ss $start -t $dur $HOME/Videos/$(date +%s).mp4 printf "Do you want to split video for SNS?? (y or n) :"
read x
if [ $x == 'n' ]; then
ffmpeg -i $(youtube-dl -f best --get-url "$video") -ss $start -t $dur $HOME/Videos/$(date +%T_%F).mp4
else
out=$(date +%T_%F)
ffmpeg -i $(youtube-dl -f best --get-url "$video") -map 0 -codec copy -f segment -segment_time 30 -ss $start -t $dur $HOME/Videos/${out}_%03d.mp4
fi
} }
#program starts from here..
printf "${c_blue}Input Youtube link :${c_magenta}" printf "${c_blue}Input Youtube link :${c_magenta}"
read x read x
printf "${c_yellow}Download>>\n${c_green}[f]Full video\n${c_cyan}[p]Part of video\n${c_red}[q]Quit" printf "${c_yellow}Download>>\n${c_green}[f]Full video\n${c_cyan}[p]Part of video\n${c_red}[q]Quit"