-
-
Save dslusser/4c63a80d13888b517c4a to your computer and use it in GitHub Desktop.
Save Periscope Videos
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 | |
mkdir -v periscope; cd periscope; echo $PWD | |
TOKEN=${1##*/}; echo $TOKEN | |
curl -v "https://api.periscope.tv/api/v2/getAccessPublic?token=${TOKEN//=/%3D}" | json > periscope.json | |
M3U8=$(awk -F\" /replay/'{print $4}' periscope.json); echo $M3U8 | |
COOKIE="Cookie: $(awk -F'"' -v ORS="" /CloudFront/'{print $4"="; getline; print $4"; "}' periscope.json)" | |
curl -v -O -H "$COOKIE" "${M3U8}" | |
FIRST=$(awk -F'[_.]' '/chunk/{print $2;exit}' playlist.m3u8); echo chunk_$FIRST.ts | |
LAST=$(awk -F'[_.]' '/chunk/{num=$2}END{print num}' playlist.m3u8); echo chunk_$LAST.ts | |
curl -v -O -H "$COOKIE" "${M3U8%/*}/chunk_[$FIRST-$LAST].ts" | |
ffmpeg -v verbose -i playlist.m3u8 -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 periscope.mp4 | |
cp -v periscope.mp4 ..; cd ..; rm -frv periscope; file periscope.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment