feat: add m3u8 download script
continuous-integration/drone/push Build is passing Details

master
Evan Chen 2021-09-24 17:35:46 +08:00
parent adf5b2c60f
commit 467456e6e4
3 changed files with 21 additions and 7 deletions

View File

@ -20,13 +20,20 @@ function cleanup {
} }
# register the cleanup function to be called on the EXIT signal # register the cleanup function to be called on the EXIT signal
# trap cleanup EXIT trap cleanup EXIT
echo "請輸入m3u8網址: ( copy as cURL(bash) )" echo "請輸入m3u8網址: ( copy as cURL(bash) )"
read m3u8 read m3u8
echo
echo "請輸入其中一個ts的網址: ( copy as cURL(bash) )" echo "請輸入其中一個ts的網址: ( copy as cURL(bash) )"
read BASE read BASE
echo
echo "請輸入下載檔案名稱: (ex: video.mp4)"
read output
echo
echo "下載開始...."
m3u8="${m3u8} -o index.m3u8" m3u8="${m3u8} -o index.m3u8"
cd $WORK_DIR cd $WORK_DIR
@ -51,4 +58,4 @@ while read p; do
fi fi
done <index.m3u8 done <index.m3u8
ffmpeg -i "index.m3u8" -codec copy ../output.mp4 ffmpeg -i "index.m3u8" -codec copy ../$output

View File

@ -1,4 +1,4 @@
base="curl 'https://vod.live.eplus.jp/out/v1/f69369f0004d4e30a93381c0f9cf5c5c/76b6cf49f18ca1445cbd28b3f950733e/index_4_3847.ts' \ BASE="curl 'https://vod.live.eplus.jp/out/v1/f69369f0004d4e30a93381c0f9cf5c5c/76b6cf49f18ca1445cbd28b3f950733e/index_4_3847.ts' \
-H 'authority: vod.live.eplus.jp' \ -H 'authority: vod.live.eplus.jp' \
-H 'pragma: no-cache' \ -H 'pragma: no-cache' \
-H 'cache-control: no-cache' \ -H 'cache-control: no-cache' \
@ -16,18 +16,24 @@ base="curl 'https://vod.live.eplus.jp/out/v1/f69369f0004d4e30a93381c0f9cf5c5c/76
-H 'cookie: CloudFront-Key-Pair-Id=XXX; CloudFront-Policy=XXX; CloudFront-Signature=XXX%XXX-XX-XX__; KOJIN_SHIKIBETSU=1234; MEMBER_ID=1234; TODOFUKEN_CODE=13; _ga=GA1.2.00.00; _gid=GA1.2.000.00; _gat_UA-44492173-17=1; _gat_gtag_UA_44492173_17=1' \ -H 'cookie: CloudFront-Key-Pair-Id=XXX; CloudFront-Policy=XXX; CloudFront-Signature=XXX%XXX-XX-XX__; KOJIN_SHIKIBETSU=1234; MEMBER_ID=1234; TODOFUKEN_CODE=13; _ga=GA1.2.00.00; _gid=GA1.2.000.00; _gat_UA-44492173-17=1; _gat_gtag_UA_44492173_17=1' \
--compressed" --compressed"
origin=$(echo $base | sed -e "s/[^']*'\([^\?^']*\).*'.*/\1/" ) origin=$(echo $BASE | sed -e "s/[^']*'\([^\?^']*\).*'.*/\1/" )
file=${origin##*/} file=${origin##*/}
file=$(echo $file | sed 's/[\*\.\&\?]/\\&/g') file=$(echo $file | sed 's/[\*\.\&\?]/\\&/g')
p=test.ts p=test.ts
pp=$(echo $p | sed 's/[\*\.\&\?]/\\&/g') pp=$(echo $p | sed 's/[\*\.\&\?]/\\&/g')
ts=$(echo $base | sed -e "s,$file,$pp,") ts="$(echo $BASE | sed "s,$file,$pp,") -o $p -w '%{http_code}'"
echo base: $base echo base: $BASE
echo echo
echo origin: $origin echo origin: $origin
echo echo
echo file: $file echo file: $file
echo echo
echo command: $ts echo command: $ts
status_code=$(eval " $ts")
echo
echo status_code: $status_code

1
m3u8下載/test.ts Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidKey</Code><Message>Unknown Key</Message></Error>