diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index f5f9ea78..841df0d1 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -678,24 +678,20 @@
@@ -2558,7 +2554,7 @@ initConfigCheckbox("#use_waffles"); initConfigCheckbox("#use_rutracker"); initConfigCheckbox("#use_apollo"); - initConfigCheckbox("#use_pth"); + initConfigCheckbox("#use_redacted"); initConfigCheckbox("#use_strike"); initConfigCheckbox("#api_enabled"); initConfigCheckbox("#enable_https"); diff --git a/headphones/config.py b/headphones/config.py index 07b6678f..57af4c16 100644 --- a/headphones/config.py +++ b/headphones/config.py @@ -306,11 +306,10 @@ _CONFIG_DEFINITIONS = { 'WAFFLES_PASSKEY': (str, 'Waffles', ''), 'WAFFLES_RATIO': (str, 'Waffles', ''), 'WAFFLES_UID': (str, 'Waffles', ''), - 'PTH': (int, 'PassTheHeadphones.me', 0), - 'PTH_PASSWORD': (str, 'PassTheHeadphones.me', ''), - 'PTH_RATIO': (str, 'PassTheHeadphones.me', ''), - 'PTH_USERNAME': (str, 'PassTheHeadphones.me', ''), - 'PTH_URL': (str, 'PassTheHeadphones.me', 'https://passtheheadphones.me'), + 'REDACTED': (int, 'Redacted', 0), + 'REDACTED_USERNAME': (str, 'Redacted', ''), + 'REDACTED_PASSWORD': (str, 'Redacted', ''), + 'REDACTED_RATIO': (str, 'Redacted', ''), 'XBMC_ENABLED': (int, 'XBMC', 0), 'XBMC_HOST': (str, 'XBMC', ''), 'XBMC_NOTIFY': (int, 'XBMC', 0), diff --git a/headphones/searcher.py b/headphones/searcher.py index eddf54c0..d2a6565f 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -47,9 +47,9 @@ TORRENT_TO_MAGNET_SERVICES = [ # Persistent Apollo.rip API object apolloobj = None -# Persistent PTH API object ruobj = None -pthobj = None +# Persistent RED API object +redobj = None def fix_url(s, charset="utf-8"): @@ -164,8 +164,8 @@ def get_seed_ratio(provider): seed_ratio = headphones.CONFIG.KAT_RATIO elif provider == 'Apollo.rip': seed_ratio = headphones.CONFIG.APOLLO_RATIO - elif provider == 'PassTheHeadphones.Me': - seed_ratio = headphones.CONFIG.PTH_RATIO + elif provider == 'Redacted': + seed_ratio = headphones.CONFIG.REDACTED_RATIO elif provider == 'The Pirate Bay': seed_ratio = headphones.CONFIG.PIRATEBAY_RATIO elif provider == 'Old Pirate Bay': @@ -277,7 +277,7 @@ def do_sorted_search(album, new, losslessOnly, choose_specific_download=False): headphones.CONFIG.WAFFLES or headphones.CONFIG.RUTRACKER or headphones.CONFIG.APOLLO or - headphones.CONFIG.PTH or + headphones.CONFIG.REDACTED or headphones.CONFIG.STRIKE or headphones.CONFIG.TQUATTRECENTONZE) @@ -1206,7 +1206,7 @@ def verifyresult(title, artistterm, term, lossless): def searchTorrent(album, new=False, losslessOnly=False, albumlength=None, choose_specific_download=False): global apolloobj # persistent apollo.rip api object to reduce number of login attempts - global pthobj # persistent pth api object to reduce number of login attempts + global redobj # persistent redacted api object to reduce number of login attempts global ruobj # and rutracker reldate = album['ReleaseDate'] @@ -1613,10 +1613,10 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None, provider, 'torrent', True)) - # PassTheHeadphones.me - Using same logic as What.CD as it's also Gazelle, so should really make this into something reusable - if headphones.CONFIG.PTH: - provider = "PassTheHeadphones.me" - providerurl = "https://passtheheadphones.me/" + # Redacted - Using same logic as What.CD as it's also Gazelle, so should really make this into something reusable + if headphones.CONFIG.REDACTED: + provider = "Redacted" + providerurl = "https://redacted.ch" bitrate = None bitrate_string = bitrate @@ -1639,7 +1639,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None, bitrate_string = encoding_string if bitrate_string not in gazelleencoding.ALL_ENCODINGS: logger.info( - u"Your preferred bitrate is not one of the available PTH filters, so not using it as a search parameter.") + u"Your preferred bitrate is not one of the available RED filters, so not using it as a search parameter.") maxsize = 10000000000 elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless: # Highest quality including lossless search_formats = [gazelleformat.FLAC, gazelleformat.MP3] @@ -1648,28 +1648,28 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None, search_formats = [gazelleformat.MP3] maxsize = 300000000 - if not pthobj or not pthobj.logged_in(): + if not redobj or not redobj.logged_in(): try: - logger.info(u"Attempting to log in to PassTheHeadphones.me...") - pthobj = gazelleapi.GazelleAPI(headphones.CONFIG.PTH_USERNAME, - headphones.CONFIG.PTH_PASSWORD, - headphones.CONFIG.PTH_URL) - pthobj._login() + logger.info(u"Attempting to log in to Redacted...") + redobj = gazelleapi.GazelleAPI(headphones.CONFIG.REDACTED_USERNAME, + headphones.CONFIG.REDACTED_PASSWORD, + providerurl) + redobj._login() except Exception as e: - pthobj = None - logger.error(u"PassTheHeadphones credentials incorrect or site is down. Error: %s %s" % ( + redobj = None + logger.error(u"Redacted credentials incorrect or site is down. Error: %s %s" % ( e.__class__.__name__, str(e))) - if pthobj and pthobj.logged_in(): + if redobj and redobj.logged_in(): logger.info(u"Searching %s..." % provider) all_torrents = [] for search_format in search_formats: if usersearchterm: all_torrents.extend( - pthobj.search_torrents(searchstr=usersearchterm, format=search_format, + redobj.search_torrents(searchstr=usersearchterm, format=search_format, encoding=bitrate_string)['results']) else: - all_torrents.extend(pthobj.search_torrents(artistname=semi_clean_artist_term, + all_torrents.extend(redobj.search_torrents(artistname=semi_clean_artist_term, groupname=semi_clean_album_term, format=search_format, encoding=bitrate_string)['results']) @@ -1709,7 +1709,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None, torrent.group.update_group_data() # will load the file_path for the individual torrents resultlist.append((torrent.file_path, torrent.size, - pthobj.generate_torrent_link(torrent.id), + redobj.generate_torrent_link(torrent.id), provider, 'torrent', True)) @@ -2056,7 +2056,7 @@ def preprocess(resultlist): headers['User-Agent'] = USER_AGENT elif result[3] == 'Apollo.rip': headers['User-Agent'] = 'Headphones' - elif result[3] == 'PassTheHeadphones.me': + elif result[3] == 'Redacted': headers['User-Agent'] = 'Headphones' elif result[3] == "The Pirate Bay" or result[3] == "Old Pirate Bay": headers[ diff --git a/headphones/webserve.py b/headphones/webserve.py index 742b6767..41c5776c 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1234,11 +1234,10 @@ class WebInterface(object): "apollo_password": headphones.CONFIG.APOLLO_PASSWORD, "apollo_ratio": headphones.CONFIG.APOLLO_RATIO, "apollo_url": headphones.CONFIG.APOLLO_URL, - "use_pth": checked(headphones.CONFIG.PTH), - "pth_username": headphones.CONFIG.PTH_USERNAME, - "pth_password": headphones.CONFIG.PTH_PASSWORD, - "pth_ratio": headphones.CONFIG.PTH_RATIO, - "pth_url": headphones.CONFIG.PTH_URL, + "use_redacted": checked(headphones.CONFIG.REDACTED), + "redacted_username": headphones.CONFIG.REDACTED_USERNAME, + "redacted_password": headphones.CONFIG.REDACTED_PASSWORD, + "redacted_ratio": headphones.CONFIG.REDACTED_RATIO, "use_strike": checked(headphones.CONFIG.STRIKE), "strike_ratio": headphones.CONFIG.STRIKE_RATIO, "use_tquattrecentonze": checked(headphones.CONFIG.TQUATTRECENTONZE), diff --git a/lib/pygazelle/api.py b/lib/pygazelle/api.py index 92aac04e..29f5aa8d 100644 --- a/lib/pygazelle/api.py +++ b/lib/pygazelle/api.py @@ -11,6 +11,7 @@ import sys import json import time import requests as requests +import headphones from .user import User from .artist import Artist @@ -32,9 +33,7 @@ class GazelleAPI(object): default_headers = { 'Connection': 'keep-alive', 'Cache-Control': 'max-age=0', - 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3)'\ - 'AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79'\ - 'Safari/535.11', + 'User-Agent': 'Headphones/%s' % headphones.CURRENT_VERSION, 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9'\ ',*/*;q=0.8', 'Accept-Encoding': 'gzip,deflate,sdch',