29 lines
785 B
Python
29 lines
785 B
Python
from typing import Optional
|
|
|
|
from ..settings import option
|
|
import requests
|
|
|
|
|
|
def torrent_file_fetch(url, referer, cookies):
|
|
headers = {
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) '
|
|
'Chrome/37.0.2062.124 YaBrowser/14.10.2062.12061 Safari/537.36',
|
|
'Referer': referer
|
|
}
|
|
|
|
resp = requests.get(url, cookies=cookies, headers=headers, proxies=proxies())
|
|
if resp.ok:
|
|
return resp.content
|
|
else:
|
|
return None
|
|
|
|
|
|
def proxies():
|
|
if option.get_boolean('use_socks'):
|
|
return {
|
|
'http': f'socks5://{option["socks_ip"]}:{option["socks_port"]}',
|
|
'https': f'socks5://{option["socks_ip"]}:{option["socks_port"]}'
|
|
}
|
|
else:
|
|
return None
|