Skip to content

Instantly share code, notes, and snippets.

@guidocella
Last active June 7, 2024 13:38
Show Gist options
  • Save guidocella/0ca7777158747290742aa444db6da256 to your computer and use it in GitHub Desktop.
Save guidocella/0ca7777158747290742aa444db6da256 to your computer and use it in GitHub Desktop.
Download videos from avgle.com
#!/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
@Tunied
Copy link

Tunied commented Nov 2, 2021

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