Skip to content

Instantly share code, notes, and snippets.

@choonkeat
Created January 22, 2023 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choonkeat/104626b2bc13d72738daf60b51da5d86 to your computer and use it in GitHub Desktop.
Save choonkeat/104626b2bc13d72738daf60b51da5d86 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
#
#
# `m3u8.txt` contains urls returned by `https://www.dandanzan.com/url.php`
# you can get them from your browser's network tab, look for `url.php`,
# copy the response body, and paste into your `m3u8.txt` file
#
#
i=0
cat m3u8.txt | while read url
do
i=$((i+1))
echo starting $i
mkdir -p "slamdunk-${i}"
cd "slamdunk-${i}"
if test -f index.txt
then
echo cached index.txt
else
echo GET $url
curl $url > index.txt
fi
newpath=`cat index.txt | grep .m3u8`
if test -f fsfiles.txt
then
echo cached fsfiles.txt
else
curl "${url}/../${newpath}" | egrep '.ts$' > fsfiles.txt
fi
cat fsfiles.txt | while read tsfile
do
filename=`basename $tsfile`
if test -f $filename
then
echo cached $filename
else
case $tsfile in
https://*)
echo GET $tsfile
wget --wait=30 --tries=5 "${tsfile}"
;;
*)
echo GET "${url}/../${newpath}/../${tsfile}"
wget --wait=30 --tries=5 "${url}/../${newpath}/../${tsfile}"
;;
esac
fi
done
# if test -f all.ts
# then
# echo cached all.ts
# else
# echo *.ts
# cat *.ts > all.ts # videos have the same prefix, advertisements have different prefix, should exclude advertisements
# fi
# if test -f all.mp4
# then
# echo cached all.mp4
# else
# time ffmpeg -i all.ts -acodec copy -vcodec copy all.mp4
# ls -lat all.mp4
# fi
cd -
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment