Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions download-hls.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

if [ -z $1 ]
if [ -z $1 ]
then
echo "usage: download-hls URL [name to save]"
exit 1
Expand All @@ -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"
Expand All @@ -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
done