Added headers in torrent API requests

This commit is contained in:
Fabio Manganiello 2019-09-02 01:10:22 +02:00
parent 7bf4284f7b
commit 86d38b421a

View file

@ -37,6 +37,9 @@ class TorrentPlugin(Plugin):
torrent_state = {} torrent_state = {}
transfers = {} transfers = {}
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36'
}
def __init__(self, download_dir=None, torrent_ports=None, **kwargs): def __init__(self, download_dir=None, torrent_ports=None, **kwargs):
""" """
@ -118,7 +121,7 @@ class TorrentPlugin(Plugin):
'https://movies-v2.api-fetch.website/movies/1?' + urllib.parse.urlencode({ 'https://movies-v2.api-fetch.website/movies/1?' + urllib.parse.urlencode({
'sort': 'relevance', 'sort': 'relevance',
'keywords': query, 'keywords': query,
}) }), headers=self.headers
)) ))
response = json.loads(request.read().decode('utf-8')) response = json.loads(request.read().decode('utf-8'))
@ -151,7 +154,7 @@ class TorrentPlugin(Plugin):
'https://tv-v2.api-fetch.website/shows/1?' + urllib.parse.urlencode({ 'https://tv-v2.api-fetch.website/shows/1?' + urllib.parse.urlencode({
'sort': 'relevance', 'sort': 'relevance',
'keywords': query, 'keywords': query,
}) }), headers=self.headers
)) ))
results = [] results = []
@ -159,7 +162,8 @@ class TorrentPlugin(Plugin):
for show in shows: for show in shows:
request = urllib.request.urlopen(urllib.request.Request( request = urllib.request.urlopen(urllib.request.Request(
'https://tv-v2.api-fetch.website/show/' + show.get('_id'))) 'https://tv-v2.api-fetch.website/show/' + show.get('_id')),
headers=self.headers)
show = json.loads(request.read().decode('utf-8')) show = json.loads(request.read().decode('utf-8'))
@ -200,7 +204,7 @@ class TorrentPlugin(Plugin):
'https://anime.api-fetch.website/animes/1?' + urllib.parse.urlencode({ 'https://anime.api-fetch.website/animes/1?' + urllib.parse.urlencode({
'sort': 'relevance', 'sort': 'relevance',
'keywords': query, 'keywords': query,
}) }), headers=self.headers
)) ))
results = [] results = []
@ -208,7 +212,8 @@ class TorrentPlugin(Plugin):
for show in shows: for show in shows:
request = urllib.request.urlopen(urllib.request.Request( request = urllib.request.urlopen(urllib.request.Request(
'https://anime.api-fetch.website/anime/' + show.get('_id'))) 'https://anime.api-fetch.website/anime/' + show.get('_id')),
headers=self.headers)
show = json.loads(request.read().decode('utf-8')) show = json.loads(request.read().decode('utf-8'))