def __getattr__(self, name): if not self.__wrappee: # fetch wrappee br = newBrowser(self.__url) br.select_form("watch_form") url = br.submit().geturl() self.__wrappee = handlers.wrap(url) return getattr(self.__wrappee, name)
def stream(self): # open the first page br = newBrowser(self._url) # push the big red button br.select_form(nr=1) br.submit() # now it gets ugly html = br.response().read() url = re.search(r"file: \"([^\"]+)\"", html).group(1) return urllib.urlopen(url)