Last active
May 18, 2020 09:29
-
-
Save kappuccino/1d579e08843772c9adc66f3804199efb to your computer and use it in GitHub Desktop.
Download pluzz
This file contains hidden or 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
#!/usr/bin/env bash | |
cd "$(dirname "$0")" | |
echo "Hello hacker !" | |
if [ ! -f ./index.m3u ]; then | |
echo "😬 File index.m3u not found" | |
exit | |
fi | |
# Clean | |
rm -f "./final.ts" | |
rm -rf "./tmp" | |
mkdir "./tmp" | |
# Get all the URLS | |
URLS=`cat ./index.m3u | grep "https://"` | |
URLS=`cat ./index.m3u | grep "https://" | head -n 30` | |
TOTAL=$(echo -n "$URLS" | grep -c '^') | |
# Download them all | |
VIDEO=1 | |
cd ./tmp | |
for URL in $URLS | |
do | |
#echo "📦 $URL" | |
echo "Download video #$VIDEO/$TOTAL..." | |
curl -s "$URL" --output ./segment_$VIDEO.ts | |
let VIDEO=VIDEO+1 | |
done | |
# Prepare list of files for ffmpeg like: file1|file2|files3|...filesN | |
FILES=$(ls -hatr1 ./*.ts | perl -0pe 's/\n/|/g;s/\|$//g') | |
# Merge all tmp/*.ts to final.ts in current folder | |
ffmpeg -i "concat:$FILES" -c copy final.ts | |
# Clean | |
mv ./final.ts ../ | |
cd ../ | |
#rm -rf ./tmp | |
echo "😎 Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment