From 2e2ba30fd4f75b0499112cf9124ba90cac9b7f45 Mon Sep 17 00:00:00 2001 From: mewlabs Date: Fri, 23 Dec 2022 19:02:03 +0200 Subject: [PATCH] save temporary m3u8 file with different filename it will allow to download several files at the same time --- download-hls.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/download-hls.sh b/download-hls.sh index 5654b8c..6221024 100755 --- a/download-hls.sh +++ b/download-hls.sh @@ -1,6 +1,6 @@ #!/bin/bash -if [ -z $1 ] +if [ -z $1 ] then echo "usage: download-hls URL [name to save]" exit 1 @@ -19,15 +19,15 @@ echo "Save file to $filename" status="begin" count=1 url="$1" -curl "$url" > temp.m3u8 -cat temp.m3u8 | \ +curl "$url" > $filename.m3u8 +cat $filename.m3u8 | \ while read line; do if [[ $line == \#EXTINF* ]] then status="reading" continue fi - + if [[ $status == "reading" ]] then curl -s --show-error "${line}" >> "$filename" @@ -36,12 +36,12 @@ while read line; do let "count += 1" continue fi - + if [[ $line == "#EXT-X-ENDLIST" ]] then status="done" echo "Download finished" - rm temp.m3u8 + rm $filename.m3u8 exit 0 fi -done \ No newline at end of file +done