def main(): search_terms = sys.argv[1:] if not search_terms: print_usage(basename(sys.argv[0])) sys.exit(1) show_link = search(' '.join(search_terms)) episode_link = select(get_tree(show_link)) data = get_table(episode_link) try_hosts(data)
def search(name): name = name.replace(' ', '+') root = get_tree('{}{}'.format(SEARCH_BASE, name)) show_list = get_list(root) if not show_list: print 'No search results.' sys.exit(1) elif len(show_list) == 1: return show_list[0].link else: return choose(show_list)
def process_sockshare_ws(hoster, url): root = get_tree(url) try: filehash = root.xpath('//input[@name="hash"]')[0].attrib['value'] except IndexError: return None payload = { 'hash': filehash, 'agreeButton': 'Continue as Free User', } data = post(url=url, data=payload) root = html.fromstring(data) return root.xpath('//a[@id="player"]')[0].attrib['href']
def get_table(url): links = defaultdict(set) root = get_tree(url) for elem in root.xpath('//table'): rows = elem.xpath('tbody/tr') for row in rows: try: hoster, link = get_info(row) links[hoster].add(link) except TypeError: pass return links
def process_putlocker_com(hoster, url): root = get_tree(url) try: filehash = root.xpath('//input[@name="hash"]')[0].attrib['value'] except IndexError: return None payload = { 'hash': filehash, 'confirm': 'Continue as Free User', } data = post(url=url, data=payload) root = html.fromstring(data) remote_file = root.xpath( '//a[@class="download_file_link"]' )[0].attrib['href'] return 'http://www.{}{}'.format(hoster, remote_file)
def process_gorillavid_in(hoster, url): root = get_tree(url) try: ident = root.xpath('//form/input[@name="id"]')[0].attrib['value'] except IndexError: return None payload = { 'op': 'download1', 'usr_login': '', 'channel': '', 'method_free': 'Kostenloser Download', 'id': ident, } data = post(url=url, data=payload) for line in data.split('\n'): if 'file: "' in line: line = re.sub(r'^.*file: "', '', line) return re.sub(r'",.*$', '', line) return None