Redacted: use a FL token when available

- Use a FL token when available
- Added a configuration (default off) to enable the feature
- Skip prefetching the data with Deluge as with Transmission in
`preprocess()`

- Note: because QBittorrent & uTorrent need the data to compute the
torrenthash but still require the url to download the file, it will
result in 2 FL tokens used instead of one because the .torrent will be
downloaded twice from the server.

Fixes #3163
This commit is contained in:
Hypsometric
2018-11-30 17:03:05 +01:00
parent 4b52ae445d
commit f66a37abbd
6 changed files with 19 additions and 9 deletions
+6 -5
View File
@@ -401,14 +401,15 @@ class GazelleAPI(object):
return {'curr_page': curr_page, 'pages': pages, 'results': matching_torrents}
def generate_torrent_link(self, id):
url = "%storrents.php?action=download&id=%s&authkey=%s&torrent_pass=%s" %\
(self.site, id, self.logged_in_user.authkey, self.logged_in_user.passkey)
def generate_torrent_link(self, id, use_token=False):
url = "%storrents.php?action=download&id=%s&authkey=%s&torrent_pass=%s&usetoken=%d" %\
(self.site, id, self.logged_in_user.authkey, self.logged_in_user.passkey, use_token)
return url
def save_torrent_file(self, id, dest):
def save_torrent_file(self, id, dest, use_token=False):
file_data = self.unparsed_request("torrents.php", 'download',
id=id, authkey=self.logged_in_user.authkey, torrent_pass=self.logged_in_user.passkey)
id=id, authkey=self.logged_in_user.authkey, torrent_pass=self.logged_in_user.passkey,
usetoken=int(use_token))
with open(dest, 'w+') as dest_file:
dest_file.write(file_data)
+1
View File
@@ -152,6 +152,7 @@ class Torrent(object):
self.snatched = search_torrent_json_response['snatches']
self.free_torrent = search_torrent_json_response['isFreeleech'] or search_torrent_json_response['isPersonalFreeleech']
self.time = search_torrent_json_response['time']
self.can_use_token = search_torrent_json_response.get('canUseToken', False)
def set_torrent_top_10_data(self, top_10_json_response):
if self.id != top_10_json_response['torrentId']: