mirror of
https://github.com/rembo10/headphones.git
synced 2026-04-04 20:19:27 +01:00
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:
@@ -686,6 +686,10 @@
|
||||
<label>Seed Ratio</label>
|
||||
<input type="text" class="override-float" name="redacted_ratio" value="${config['redacted_ratio']}" size="10" title="Stop seeding when ratio met, 0 = unlimited. Scheduled job will remove torrent when post processed and finished seeding">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Use freeleech tokens when available</label>
|
||||
<input type="checkbox" name="redacted_use_fltoken" value="1" ${config['redacted_use_fltoken']}>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
|
||||
@@ -309,6 +309,7 @@ _CONFIG_DEFINITIONS = {
|
||||
'REDACTED_USERNAME': (str, 'Redacted', ''),
|
||||
'REDACTED_PASSWORD': (str, 'Redacted', ''),
|
||||
'REDACTED_RATIO': (str, 'Redacted', ''),
|
||||
'REDACTED_USE_FLTOKEN': (int, 'Redacted', 0),
|
||||
'XBMC_ENABLED': (int, 'XBMC', 0),
|
||||
'XBMC_HOST': (str, 'XBMC', ''),
|
||||
'XBMC_NOTIFY': (int, 'XBMC', 0),
|
||||
|
||||
@@ -1691,9 +1691,10 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None,
|
||||
for torrent in match_torrents:
|
||||
if not torrent.file_path:
|
||||
torrent.group.update_group_data() # will load the file_path for the individual torrents
|
||||
use_token = headphones.CONFIG.REDACTED_USE_FLTOKEN and torrent.can_use_token
|
||||
resultlist.append((torrent.file_path,
|
||||
torrent.size,
|
||||
redobj.generate_torrent_link(torrent.id),
|
||||
redobj.generate_torrent_link(torrent.id, use_token),
|
||||
provider,
|
||||
'torrent', True))
|
||||
|
||||
@@ -1914,8 +1915,9 @@ def preprocess(resultlist):
|
||||
if result[3] == 'rutracker.org':
|
||||
return ruobj.get_torrent_data(result[2]), result
|
||||
|
||||
# Get out of here if we're using Transmission
|
||||
if headphones.CONFIG.TORRENT_DOWNLOADER == 1: # if not a magnet link still need the .torrent to generate hash... uTorrent support labeling
|
||||
# Get out of here if we're using Transmission or Deluge
|
||||
# if not a magnet link still need the .torrent to generate hash... uTorrent support labeling
|
||||
if headphones.CONFIG.TORRENT_DOWNLOADER in [1, 3]:
|
||||
return True, result
|
||||
# Get out of here if it's a magnet link
|
||||
if result[2].lower().startswith("magnet:"):
|
||||
|
||||
@@ -1255,6 +1255,7 @@ class WebInterface(object):
|
||||
"redacted_username": headphones.CONFIG.REDACTED_USERNAME,
|
||||
"redacted_password": headphones.CONFIG.REDACTED_PASSWORD,
|
||||
"redacted_ratio": headphones.CONFIG.REDACTED_RATIO,
|
||||
"redacted_use_fltoken": checked(headphones.CONFIG.REDACTED_USE_FLTOKEN),
|
||||
"pref_qual_0": radio(headphones.CONFIG.PREFERRED_QUALITY, 0),
|
||||
"pref_qual_1": radio(headphones.CONFIG.PREFERRED_QUALITY, 1),
|
||||
"pref_qual_2": radio(headphones.CONFIG.PREFERRED_QUALITY, 2),
|
||||
@@ -1463,7 +1464,7 @@ class WebInterface(object):
|
||||
"use_newznab", "newznab_enabled", "use_torznab", "torznab_enabled",
|
||||
"use_nzbsorg", "use_omgwtfnzbs", "use_piratebay", "use_oldpiratebay",
|
||||
"use_mininova", "use_waffles", "use_rutracker",
|
||||
"use_orpheus", "use_redacted", "preferred_bitrate_allow_lossless",
|
||||
"use_orpheus", "use_redacted", "redacted_use_fltoken", "preferred_bitrate_allow_lossless",
|
||||
"detect_bitrate", "ignore_clean_releases", "freeze_db", "cue_split", "move_files",
|
||||
"rename_files", "correct_metadata", "cleanup_files", "keep_nfo", "add_album_art",
|
||||
"embed_album_art", "embed_lyrics",
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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']:
|
||||
|
||||
Reference in New Issue
Block a user