Created
August 4, 2011 14:59
-
-
Save jrave/1125360 to your computer and use it in GitHub Desktop.
Quick and Dirty script to automate some stuff for the itunes festival streams
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
import urllib2 | |
import re | |
url = '' | |
host='http://streaming.itunesfestival.com' | |
def get_token(): | |
sub = url.find('?token=') | |
return url[sub:] | |
def get_stream_dir(): | |
response = urllib2.urlopen(url) | |
data = response.read() | |
data = data.splitlines() | |
for line in data: | |
match = re.match(r'/auth/\w+/vod/\w+/r2/',line) | |
if match: | |
return line | |
def get_sequence_files(stream_dir, token): | |
urlstr = host + stream_dir + token | |
response = urllib2.urlopen(urlstr) | |
data = response.read() | |
return data.splitlines() | |
def prepare_download_file(buffer,token): | |
out = open('out.txt','w') | |
for line in buffer: | |
line = line.rstrip() | |
if not line.startswith('#'): | |
str = host + line + token + '\n' | |
out.write(str) | |
def main(): | |
token = get_token() | |
dir = get_stream_dir() | |
buf = get_sequence_files(dir,token) | |
prepare_download_file(buf, token) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment