Created
March 7, 2020 02:08
-
-
Save dwisiswant0/3b5f91078f646fb73d2f3148f958bc80 to your computer and use it in GitHub Desktop.
metOwn - meTube Video Downloader
This file contains 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 | |
OUTPUT="$(pwd)" | |
TARGET=$(curl -s $1) | |
VIDEO_ID=$(echo "$TARGET" | grep -Eo '"video_id":[0-9]+' | sed 's/[^0-9]*//g') | |
TITLE=$(echo "$TARGET" | grep -Eo '<title>(.+)</title>' | sed 's/\///g; s/<title>//g' | sed 's/meTube.id - //') | |
INDEX=$(echo "$TARGET" | grep -Eo '"video_source":"(.+).m3u8' | sed 's/"//g; s/video_source//g' | cut -c2-) | |
CDN=$(echo "$INDEX" | sed 's/index.m3u8//') | |
LIST=($(curl -s "$INDEX" | sed '/^#/d')) | |
echo -e "Title: $TITLE\n" | |
echo "Choose video quality: " | |
a=1 | |
for l in "${LIST[@]}"; do echo "$a. $(dirname $l)"; let a+=1; done | |
read -p "> " QUALITY | |
echo | |
mkdir -p "/tmp/${VIDEO_ID}" | |
cd "/tmp/${VIDEO_ID}" | |
echo -n "Downloading list stream." | |
echo -e " OK!\n" | |
((QUALITY = QUALITY - 1)) | |
curl -s "${CDN}${LIST[$QUALITY]}" -O | |
SEGMENTS=($(cat "/tmp/${VIDEO_ID}/$(basename ${LIST[$QUALITY]})" | sed '/^#/d')) | |
echo -n "Downloading stream files." | |
for ts in "${SEGMENTS[@]}"; do curl -s "$(dirname ${CDN}${LIST[$QUALITY]})/${ts}" -O; echo -n "."; done | |
echo -e " OK!\n" | |
echo -e "\nCompiling all stream to mp4" | |
ffmpeg -i "$(basename ${LIST[$QUALITY]})" -codec copy -bsf:a aac_adtstoasc "${OUTPUT}/$(echo ${TITLE} | sed 's/ /_/g').mp4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment