Last active
March 29, 2022 14:39
-
-
Save davit312/c1e3f0b600802bab37a2bbb847840242 to your computer and use it in GitHub Desktop.
5tv ալիքի ուղիղ եթերը ձայնագրող script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
prefix='https://live-5tvam.cdnvideo.ru/5tvam/5tvam/' | |
chunklistData=$(curl -s ${prefix}'playlist.m3u8') | |
declare -a chunks=('-', '-', '-') | |
appends=0 | |
targetTime=15 | |
out='out.ts' | |
for i in ${chunklistData}; do | |
if [[ $i == *'.m3u8'* ]]; then | |
chunkList=$i | |
fi | |
done | |
echo 'Chunk list url is:' | |
echo $chunkList | |
echo ':::::::::::::::::::::::::::::::::' | |
echo '::::::::::: Recording :::::::::::' | |
echo ':::::::::::::::::::::::::::::::::' | |
while true; do | |
startTime=$SECONDS | |
part=$(curl -s ${prefix}${chunkList}) | |
for p in $part; do | |
if [[ $p == *'.ts?hls_proxy'* ]] &&\ | |
[[ ${chunks[-1]} != $p ]] &&\ | |
[[ ${chunks[-2]} != $p ]] &&\ | |
[[ ${chunks[-3]} != $p ]]; then | |
curl -s ${prefix}${p} >> $out | |
chunks+=($p) | |
((appends=appends+1)) | |
echo 'Chunk index: ' $appends | |
if [[ $((appends / 50)) -gt 0 ]] && [[ $((appends % 50)) -eq 0 ]]; then | |
declare -a chunks=${chunks:-1:9} | |
echo ': : :::::::::::::: Memory clean ::::::::::::::: : : :' | |
fi | |
fi | |
done | |
endTime=$SECONDS | |
remindTime=$(expr $endTime - $startTime) | |
waitTime=$(expr $targetTime - $remindTime) | |
echo -n '-- Sleep '; printf "%3s" ${waitTime}; echo ' second --' | |
if [[ $waitTime -ge 0 ]]; then | |
sleep $waitTime | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment