Created
January 22, 2023 15:05
-
-
Save choonkeat/104626b2bc13d72738daf60b51da5d86 to your computer and use it in GitHub Desktop.
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
#!/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