mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-21 20:29:27 +00:00
Rename PTH to Redacted and fix invalid User-Agent (Again)
This is a duplicate of albshin's PR as I got impatient waiting for him to submit it to the develop branch with the addition of removing the previous user agents and replacing them with Headphones as the agent. Redacted considers falsifying the agent as a bannable offence. From albshin's PR; "Changes all instances of PassTheHeadphones to Redacted. Removed the URL option for Redacted as it's unnecessary(?). Fixed a bug in the pyGazelle library in which the User-Agent was invalid due to a missing space. Should work now for Redacted."
This commit is contained in:
@@ -678,24 +678,20 @@
|
||||
|
||||
<fieldset>
|
||||
<div class="row checkbox left">
|
||||
<input id="use_pth" type="checkbox" class="bigcheck" name="use_pth" value="1" ${config['use_pth']} /><label for="use_pth"><span class="option">PassTheHeadphones.me</span></label>
|
||||
<input id="use_redacted" type="checkbox" class="bigcheck" name="use_redacted" value="1" ${config['use_redacted']} /><label for="use_redacted"><span class="option">Redacted</span></label>
|
||||
</div>
|
||||
<div class="config">
|
||||
<div class="row">
|
||||
<label>Username</label>
|
||||
<input type="text" name="pth_username" value="${config['pth_username']}" size="36">
|
||||
<input type="text" name="redacted_username" value="${config['redacted_username']}" size="36">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Password</label>
|
||||
<input type="password" name="pth_password" value="${config['pth_password'] | h}" size="36">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>URL</label>
|
||||
<input type="text" name="pth_url" value="${config['pth_url']}" size="36">
|
||||
<input type="password" name="redacted_password" value="${config['redacted_password'] | h}" size="36">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Seed Ratio</label>
|
||||
<input type="text" class="override-float" name="pth_ratio" value="${config['pth_ratio']}" size="10" title="Stop seeding when ratio met, 0 = unlimited. Scheduled job will remove torrent when post processed and finished seeding">
|
||||
<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>
|
||||
</fieldset>
|
||||
@@ -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");
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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[
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user