Last active
May 27, 2017 15:05
-
-
Save devx00/50e02031b6c4fc43fc5aceebb779aaaf to your computer and use it in GitHub Desktop.
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
#! /usr/bin/python | |
# | |
# This is a script for OSX to allow users to easily watch LiveEdu livestreams | |
# from their favorite streamers. Be sure to change the vlcLocation variable if | |
# if necessary before running. | |
# | |
# Requires rtmpdump and VLC | |
# | |
# May require 'chmod +x watch_liveedu.py' before first use. | |
# | |
# Usage: ./watch_liveedu.py [streamers_username] | |
import urllib, json, requests, subprocess, sys | |
vlcLocation = '/Applications/VLC.app' | |
userURL = "https://www.liveedu.tv/api/v2/users/" | |
script_name = sys.argv[0] | |
helpInfo = "Usage: " + script_name + " user \n\n " + script_name + " requires:\n\n rtmpdump (see google, or 'brew install rtmpdump') \n\n vlc (recommended build https://nightlies.videolan.org/build/macosx-intel/vlc-3.0.0-20160619-2251/vlc-3.0.0-20160619-2251-git.dmg) \n\n Make sure to edit this script and change the 'vlcLocation' variable to point to the version of vlc you wish to use.\n\n" | |
if len(sys.argv) <= 1: | |
print helpInfo | |
sys.exit() | |
else: | |
mainArg = sys.argv[1] | |
if mainArg == 'help' or mainArg == '-h': | |
print helpInfo | |
sys.exit() | |
else: | |
user = mainArg | |
req = requests | |
session = req.Session() | |
session.get('http://liveedu.tv/') | |
url = userURL + user + "/" | |
response = session.get(url) | |
#print response.text | |
data = json.loads(response.text) | |
active_project = data['active_project'] | |
streamdataURL = active_project + "livestream/" | |
response = session.get(streamdataURL) | |
streamData = json.loads(response.text) | |
streamURLs = streamData['viewing_urls']['urls'] | |
for streamURL in streamURLs: | |
if streamURL['type'] == 'rtmp/mp4': | |
stream = streamURL['src'] | |
dump = subprocess.Popen(('rtmpdump', '-v', '-r', stream), stdout=subprocess.PIPE) | |
vlc = subprocess.Popen((vlcLocation + '/Contents/MacOS/VLC', '-'), stdin=dump.stdout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment