-
-
Save SavSanta/6109e5dfb51eceea9688fbd59095d75d to your computer and use it in GitHub Desktop.
vkontakte_m3u8_downloader.sh
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/sh | |
# VKontakte *m3u8 downloader | |
# Worked at the time of writing | |
mkdir /tmp/m3u8 | |
set -e -x | |
cd /tmp/m3u8 | |
rm * | |
# Download m3u8. | |
url=$1 | |
urldir=`dirname $url` | |
wget $url -O index.m3u8 | |
# Download first key into 'key.pub'. We expect it is the only key used. | |
keyurl=`sed -n 's@.*\(https.*key.pub\).*@\1@ p' index.m3u8 | head -n 1` | |
wget $keyurl | |
# Replace http urls with local file names | |
# Download ts segments | |
cat index.m3u8 | \ | |
sed 's@"https.*pub?.*"@key.pub@g' | \ | |
sed 's@ts?.*@ts@g' >index_local.m3u8 | |
for line in `cat index_local.m3u8 | grep -v '^#'` ; do | |
wget `dirname $url`/$line | |
done | |
# Concat and decrypt ts-segments with ffmpeg, which understands local filesystem paths | |
ffmpeg -allowed_extensions 'ALL' -protocol_whitelist 'crypto,file' -i index_local.m3u8 -c copy out.ts | |
# Go grab the output | |
echo "`pwd`/out.ts" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment