Open JanoG2 opened 3 years ago
#!/usr/bin/env bash
# If link is empty exit
[ -z "$1" ] && echo "Link is empty" && exit
echo "Download page: "$1
# Extract number video from link for playlist
playlist_num=$(echo "$1" | cut -d '/' -f 7)
echo "Playlist:" $playlist_num
# Playlist link
playlist_link=https://www.rtvs.sk/json/archive5f.json?id=$playlist_num
echo "Download playlist: "$playlist_link
# Extract line with link to stream
stream_tmp="$(curl -s $playlist_link)"
stream_name=$(echo "${stream_tmp%x}" | grep "src\" :" | grep smil | head -1)
##
echo "Stream name:" $stream_name
stream_title=$(echo "${stream_tmp%x}" | grep "title")
echo "Stream title: "$stream_title
###
datetime_create=$(echo "${stream_tmp%x}" | grep "datetime_create")
datetime_create=$(echo "$datetime_create" | cut -d " " -f 9)
datetime_create=$(echo "$datetime_create" | sed 's/\",//g')
datetime_create=$(echo "$datetime_create" | sed 's/\"//g')
datetime_create=$(echo "$datetime_create" | sed 's/^\s//g')
datetime_create=$(echo "$datetime_create" | sed 's/\s/_/g')
###
# Stream link name to array
stream_name_array=($stream_name)
# Extract link and remove quotes and commas
stream_link=$(echo ${stream_name_array[2]} | sed 's/[\",]//g')
# Extract title
stream_title=$(echo "$stream_title" | cut -d ":" -f 2)
# Remove ", from end
stream_title=$(echo "$stream_title" | sed 's/\",//g')
# Remove quotes
stream_title=$(echo "$stream_title" | sed 's/\"//g')
# Trim
stream_title=$(echo "$stream_title" | sed 's/^\s//g')
# Replace space to underscore
stream_title=$(echo "$stream_title" | sed 's/\s/_/g')
echo "Download stream link: "$stream_link
# ffmpeg -i $stream_link -acodec mp3 -vcodec copy "${stream_title} ${datetime_create} (${playlist_num})".mkv
ffmpeg -i $stream_link -acodec mp3 -vf scale=-1:720 "${stream_title} ${datetime_create} (${playlist_num})".mp4
Zdravim,
na stranke RTVS sa pred cca 2 tyzdnami zmenil format archivu.
Po spusteni skriptu sa nevyparsuje link na video: Playlist: Download playlist: https: Stream name: Stream title: Download stream link:
Bolo by prosim mozne zabezpecit opravu?
Vopred dakujem. Jano