Created
April 1, 2022 10:05
-
-
Save onesixromcom/649a2b7ff95a78a5125b3994fbaec7aa to your computer and use it in GitHub Desktop.
This script will download video from online video service website.
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/bash | |
| # This script will download video from online video service website. | |
| # sudo apt install html-xml-utils | |
| # Usage ./video-service-movie-download.sh https://somewhere-online-movie.web/best-movie.html | |
| if [ -z "$1" ]; then | |
| echo "No url supplied. Please set collection name. (ex: https://somewhere-online-movie.web/best-movie.html)" | |
| exit | |
| fi | |
| get_iframe_video_url() { | |
| echo $1 | | |
| wget -O- -i- --no-verbose | | |
| hxnormalize -x | | |
| hxselect -i "div.video-player-wrapper iframe" | | |
| hxwls | |
| } | |
| get_first_playlist() { | |
| echo $1 | | |
| wget -O- -i- --no-verbose | | |
| grep -E -o 'file:"(.*)m3u8' | | |
| sed -n 's/file:"//p' | |
| } | |
| get_second_playlist() { | |
| echo $1 | | |
| wget -O- -i- --no-verbose | | |
| grep -E -o 'file:"(.*)m3u8' | | |
| sed -n 's/file:"//p' | | |
| sed -n 's/index.m3u8/480\/index.m3u8/p' | |
| } | |
| get_video_uri() { | |
| echo $1 | | |
| wget -O- -i- --no-verbose | | |
| grep -E -o 'file:"(.*)m3u8' | | |
| sed -n 's/file:"//p' | | |
| sed -n 's/index.m3u8//p' | |
| } | |
| create_segments_file() { | |
| if test -f "$FILE_FFMPEG_LIST"; then | |
| rm $FILE_FFMPEG_LIST | |
| fi | |
| if test -f "$FILE_FFMPEG_LIST"; then | |
| rm $FILE_WGET_LIST | |
| fi | |
| # download movie playlist | |
| wget $VIDEO_URI/$QUALITY/index.m3u8 --output-document=pls.file --no-verbose | |
| LIST=$(grep segment pls.file) | |
| rm pls.file | |
| for f in $LIST; | |
| do | |
| echo "file '$DIRECTORY/$f'" >> $FILE_FFMPEG_LIST | |
| echo "$VIDEO_URI$QUALITY/$f" >> $FILE_WGET_LIST | |
| done | |
| echo "Saving files done." | |
| } | |
| get_directory_from_url() { | |
| echo $1 | sed 's#.*/##' | |
| } | |
| # 480, 720, 1080 | |
| QUALITY="480"; | |
| FILE_FFMPEG_LIST="./list-ffmpeg.txt" | |
| FILE_WGET_LIST="./list-wget.txt" | |
| URL="$1" | |
| DIRECTORY=$(get_directory_from_url $URL); | |
| DIRECTORY="${DIRECTORY%.*}" | |
| VIDEO_URL=$(get_iframe_video_url $URL) | |
| echo $VIDEO_URL; | |
| VIDEO_URI=$(get_video_uri $VIDEO_URL) | |
| echo $VIDEO_URI | |
| PLAYLIST="$VIDEO_URI/$QUALITY/index.m3u8" | |
| ffmpeg -i $PLAYLIST -c copy -bsf:a aac_adtstoasc "$DIRECTORY.mp4" -y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment