def download_torrent(url, path, settings): from base import save_hashes save_hashes(path) url = url.replace('details.php', 'download.php') if not 'passkey' in url: url += '&passkey=' + settings.hdclub_passkey try: import shutil response = urllib2.urlopen(real_url(url)) with filesystem.fopen(path, 'wb') as f: shutil.copyfileobj(response, f) save_hashes(path) return True except BaseException as e: print_tb(e) return False
def download_torrent(url, path, settings): from base import save_hashes save_hashes(path) url = urllib2.unquote(url) debug('download_torrent:' + url) s = get_session(settings) page = s.get(url) #debug(page.text.encode('utf-8')) soup = BeautifulSoup(page.text, 'html.parser') try: a = soup.select_one('#tv720 div.torrent_h a') except TypeError: a = None try: if a is None: a = soup.select_one('div.torrent_h > a') except TypeError: a = None if a is not None: href = 'https://tr.anidub.com' + a['href'] debug(s.headers) r = s.get(href, headers={'Referer': url}) debug(r.headers) if 'Content-Type' in r.headers: if not 'torrent' in r.headers['Content-Type']: return False try: with filesystem.fopen(path, 'wb') as torr: for chunk in r.iter_content(100000): torr.write(chunk) save_hashes(path) return True except: pass return False
def download_torrent(url, path, settings): from base import save_hashes save_hashes(path) import shutil url = urllib2.unquote(url) debug('download_torrent:' + url) href = None link = None # find_direct_link(url, settings) if link is None: s = create_session(settings) page = s.get(url) # debug(page.text.encode('cp1251')) soup = BeautifulSoup(clean_html(page.text), 'html.parser') a = soup.select('td.gensmall > span.genmed > b > a') if len(a) > 0: href = 'http://nnm-club.me/forum/' + a[0]['href'] else: href = linkd response = urllib2.urlopen(real_url(link, settings)) #CHUNK = 256 * 1024 with filesystem.fopen(path, 'wb') as f: shutil.copyfileobj(response, f) save_hashes(path) return True #r = requests.head(link) #debug(r.headers) #return False if href: def make_req(): if link: return requests.get(real_url(link, settings), verify=False) else: return s.get(href, headers={'Referer': real_url(url, settings)}) try: r = make_req() if not r.ok and r.status_code == 502: import time time.sleep(1) r = make_req() if 'Content-Type' in r.headers: if not 'torrent' in r.headers['Content-Type']: return False with filesystem.fopen(path, 'wb') as torr: for chunk in r.iter_content(100000): torr.write(chunk) save_hashes(path) return True except: pass return False
def download_torrent(url, path, settings): from base import save_hashes save_hashes(path) url = urllib2.unquote(url) debug('download_torrent:' + url) page = requests.get(real_url(url, settings)) soup = BeautifulSoup(clean_html(page.text), 'html.parser') a = soup.select('#download > a') if len(a) > 1: link = a[1]['href'] else: link = None if link: r = requests.get(real_url(link, settings)) debug(r.headers) if 'Content-Type' in r.headers: if not 'torrent' in r.headers['Content-Type']: return False try: with filesystem.fopen(path, 'wb') as torr: for chunk in r.iter_content(100000): torr.write(chunk) save_hashes(path) return True except: pass return False
def download_torrent(url, path, settings): if not settings.bluebird_passkey: settings.bluebird_passkey = get_passkey(settings) if not settings.bluebird_passkey: return False from base import save_hashes save_hashes(path) url = url.replace('details.php', 'download.php') if not 'passkey' in url: url += '&passkey=' + settings.bluebird_passkey try: response = urllib2.urlopen(real_url(url)) data = response.read() if not data.startswith('d8:'): return False with filesystem.fopen(path, 'wb') as f: f.write(data) save_hashes(path) return True except BaseException as e: print_tb(e) return False
def download_torrent(url, path, settings): from base import save_hashes save_hashes(path) import urllib2 url = urllib2.unquote(url) debug('download_torrent:' + url) soup = soup_base(url).soup if soup: # <button onclick="window.document.location.href='/engine/torrent.php?nid=8280&id=10977'" class="bytn" style="cursor: pointer;" title="скачивание работает с программой Utorrent"> Скачать</button> btn = soup.find('button', class_="bytn") if btn: try: dnl_url = btn['onclick'] dnl_url = dnl_url.split("href=")[-1] dnl_url = dnl_url.replace("'", "") dnl_url = '{}://{}{}'.format(protocol, domain, dnl_url) except BaseException as e: pass import requests r = requests.get(dnl_url) try: import filesystem with filesystem.fopen(path, 'wb') as torr: for chunk in r.iter_content(100000): torr.write(chunk) save_hashes(path) return True except: pass return False