From ebc0b7205fedee94702c8064f9e79497f6116bf0 Mon Sep 17 00:00:00 2001 From: Kane Wallmann Date: Wed, 30 Apr 2014 19:53:59 +1000 Subject: [PATCH 1/2] Added MPC notifier, calls 'mpc update' on local machine --- data/interfaces/default/config.html | 8 ++++++++ headphones/__init__.py | 1 + headphones/notifiers.py | 11 +++++++++++ headphones/postprocessor.py | 4 ++++ headphones/webserve.py | 7 +++++-- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 60aeaf99..44f36268 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -812,6 +812,14 @@ +
+

MPC

+
+ +
+
+ +
diff --git a/headphones/__init__.py b/headphones/__init__.py index b354291b..68edabf3 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -284,6 +284,7 @@ SONGKICK_ENABLED = False SONGKICK_APIKEY = None SONGKICK_LOCATION = None SONGKICK_FILTER_ENABLED = False +MPC_ENABLED = False CACHE_SIZEMB = 32 JOURNAL_MODE = None diff --git a/headphones/notifiers.py b/headphones/notifiers.py index a549db80..fdb12c55 100644 --- a/headphones/notifiers.py +++ b/headphones/notifiers.py @@ -169,6 +169,17 @@ class PROWL: self.notify('ZOMG Lazors Pewpewpew!', 'Test Message') +class MPC: + + def __init__(self): + + pass + + def notify( self ): + + subprocess.call( ["mpc", "update"] ) + + class XBMC: def __init__(self): diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index d1ccbee4..726c56fd 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -502,6 +502,10 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, boxcar = notifiers.BOXCAR() boxcar.notify('Headphones processed: ' + pushmessage, "Download and Postprocessing completed", release['AlbumID']) + if headphones.MPC_ENABLED: + mpc = notifiers.MPC() + mpc.notify() + def embedAlbumArt(artwork, downloaded_track_list): logger.info('Embedding album art') diff --git a/headphones/webserve.py b/headphones/webserve.py index 517104ab..8f293ee1 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1085,7 +1085,8 @@ class WebInterface(object): "songkick_filter_enabled": checked(headphones.SONGKICK_FILTER_ENABLED), "cache_sizemb": headphones.CACHE_SIZEMB, "file_permissions": headphones.FILE_PERMISSIONS, - "folder_permissions": headphones.FOLDER_PERMISSIONS + "folder_permissions": headphones.FOLDER_PERMISSIONS, + "mpc_enabled": checked(headphones.MPC_ENABLED) } # Need to convert EXTRAS to a dictionary we can pass to the config: it'll come in as a string like 2,5,6,8 @@ -1122,7 +1123,7 @@ class WebInterface(object): osx_notify_enabled=0, osx_notify_onsnatch=0, osx_notify_app=None, boxcar_enabled=0, boxcar_onsnatch=0, boxcar_token=None, 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, plex_password=None, plex_update=0, plex_notify=0, - songkick_enabled=0, songkick_apikey=None, songkick_location=None, songkick_filter_enabled=0, encoder_multicore=False, encoder_multicore_count=0, **kwargs): + songkick_enabled=0, songkick_apikey=None, songkick_location=None, songkick_filter_enabled=0, encoder_multicore=False, encoder_multicore_count=0, mpc_enabled=False, **kwargs ): headphones.HTTP_HOST = http_host headphones.HTTP_PORT = http_port @@ -1291,6 +1292,8 @@ class WebInterface(object): headphones.BOXCAR_ONSNATCH = boxcar_onsnatch headphones.BOXCAR_TOKEN = boxcar_token + headphones.MPC_ENABLED = mpc_enabled + headphones.MIRROR = mirror headphones.CUSTOMHOST = customhost headphones.CUSTOMPORT = customport From ea8b1815f633821944c304f40f26afe872f365eb Mon Sep 17 00:00:00 2001 From: Kane Wallmann Date: Wed, 30 Apr 2014 20:18:48 +1000 Subject: [PATCH 2/2] Fixed tab indent to match file --- headphones/webserve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 8f293ee1..625a7b76 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1086,7 +1086,7 @@ class WebInterface(object): "cache_sizemb": headphones.CACHE_SIZEMB, "file_permissions": headphones.FILE_PERMISSIONS, "folder_permissions": headphones.FOLDER_PERMISSIONS, - "mpc_enabled": checked(headphones.MPC_ENABLED) + "mpc_enabled": checked(headphones.MPC_ENABLED) } # Need to convert EXTRAS to a dictionary we can pass to the config: it'll come in as a string like 2,5,6,8