mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-24 05:39:27 +00:00
Merge remote-tracking branch 'NovaXeros/master' into develop
Conflicts: headphones/searcher.py headphones/webserve.py
This commit is contained in:
@@ -672,6 +672,19 @@
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<h3>LMS</h3>
|
||||
<div class="checkbox row">
|
||||
<input type="checkbox" name="lms_enabled" id="lms" value="1" ${config['lms_enabled']} /><label>Enable Squeezebox Updates</label>
|
||||
</div>
|
||||
<div id="lmsoptions">
|
||||
<div class="row">
|
||||
<label>LMS Host:Port</label>
|
||||
<input type="text" name="lms_host" value="${config['lms_host']}" size="30">
|
||||
<small>e.g. http://localhost:9000. Seperate hosts with commas</small>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</td>
|
||||
<td>
|
||||
<fieldset>
|
||||
@@ -1300,6 +1313,26 @@
|
||||
}
|
||||
});
|
||||
|
||||
if ($("#lms").is(":checked"))
|
||||
{
|
||||
$("#lmsoptions").show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#lmsoptions").hide();
|
||||
}
|
||||
|
||||
$("#lms").click(function(){
|
||||
if ($("#lms").is(":checked"))
|
||||
{
|
||||
$("#lmsoptions").slideDown();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#lmsoptions").slideUp();
|
||||
}
|
||||
});
|
||||
|
||||
if ($("#plex").is(":checked"))
|
||||
{
|
||||
$("#plexoptions").show();
|
||||
|
||||
@@ -238,6 +238,8 @@ XBMC_USERNAME = None
|
||||
XBMC_PASSWORD = None
|
||||
XBMC_UPDATE = False
|
||||
XBMC_NOTIFY = False
|
||||
LMS_ENABLED = False
|
||||
LMS_HOST = None
|
||||
PLEX_ENABLED = False
|
||||
PLEX_SERVER_HOST = None
|
||||
PLEX_CLIENT_HOST = None
|
||||
@@ -349,7 +351,7 @@ def initialize():
|
||||
TWITTER_ENABLED, TWITTER_ONSNATCH, TWITTER_USERNAME, TWITTER_PASSWORD, TWITTER_PREFIX, \
|
||||
PUSHBULLET_ENABLED, PUSHBULLET_APIKEY, PUSHBULLET_DEVICEID, PUSHBULLET_ONSNATCH, \
|
||||
MIRROR, CUSTOMHOST, CUSTOMPORT, CUSTOMSLEEP, HPUSER, HPPASS, XBMC_ENABLED, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, XBMC_UPDATE, \
|
||||
XBMC_NOTIFY, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, NMA_ONSNATCH, SYNOINDEX_ENABLED, ALBUM_COMPLETION_PCT, PREFERRED_BITRATE_HIGH_BUFFER, \
|
||||
XBMC_NOTIFY, LMS_ENABLED, LMS_HOST, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, NMA_ONSNATCH, SYNOINDEX_ENABLED, ALBUM_COMPLETION_PCT, PREFERRED_BITRATE_HIGH_BUFFER, \
|
||||
PREFERRED_BITRATE_LOW_BUFFER, PREFERRED_BITRATE_ALLOW_LOSSLESS, CACHE_SIZEMB, JOURNAL_MODE, UMASK, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \
|
||||
PLEX_ENABLED, PLEX_SERVER_HOST, PLEX_CLIENT_HOST, PLEX_USERNAME, PLEX_PASSWORD, PLEX_UPDATE, PLEX_NOTIFY, PUSHALOT_ENABLED, PUSHALOT_APIKEY, \
|
||||
PUSHALOT_ONSNATCH, SONGKICK_ENABLED, SONGKICK_APIKEY, SONGKICK_LOCATION, SONGKICK_FILTER_ENABLED
|
||||
@@ -377,6 +379,7 @@ def initialize():
|
||||
CheckSection('Pushover')
|
||||
CheckSection('PushBullet')
|
||||
CheckSection('XBMC')
|
||||
CheckSection('LMS')
|
||||
CheckSection('Plex')
|
||||
CheckSection('NMA')
|
||||
CheckSection('Pushalot')
|
||||
@@ -566,6 +569,9 @@ def initialize():
|
||||
XBMC_UPDATE = bool(check_setting_int(CFG, 'XBMC', 'xbmc_update', 0))
|
||||
XBMC_NOTIFY = bool(check_setting_int(CFG, 'XBMC', 'xbmc_notify', 0))
|
||||
|
||||
LMS_ENABLED = bool(check_setting_int(CFG, 'LMS', 'lms_enabled', 0))
|
||||
LMS_HOST = check_setting_str(CFG, 'LMS', 'lms_host', '')
|
||||
|
||||
PLEX_ENABLED = bool(check_setting_int(CFG, 'Plex', 'plex_enabled', 0))
|
||||
PLEX_SERVER_HOST = check_setting_str(CFG, 'Plex', 'plex_server_host', '')
|
||||
PLEX_CLIENT_HOST = check_setting_str(CFG, 'Plex', 'plex_client_host', '')
|
||||
@@ -972,6 +978,10 @@ def config_write():
|
||||
new_config['XBMC']['xbmc_update'] = int(XBMC_UPDATE)
|
||||
new_config['XBMC']['xbmc_notify'] = int(XBMC_NOTIFY)
|
||||
|
||||
new_config['LMS'] = {}
|
||||
new_config['LMS']['lms_enabled'] = int(LMS_ENABLED)
|
||||
new_config['LMS']['lms_host'] = LMS_HOST
|
||||
|
||||
new_config['Plex'] = {}
|
||||
new_config['Plex']['plex_enabled'] = int(PLEX_ENABLED)
|
||||
new_config['Plex']['plex_server_host'] = PLEX_SERVER_HOST
|
||||
|
||||
@@ -238,6 +238,51 @@ class XBMC:
|
||||
|
||||
except:
|
||||
logger.warn('Error sending notification request to XBMC')
|
||||
class LMS:
|
||||
|
||||
#Class for updating a Logitech Media Server
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.hosts = headphones.LMS_HOST
|
||||
|
||||
def _sendjson(self, host):
|
||||
data = {'id': 1, 'method': 'slim.request', 'params': ["",["rescan"]]} #Had a lot of trouble with simplejson, but this works.
|
||||
data = simplejson.JSONEncoder().encode(data)
|
||||
|
||||
content = {'Content-Type': 'application/json', 'Content-Length': len(data)}
|
||||
|
||||
req = urllib2.Request(host+'/jsonrpc.js', data, content)
|
||||
|
||||
try:
|
||||
handle = urllib2.urlopen(req)
|
||||
except Exception, e:
|
||||
logger.warn('Error opening LMS url: %s' % e)
|
||||
return
|
||||
|
||||
response = simplejson.JSONDecoder().decode(handle.read())
|
||||
server_result = simplejson.dumps(response)
|
||||
|
||||
try:
|
||||
return response[0]['result']
|
||||
except:
|
||||
logger.warn('LMS returned error: %s' % response[0]['error'])
|
||||
return
|
||||
|
||||
def update(self):
|
||||
|
||||
#Send the ["rescan"] command to an LMS server.
|
||||
#Note that the command must be prefixed with the 'player' that the command is aimed at,
|
||||
#But with this being a request for the server to update its library, the player is blank, so ""
|
||||
|
||||
hosts = [x.strip() for x in self.hosts.split(',')]
|
||||
|
||||
for host in hosts:
|
||||
logger.info('Sending library rescan command to LMS @ '+host)
|
||||
request = self._sendjson(host)
|
||||
|
||||
if not request:
|
||||
logger.warn('Error sending rescan request to LMS')
|
||||
|
||||
class Plex:
|
||||
|
||||
|
||||
@@ -429,7 +429,11 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
||||
xbmc.update()
|
||||
if headphones.XBMC_NOTIFY:
|
||||
xbmc.notify(release['ArtistName'], release['AlbumTitle'], album_art_path)
|
||||
|
||||
|
||||
if headphones.LMS_ENABLED:
|
||||
lms = notifiers.LMS()
|
||||
lms.update()
|
||||
|
||||
if headphones.PLEX_ENABLED:
|
||||
plex = notifiers.Plex()
|
||||
if headphones.PLEX_UPDATE:
|
||||
|
||||
@@ -1117,6 +1117,7 @@ def searchTorrent(album, new=False, losslessOnly=False):
|
||||
# Requesting content
|
||||
logger.info('Parsing results from The Pirate Bay')
|
||||
|
||||
headers = { 'User-Agent' : 'Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19' }
|
||||
params = {
|
||||
"iht": "2",
|
||||
"sort": "seeds"
|
||||
@@ -1125,6 +1126,7 @@ def searchTorrent(album, new=False, losslessOnly=False):
|
||||
data = request.request_soup(
|
||||
url=providerurl + category,
|
||||
params=params,
|
||||
headers=headers,
|
||||
timeout=20
|
||||
)
|
||||
|
||||
|
||||
@@ -1026,6 +1026,8 @@ class WebInterface(object):
|
||||
"xbmc_password": headphones.XBMC_PASSWORD,
|
||||
"xbmc_update": checked(headphones.XBMC_UPDATE),
|
||||
"xbmc_notify": checked(headphones.XBMC_NOTIFY),
|
||||
"lms_enabled": checked(headphones.LMS_ENABLED),
|
||||
"lms_host": headphones.LMS_HOST,
|
||||
"plex_enabled": checked(headphones.PLEX_ENABLED),
|
||||
"plex_server_host": headphones.PLEX_SERVER_HOST,
|
||||
"plex_client_host": headphones.PLEX_CLIENT_HOST,
|
||||
@@ -1097,7 +1099,7 @@ class WebInterface(object):
|
||||
remix=0, spokenword=0, audiobook=0, other=0, autowant_upcoming=False, autowant_all=False, keep_torrent_files=False, prefer_torrents=0, interface=None, log_dir=None, cache_dir=None, music_encoder=0, encoder=None, xldprofile=None,
|
||||
bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0,
|
||||
delete_lossless_files=0, growl_enabled=0, growl_onsnatch=0, growl_host=None, growl_password=None, prowl_enabled=0, prowl_onsnatch=0, prowl_keys=None, prowl_priority=0, xbmc_enabled=0, xbmc_host=None, xbmc_username=None, xbmc_password=None,
|
||||
xbmc_update=0, xbmc_notify=0, nma_enabled=False, nma_apikey=None, nma_priority=0, nma_onsnatch=0, pushalot_enabled=False, pushalot_apikey=None, pushalot_onsnatch=0, synoindex_enabled=False,
|
||||
xbmc_update=0, xbmc_notify=0, nma_enabled=False, nma_apikey=None, nma_priority=0, nma_onsnatch=0, pushalot_enabled=False, pushalot_apikey=None, pushalot_onsnatch=0, synoindex_enabled=False, lms_enabled=0, lms_host=None,
|
||||
pushover_enabled=0, pushover_onsnatch=0, pushover_keys=None, pushover_priority=0, pushover_apitoken=None, pushbullet_enabled=0, pushbullet_onsnatch=0, pushbullet_apikey=None, pushbullet_deviceid=None, twitter_enabled=0, twitter_onsnatch=0, mirror=None, customhost=None, customport=None,
|
||||
customsleep=None, hpuser=None, hppass=None, preferred_bitrate_high_buffer=None, preferred_bitrate_low_buffer=None, preferred_bitrate_allow_lossless=0, cache_sizemb=None,
|
||||
enable_https=0, https_cert=None, https_key=None, file_permissions=None, folder_permissions=None, plex_enabled=0, plex_server_host=None, plex_client_host=None, plex_username=None,
|
||||
@@ -1228,6 +1230,8 @@ class WebInterface(object):
|
||||
headphones.XBMC_PASSWORD = xbmc_password
|
||||
headphones.XBMC_UPDATE = xbmc_update
|
||||
headphones.XBMC_NOTIFY = xbmc_notify
|
||||
headphones.LMS_ENABLED = lms_enabled
|
||||
headphones.LMS_HOST = lms_host
|
||||
headphones.PLEX_ENABLED = plex_enabled
|
||||
headphones.PLEX_SERVER_HOST = plex_server_host
|
||||
headphones.PLEX_CLIENT_HOST = plex_client_host
|
||||
|
||||
Reference in New Issue
Block a user