Add support for Subsonic library update. Fixes #1864

This commit is contained in:
Bas Stottelaar
2014-09-15 01:29:40 +02:00
parent 638baf564d
commit f4b13533ce
5 changed files with 88 additions and 3 deletions

View File

@@ -822,8 +822,26 @@
</div>
</fieldset>
<fieldset>
<h3>Subsonic</h3>
<div class="row checkbox">
<input type="checkbox" name="subsonic_enabled" id="subsonic" value="1" ${config['subsonic_enabled']} /><label>Enable Subsonic Updates</label>
</div>
<div id="subsonicoptions">
<div class="row">
<label>Subsonic URL</label><input type="text" name="subsonic_host" value="${config['subsonic_host']}" size="30">
</div>
<div class="row">
<label>Subsonic Username</label><input type="text" name="subsonic_username" value="${config['subsonic_username']}" size="30">
</div>
<div class="row">
<label>Subsonic Password</label><input type="password" name="subsonic_password" value="${config['subsonic_password']}" size="30">
</div>
</div>
</fieldset>
</td>
<td>
<td>
<fieldset>
<h3>Synology NAS</h3>
@@ -1658,6 +1676,26 @@
}
});
if ($("#subsonic").is(":checked"))
{
$("#subsonicoptions").show();
}
else
{
$("#subsonicoptions").hide();
}
$("#subsonic").click(function(){
if ($("#subsonic").is(":checked"))
{
$("#subsonicoptions").slideDown();
}
else
{
$("#subsonicoptions").slideUp();
}
});
if ($("#songkick").is(":checked"))
{
$("#songkickoptions").show();

View File

@@ -283,6 +283,10 @@ OSX_NOTIFY_APP = None
BOXCAR_ENABLED = False
BOXCAR_ONSNATCH = False
BOXCAR_TOKEN = None
SUBSONIC_ENABLED = False
SUBSONIC_HOST = None
SUBSONIC_USERNAME = None
SUBSONIC_PASSWORD = None
MIRRORLIST = ["musicbrainz.org","headphones","custom"]
MIRROR = None
CUSTOMHOST = None
@@ -371,7 +375,7 @@ def initialize():
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, LOSSLESS_BITRATE_FROM, LOSSLESS_BITRATE_TO, 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, VERIFY_SSL_CERT
PUSHALOT_ONSNATCH, SONGKICK_ENABLED, SONGKICK_APIKEY, SONGKICK_LOCATION, SONGKICK_FILTER_ENABLED, SUBSONIC_ENABLED, SUBSONIC_HOST, SUBSONIC_USERNAME, SUBSONIC_PASSWORD, VERIFY_SSL_CERT
if __INITIALIZED__:
@@ -627,6 +631,11 @@ def initialize():
BOXCAR_ONSNATCH = bool(check_setting_int(CFG, 'Boxcar', 'boxcar_onsnatch', 0))
BOXCAR_TOKEN = check_setting_str(CFG, 'Boxcar', 'boxcar_token', '')
SUBSONIC_ENABLED = bool(check_setting_int(CFG, 'Subsonic', 'subsonic_enabled', 0))
SUBSONIC_HOST = check_setting_str(CFG, 'Subsonic', 'subsonic_host', '')
SUBSONIC_USERNAME = check_setting_str(CFG, 'Subsonic', 'subsonic_username', '')
SUBSONIC_PASSWORD = check_setting_str(CFG, 'Subsonic', 'subsonic_password', '')
SONGKICK_ENABLED = bool(check_setting_int(CFG, 'Songkick', 'songkick_enabled', 1))
SONGKICK_APIKEY = check_setting_str(CFG, 'Songkick', 'songkick_apikey', 'nd1We7dFW2RqxPw8')
SONGKICK_LOCATION = check_setting_str(CFG, 'Songkick', 'songkick_location', '')
@@ -1071,6 +1080,12 @@ def config_write():
new_config['Boxcar']['boxcar_onsnatch'] = int(BOXCAR_ONSNATCH)
new_config['Boxcar']['boxcar_token'] = BOXCAR_TOKEN
new_config['Subsonic'] = {}
new_config['Subsonic']['subsonic_enabled'] = int(SUBSONIC_ENABLED)
new_config['Subsonic']['subsonic_host'] = SUBSONIC_HOST
new_config['Subsonic']['subsonic_username'] = SUBSONIC_USERNAME
new_config['Subsonic']['subsonic_password'] = SUBSONIC_PASSWORD
new_config['Songkick'] = {}
new_config['Songkick']['songkick_enabled'] = int(SONGKICK_ENABLED)
new_config['Songkick']['songkick_apikey'] = SONGKICK_APIKEY

View File

@@ -793,3 +793,22 @@ class BOXCAR(object):
except urllib2.URLError as e:
logger.warn('Error sending Boxcar2 Notification: %s' % e)
return False
class SubSonicNotifier(object):
def __init__(self):
self.host = headphones.SUBSONIC_HOST
self.username = headphones.SUBSONIC_USERNAME
self.password = headphones.SUBSONIC_PASSWORD
def notify(self, albumpaths):
# Correct URL
if not self.host.lower().startswith("http"):
self.host = "http://" + self.host
if not self.host.lower().endswith("/"):
self.host = self.host + "/"
# Invoke request
request.request_response(self.host + "musicFolderSettings.view?scanNow",
auth=(self.username, self.password))

View File

@@ -519,6 +519,11 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
boxcar.notify('Headphones processed: ' + pushmessage,
statusmessage, release['AlbumID'])
if headphones.SUBSONIC_ENABLED:
logger.info(u"Sending Subsonic update")
subsonic = notifiers.SubSonicNotifier()
subsonic.notify(albumpaths)
if headphones.MPC_ENABLED:
mpc = notifiers.MPC()
mpc.notify()

View File

@@ -1124,6 +1124,10 @@ class WebInterface(object):
"pushbullet_onsnatch": checked(headphones.PUSHBULLET_ONSNATCH),
"pushbullet_apikey": headphones.PUSHBULLET_APIKEY,
"pushbullet_deviceid": headphones.PUSHBULLET_DEVICEID,
"subsonic_enabled": checked(headphones.SUBSONIC_ENABLED),
"subsonic_host": headphones.SUBSONIC_HOST,
"subsonic_username": headphones.SUBSONIC_USERNAME,
"subsonic_password": headphones.SUBSONIC_PASSWORD,
"twitter_enabled": checked(headphones.TWITTER_ENABLED),
"twitter_onsnatch": checked(headphones.TWITTER_ONSNATCH),
"osx_notify_enabled": checked(headphones.OSX_NOTIFY_ENABLED),
@@ -1181,7 +1185,7 @@ class WebInterface(object):
rutracker=0, rutracker_user=None, rutracker_password=None, rutracker_ratio=None, rename_files=0, correct_metadata=0, cleanup_files=0, keep_nfo=0, add_album_art=0, album_art_format=None, embed_album_art=0, embed_lyrics=0, replace_existing_folders=False,
destination_dir=None, lossless_destination_dir=None, folder_format=None, file_format=None, file_underscores=0, include_extras=0, single=0, ep=0, compilation=0, soundtrack=0, live=0, remix=0, spokenword=0, audiobook=0, other=0, djmix=0, mixtape_street=0, broadcast=0, interview=0, demo=0,
autowant_upcoming=False, autowant_all=False, keep_torrent_files=False, prefer_torrents=0, open_magnet_links=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,
bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0, subsonic_enabled=False, subsonic_host=None, subsonic_username=None, subsonic_password=None,
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, 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,
@@ -1350,6 +1354,10 @@ class WebInterface(object):
headphones.PUSHBULLET_ONSNATCH = pushbullet_onsnatch
headphones.PUSHBULLET_APIKEY = pushbullet_apikey
headphones.PUSHBULLET_DEVICEID = pushbullet_deviceid
headphones.SUBSONIC_ENABLED = subsonic_enabled
headphones.SUBSONIC_HOST = subsonic_host
headphones.SUBSONIC_USERNAME = subsonic_username
headphones.SUBSONIC_PASSWORD = subsonic_password
headphones.SONGKICK_ENABLED = songkick_enabled
headphones.SONGKICK_APIKEY = songkick_apikey
headphones.SONGKICK_LOCATION = songkick_location