i modified the code. search is faster. no more files in directory. immediately stop after found replay url.
usage: calclive.sh video-id (variables #2 and #3 are optional)
output:
-nothing if no replay was found
-message if video is more than 3 months old
-url replay
note:
i could not test this code maybe webside_len need to be redefined. In next version i have to add error checks (curl: Could not resolve host).
maybe someone will convert this to windows batch.
Code:
#!/bin/bash
liveme_video_id=$1
count_variable=$2; if [ "$count_variable" = "" ]; then count_variable=120 ; fi
curltimeout=$3; if [ "$curltimeout" = "" ]; then curltimeout=10 ; fi
liveme_unixtime=${liveme_video_id::10}
liveme_unixtime_plus8=$(expr $liveme_unixtime + 28800)
liveme_video_date_plus8=$( date -u -d @$liveme_unixtime_plus8 +%Y%m%d%H%M%S )
datecheck=$[$(date +%s)-$liveme_unixtime]
if (( datecheck > 8000000))
then
echo "Video-ID more than 3 months old"
exit
fi
if (( liveme_unixtime < 1630986656 ))
then
loop_counter=1
while [ $loop_counter -lt $count_variable ]; do
dlurl=$(expr $liveme_unixtime - 1 + $loop_counter)
url100=$( date -u -d @$dlurl +%Y%m%d%H%M%S )
webside_variable=$(curl -s "http://record.linkv.fun/oc/yolo-"$liveme_video_id"--"$url100".m3u8" -m$curltimeout)
webside_len=`expr length "$webside_variable"`
if (( webside_len > 1000 ))
then
echo "http://record.linkv.fun/oc/yolo-"$liveme_video_id"--"$url100".m3u8"
loop_counter=$count_variable
fi
loop_counter=$[$loop_counter+1]
done
else
loop_counter=1
while [ $loop_counter -lt $count_variable ]; do
dlurl=$(expr $liveme_unixtime_plus8 - 10 + $loop_counter)
url100=$( date -u -d @$dlurl +%Y%m%d%H%M%S )
webside_variable=$(curl -s "http://vod.oc.linkv.fun/yolo-"$liveme_video_id"--"$url100".m3u8" -m$curltimeout)
webside_len=`expr length "$webside_variable"`
if (( webside_len > 1000 ))
then
echo "http://vod.oc.linkv.fun/yolo-"$liveme_video_id"--"$url100".m3u8"
loop_counter=$count_variable
fi
loop_counter=$[$loop_counter+1]
done
fi