mirror of
https://github.com/rembo10/headphones.git
synced 2026-04-04 20:19:27 +01:00
Added Headphones Indexer
This commit is contained in:
@@ -208,6 +208,26 @@
|
||||
<tr>
|
||||
<td>
|
||||
<legend>NZBs</legend>
|
||||
<fieldset>
|
||||
<legend>Headphones Indexer</legend>
|
||||
<div class="row checkbox">
|
||||
<input id="use_headphones_indexer" type="checkbox" name="use_headphones_indexer" onclick="initConfigCheckbox($(this));" value="1" ${config['use_headphones_indexer']} /><label>Use Headphones Indexer</label>
|
||||
</div>
|
||||
<div class="config">
|
||||
<div class="row">
|
||||
<label>Username</label>
|
||||
<input class="hpuser" type="text" value="${config['hpuser']}" size="20">
|
||||
<small>Headphones VIP Server username & password</small>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Password</label>
|
||||
<input class="hppass" type="password" value="${config['hppass']}" size="20">
|
||||
</div>
|
||||
<div class="row">
|
||||
<a href="http://headphones.codeshy.com/vip" id="vipserver">Get an Account!</a>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Newznab</legend>
|
||||
<div class="row checkbox">
|
||||
@@ -801,10 +821,10 @@
|
||||
|
||||
<div id="hpserveroptions">
|
||||
<div class="row">
|
||||
<label>Username:</label><input type="text" name="hpuser" value="${config['hpuser']}" size="20">
|
||||
<label>Username:</label><input type="text" class="hpuser" name="hpuser" value="${config['hpuser']}" size="20">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Password:</label><input type="password" name="hppass" value="${config['hppass']}" size="15"><br>
|
||||
<label>Password:</label><input type="password" class="hppass" name="hppass" value="${config['hppass']}" size="15"><br>
|
||||
<a href="http://headphones.codeshy.com/vip" id="vipserver">Get an Account!</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1125,6 +1145,14 @@
|
||||
formfields.append("</div>");
|
||||
$("#add_newznab").before(formfields);
|
||||
});
|
||||
|
||||
$(".hpuser").keyup(function() {
|
||||
$(".hpuser").val($(this).val());
|
||||
});
|
||||
|
||||
$(".hppass").keyup(function() {
|
||||
$(".hppass").val($(this).val());
|
||||
});
|
||||
|
||||
$(function() {
|
||||
$( "#tabs" ).tabs();
|
||||
|
||||
@@ -136,6 +136,8 @@ NZBGET_PASSWORD = None
|
||||
NZBGET_CATEGORY = None
|
||||
NZBGET_HOST = None
|
||||
|
||||
HEADPHONES_INDEXER = False
|
||||
|
||||
NZBMATRIX = False
|
||||
NZBMATRIX_USERNAME = None
|
||||
NZBMATRIX_APIKEY = None
|
||||
@@ -291,7 +293,7 @@ def initialize():
|
||||
TORRENTBLACKHOLE_DIR, NUMBEROFSEEDERS, ISOHUNT, KAT, MININOVA, WAFFLES, WAFFLES_UID, WAFFLES_PASSKEY, \
|
||||
RUTRACKER, RUTRACKER_USER, RUTRACKER_PASSWORD, WHATCD, WHATCD_USERNAME, WHATCD_PASSWORD, DOWNLOAD_TORRENT_DIR, \
|
||||
LIBRARYSCAN, LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \
|
||||
NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_HOST, NZBMATRIX, NZBMATRIX_USERNAME, NZBMATRIX_APIKEY, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS, \
|
||||
NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_HOST, HEADPHONES_INDEXER, NZBMATRIX, NZBMATRIX_USERNAME, NZBMATRIX_APIKEY, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS, \
|
||||
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, NZBSRUS, NZBSRUS_UID, NZBSRUS_APIKEY, \
|
||||
NZB_DOWNLOADER, PREFERRED_WORDS, REQUIRED_WORDS, IGNORED_WORDS, \
|
||||
LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, ENCODERFOLDER, ENCODER_PATH, ENCODER, XLDPROFILE, BITRATE, SAMPLINGFREQUENCY, \
|
||||
@@ -309,6 +311,7 @@ def initialize():
|
||||
CheckSection('General')
|
||||
CheckSection('SABnzbd')
|
||||
CheckSection('NZBget')
|
||||
CheckSection('Headphones')
|
||||
CheckSection('NZBMatrix')
|
||||
CheckSection('Newznab')
|
||||
CheckSection('NZBsorg')
|
||||
@@ -419,6 +422,8 @@ def initialize():
|
||||
NZBGET_CATEGORY = check_setting_str(CFG, 'NZBget', 'nzbget_category', '')
|
||||
NZBGET_HOST = check_setting_str(CFG, 'NZBget', 'nzbget_host', '')
|
||||
|
||||
HEADPHONES_INDEXER = bool(check_setting_int(CFG, 'Headphones', 'headphones_indexer', 0))
|
||||
|
||||
NZBMATRIX = bool(check_setting_int(CFG, 'NZBMatrix', 'nzbmatrix', 0))
|
||||
NZBMATRIX_USERNAME = check_setting_str(CFG, 'NZBMatrix', 'nzbmatrix_username', '')
|
||||
NZBMATRIX_APIKEY = check_setting_str(CFG, 'NZBMatrix', 'nzbmatrix_apikey', '')
|
||||
@@ -555,6 +560,12 @@ def initialize():
|
||||
if BLACKHOLE:
|
||||
NZB_DOWNLOADER = 2
|
||||
CONFIG_VERSION = '4'
|
||||
|
||||
# Enable Headphones Indexer if they have a VIP account
|
||||
if CONFIG_VERSION == '4':
|
||||
if HPUSER and HPPASS:
|
||||
HEADPHONES_INDEXER = True
|
||||
CONFIG_VERSION = '5'
|
||||
|
||||
if not LOG_DIR:
|
||||
LOG_DIR = os.path.join(DATA_DIR, 'logs')
|
||||
@@ -764,6 +775,9 @@ def config_write():
|
||||
new_config['NZBget']['nzbget_password'] = NZBGET_PASSWORD
|
||||
new_config['NZBget']['nzbget_category'] = NZBGET_CATEGORY
|
||||
new_config['NZBget']['nzbget_host'] = NZBGET_HOST
|
||||
|
||||
new_config['Headphones'] = {}
|
||||
new_config['Headphones']['headphones_indexer'] = int(HEADPHONES_INDEXER)
|
||||
|
||||
new_config['NZBMatrix'] = {}
|
||||
new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
|
||||
|
||||
@@ -25,7 +25,7 @@ from xml.dom import minidom
|
||||
from xml.parsers.expat import ExpatError
|
||||
import lib.simplejson as json
|
||||
from StringIO import StringIO
|
||||
import gzip
|
||||
import gzip, base64
|
||||
|
||||
import os, re, time
|
||||
import string
|
||||
@@ -111,7 +111,7 @@ def searchforalbum(albumid=None, new=False, lossless=False):
|
||||
|
||||
for result in results:
|
||||
foundNZB = "none"
|
||||
if (headphones.NEWZNAB or headphones.NZBSORG or headphones.NZBSRUS) and (headphones.SAB_HOST or headphones.BLACKHOLE_DIR or headphones.NZBGET_HOST):
|
||||
if (headphones.HEADPHONES_INDEXER or headphones.NEWZNAB or headphones.NZBSORG or headphones.NZBSRUS) and (headphones.SAB_HOST or headphones.BLACKHOLE_DIR or headphones.NZBGET_HOST):
|
||||
if result['Status'] == "Wanted Lossless":
|
||||
foundNZB = searchNZB(result['AlbumID'], new, losslessOnly=True)
|
||||
else:
|
||||
@@ -127,7 +127,7 @@ def searchforalbum(albumid=None, new=False, lossless=False):
|
||||
else:
|
||||
|
||||
foundNZB = "none"
|
||||
if (headphones.NZBMATRIX or headphones.NEWZNAB or headphones.NZBSORG or headphones.NEWZBIN or headphones.NZBSRUS) and (headphones.SAB_HOST or headphones.BLACKHOLE_DIR or headphones.NZBGET_HOST):
|
||||
if (headphones.HEADPHONES_INDEXER or headphones.NEWZNAB or headphones.NZBSORG or headphones.NZBSRUS) and (headphones.SAB_HOST or headphones.BLACKHOLE_DIR or headphones.NZBGET_HOST):
|
||||
foundNZB = searchNZB(albumid, new, lossless)
|
||||
|
||||
if (headphones.KAT or headphones.ISOHUNT or headphones.MININOVA or headphones.WAFFLES or headphones.RUTRACKER or headphones.WHATCD) and foundNZB == "none":
|
||||
@@ -182,6 +182,66 @@ def searchNZB(albumid=None, new=False, losslessOnly=False):
|
||||
|
||||
resultlist = []
|
||||
|
||||
if headphones.HEADPHONES_INDEXER:
|
||||
|
||||
provider = "headphones"
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
categories = "3040"
|
||||
elif headphones.PREFERRED_QUALITY:
|
||||
categories = "3040,3010"
|
||||
else:
|
||||
categories = "3010"
|
||||
|
||||
if albums['Type'] == 'Other':
|
||||
categories = "3030"
|
||||
logger.info("Album type is audiobook/spokenword. Using audiobook category")
|
||||
|
||||
params = { "t": "search",
|
||||
"cat": categories,
|
||||
"apikey": '89edf227c1de9b3de50383fff11466c6',
|
||||
"maxage": headphones.USENET_RETENTION,
|
||||
"q": term
|
||||
}
|
||||
|
||||
searchURL = 'http://headphones.codeshy.com/newznab/api?' + urllib.urlencode(params)
|
||||
|
||||
# Add a user-agent
|
||||
request = urllib2.Request(searchURL)
|
||||
request.add_header('User-Agent', 'headphones/0.0 +https://github.com/rembo10/headphones')
|
||||
base64string = base64.encodestring('%s:%s' % (headphones.HPUSER, headphones.HPPASS)).replace('\n', '')
|
||||
request.add_header("Authorization", "Basic %s" % base64string)
|
||||
|
||||
opener = urllib2.build_opener()
|
||||
|
||||
logger.info(u'Parsing results from <a href="%s">%s</a>' % (searchURL, 'Headphones Index'))
|
||||
|
||||
try:
|
||||
data = opener.open(request).read()
|
||||
except Exception, e:
|
||||
logger.warn('Error fetching data from %s: %s' % ('Headphones Index', e))
|
||||
data = False
|
||||
|
||||
if data:
|
||||
|
||||
d = feedparser.parse(data)
|
||||
|
||||
if not len(d.entries):
|
||||
logger.info(u"No results found from %s for %s" % ('Headphones Index', term))
|
||||
pass
|
||||
|
||||
else:
|
||||
for item in d.entries:
|
||||
try:
|
||||
url = item.link
|
||||
title = item.title
|
||||
size = int(item.links[1]['length'])
|
||||
|
||||
resultlist.append((title, size, url, provider))
|
||||
logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
|
||||
|
||||
except Exception, e:
|
||||
logger.error(u"An unknown error occurred trying to parse the feed: %s" % e)
|
||||
|
||||
if headphones.NEWZNAB:
|
||||
|
||||
newznab_hosts = [(headphones.NEWZNAB_HOST, headphones.NEWZNAB_APIKEY, headphones.NEWZNAB_ENABLED)]
|
||||
|
||||
@@ -586,6 +586,7 @@ class WebInterface(object):
|
||||
"use_blackhole" : checked(headphones.BLACKHOLE),
|
||||
"blackhole_dir" : headphones.BLACKHOLE_DIR,
|
||||
"usenet_retention" : headphones.USENET_RETENTION,
|
||||
"use_headphones_indexer" : checked(headphones.HEADPHONES_INDEXER),
|
||||
"use_newznab" : checked(headphones.NEWZNAB),
|
||||
"newznab_host" : headphones.NEWZNAB_HOST,
|
||||
"newznab_api" : headphones.NEWZNAB_APIKEY,
|
||||
@@ -704,7 +705,8 @@ class WebInterface(object):
|
||||
|
||||
def configUpdate(self, http_host='0.0.0.0', http_username=None, http_port=8181, http_password=None, launch_browser=0, api_enabled=0, api_key=None,
|
||||
download_scan_interval=None, nzb_search_interval=None, libraryscan_interval=None, sab_host=None, sab_username=None, sab_apikey=None, sab_password=None,
|
||||
sab_category=None, nzbget_host=None, nzbget_username='nzbget', nzbget_password=None, nzbget_category=None, nzb_downloader=0, download_dir=None, blackhole=0, blackhole_dir=None, usenet_retention=None, newznab=0, newznab_host=None, newznab_apikey=None,
|
||||
sab_category=None, nzbget_host=None, nzbget_username='nzbget', nzbget_password=None, nzbget_category=None, nzb_downloader=0, download_dir=None, blackhole=0, blackhole_dir=None, usenet_retention=None,
|
||||
use_headphones_indexer=0,newznab=0, newznab_host=None, newznab_apikey=None,
|
||||
newznab_enabled=0, nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, nzbsrus=0, nzbsrus_uid=None, nzbsrus_apikey=None, preferred_words=None, required_words=None, ignored_words=None,
|
||||
preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0, torrentblackhole_dir=None, download_torrent_dir=None,
|
||||
numberofseeders=10, use_isohunt=0, use_kat=0, use_mininova=0, waffles=0, waffles_uid=None, waffles_passkey=None, whatcd=0, whatcd_username=None, whatcd_password=None,
|
||||
@@ -741,6 +743,7 @@ class WebInterface(object):
|
||||
headphones.BLACKHOLE = blackhole
|
||||
headphones.BLACKHOLE_DIR = blackhole_dir
|
||||
headphones.USENET_RETENTION = usenet_retention
|
||||
headphones.HEADPHONES_INDEXER = use_headphones_indexer
|
||||
headphones.NEWZNAB = newznab
|
||||
headphones.NEWZNAB_HOST = newznab_host
|
||||
headphones.NEWZNAB_APIKEY = newznab_apikey
|
||||
|
||||
Reference in New Issue
Block a user