Dec 05
Here is a quick and dirty python script to download Stage6 videos.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #!/usr/bin/env python # -*- Python -*- import urllib, sgmllib, sys, string, os, time, re class MyParser(sgmllib.SGMLParser): def parse(self, s): self.feed(s) self.close() def __init__(self, verbose=0): sgmllib.SGMLParser.__init__(self, verbose) self.hyperlinks = [] self.inside_a_element = 0 def start_input(self, attributes): found = False for name, value in attributes: if name == "onclick": found = True continue if found == True and name == "value": self.hyperlinks.append(value) self.inside_a_element = 1 def end_input(self): self.inside_a_element = 0 def get_data(self): return self.hyperlinks[0] class AppURLopener(urllib.FancyURLopener): def __init__(self, *args): self.version = "Lynx" urllib.FancyURLopener.__init__(self, *args) urllib._urlopener = AppURLopener() try: url = sys.argv[1] except IndexError: print "Usage:", sys.argv[0], "URL" sys.exit(1) f = urllib.urlopen(url) s = f.read() myparser = MyParser() myparser.parse(s) data = myparser.get_data() p = re.compile(".*(http://video.stage6.com/.*/.divx).*") try: m = p.match(data) video_url = m.group(1) except AttributeError: print "Video not found >_<" sys.exit(1) def hook(*a): print '%s: %s' % (fn, a) fn = os.path.basename(url) + ".avi" print url, "->", fn urllib.urlretrieve(video_url, fn, hook) |
To use it:
$ ./stage6.py http://www.stage6.com/user/Rudimc/video/1907059/Iaido---Batto---Takeda-Ryu-Tameshigiri


