Sunday, August 29, 2010

coding at Auckmageddon

Thanks to Vector and Orcon, A5 has a 1gbps internet connection which really craps on all the other LANs that have ever happened in NZ. We tried to come up with ways we could max it out and someone suggested trailers.apple.com. I was asked to come up with a script to parse the feeds for a list of 1080p trailer URLs we could feed into wget. This is what I came up with:


from urllib2 import urlopen
from BeautifulSoup import BeautifulSoup
from json import loads


urllist = []
for t in loads(urlopen("http://trailers.apple.com/trailers/home/feeds/just_added.json").read()):
    urllist.append(t['trailers'][0]['url'])


for u in map(lambda x: "http://trailers.apple.com/" + x, urllist):
    try:
        h = urlopen(u+"includes/playlists/web.inc").read()
        soup = BeautifulSoup(h)
        avail = soup.findAll("li", {"class":"trailer last"})[0].findAll("li", {"class":"hd"})
        print avail[-1].findChild("a").attrs[0][1]
    except:
        pass

It turns out that not all the trailers have corresponding HTTP urls to the .mov files - some are handled through ITMS for unknown reasons.

Anyway, we still havent managed to crack much more than 200mbit, and Soundie seems a little dissapointed.

No comments:

Post a Comment