Skip to content

Instantly share code, notes, and snippets.

@noestreich
Forked from jrave/itunes_festival.py
Created August 4, 2011 15:07
Show Gist options
  • Save noestreich/1125380 to your computer and use it in GitHub Desktop.
Save noestreich/1125380 to your computer and use it in GitHub Desktop.
Quick and Dirty script to automate some stuff for the itunes festival streams
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