Last active
June 7, 2024 13:38
-
-
Save guidocella/0ca7777158747290742aa444db6da256 to your computer and use it in GitHub Desktop.
Download videos from avgle.com
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
#!/bin/sh | |
if [ $# -lt 2 ]; then | |
echo Usage: avgle-download.sh video_title url_of_last_segment | |
exit 1 | |
fi | |
# Visit a video page, open the network tab of the dev tools, | |
# seek to the end of the video and copy the url of the last .ts segment | |
# (the .m3u8 playlist is encoded and therefore harder to get). | |
curl --remote-name --output-dir /tmp --referer https://avgle.com $(echo $2 | sed -E 's/seg-([0-9]*)/seg-[1-\1]/') && | |
ffmpeg -i concat:$(ls -tr /tmp/*.ts | paste -sd '|') -c copy "$1.mp4" && | |
rm /tmp/*.ts |
not good at shell command. but author's code not working in my mac. if any one have the same issue my my code can help.
- save my code as run.sh
- put run.sh in some folder.ex: /Users/$YOUR_USER_NAME$/Downloads/tmp
- cd into the folder (as curl --output-dir not working in my mac)
- confirm you have already install ffmpeg, if not use
brew install ffmpeg
install it. - first time run the shell need call
chmod +x run.sh
#!/bin/sh
if [ $# -lt 2 ]; then
echo Usage: avgle-download.sh video_title url_of_last_segment
exit 1
fi
# Visit a video page, open the network tab of the dev tools,
# seek to the end of the video and copy the url of the last .ts segment
# (the .m3u8 playlist is encoded and therefore harder to get).
curl --remote-name --referer https://avgle.com $(echo $2 | sed -E 's/seg-([0-9]*)/seg-[1-\1]/')
ls *.ts | sed 's/^\([^0-9]*\)\([0-9]*\)/\1 \2/' | sort -k2,2n | tr -d ' ' |
while read f; do
echo "file '$f'" >> mylist.txt
done
ffmpeg -f concat -safe 0 -i mylist.txt -c copy $1.mp4
rm mylist.txt
rm *.ts
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, \1 is the backreference to the first capture group, which is the number of the last segment [0-9]*. So curl sees something https://foo/seg-[1-70].ts which it interprets as downloading everything from 1 to 70. This is documented at the very start of
man curl
.