def play_movie(self, url): """Play a movie from a given url.""" html = download_page(url) #grab the docid in order to construct the google video url m = re.search('googleplayer.swf\?docid=(.+?)&', html) #visit the google video page and parse out the download link url = 'http://video.google.com/videoplay?docid=%s' % m.group(1) html = download_page(url) m = re.search("download_url:'(.+?)'", html) #replace escaped speical chars with actual character url = re.sub(r'\\x3d', '=', m.group(1)) url = re.sub(r'\\x26', '&', url) self.play_video(url)
def get_genres(self, url): """Return the available genres from the homepage.""" html = download_page(url) ul_tags = BS(html, parseOnlyThese=SS('ul', {'class': 'menu'})) dirs = [{'name': a.span.string, 'url': urljoin(self.base_url, a['href'] + '&limit=0'), 'mode': '1'} for a in ul_tags.findAll('a')] self.add_dirs(dirs)
def get_movies(self, url): """Return the available movies from a genre page.""" html = download_page(url) parse_trs = SS('tr', {'class': re.compile('sectiontableentry')}) tr_tags = BS(html, parseOnlyThese=parse_trs) dirs = [{'name': tag.td.text + '. ' + tag.a.text, 'url': urljoin(self.base_url, tag.a['href']), 'mode': '2'} for tag in tr_tags] self.add_dirs(dirs)