Skip to content

Commit

Permalink
lms plugin: fix commands for querying data
Browse files Browse the repository at this point in the history
  • Loading branch information
onkelandy committed Jun 1, 2024
1 parent 4f1d4bc commit 923acac
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ def trigger_read(command):
if not custom:
return

if command == 'player.info.playlists.names':
if command == f'player.info.playlists.names{CUSTOM_SEP}{custom}':
self.logger.debug(f"Got command playlist names {command} data {data} value {value} custom {custom} by {by}")
trigger_read('player.playlist.id')
trigger_read('player.playlist.name')

if command == 'playlist.rename':
trigger_read('info.playlists.names')
# set alarm
if command == 'player.control.alarms':
if command == f'player.control.alarms{CUSTOM_SEP}{custom}':
# This does not really work currently. The created string is somehow correct.
# However, much more logic has to be included to add/update/delete alarms, etc.
try:
Expand All @@ -118,7 +118,7 @@ def trigger_read(command):
self.logger.error(f"Error setting alarm: {e}")

# set album art URL
if command == 'player.info.album':
if command == f'player.info.album{CUSTOM_SEP}{custom}':
self.logger.debug(f"Got command album {command} data {data} value {value} custom {custom} by {by}")
host = self._parameters['web_host']
port = self._parameters['web_port']
Expand All @@ -130,17 +130,17 @@ def trigger_read(command):
self._dispatch_callback('player.info.albumarturl' + CUSTOM_SEP + custom, url, by)

# set playlist ID
if command == 'player.playlist.load':
if command == f'player.playlist.load{CUSTOM_SEP}{custom}':
self.logger.debug(f"Got command load {command} data {data} value {value} custom {custom} by {by}")
trigger_read('player.playlist.id')
trigger_read('player.control.playmode')

if command == 'player.playlist.id':
if command == f'player.playlist.id{CUSTOM_SEP}{custom}':
self.logger.debug(f"Got command id {command} data {data} value {value} custom {custom} by {by}")
trigger_read('player.playlist.name')

# update on new song
if command == 'player.info.title':
if command == f'player.info.title{CUSTOM_SEP}{custom}':
# trigger_read('player.control.playmode')
# trigger_read('player.playlist.index')
trigger_read('player.info.duration')
Expand All @@ -150,7 +150,7 @@ def trigger_read(command):
trigger_read('player.info.path')

# update on new song
if command == 'player.control.playpause' and value:
if command == f'player.control.playpause{CUSTOM_SEP}{custom}' and value:
trigger_read('player.control.playmode')
trigger_read('player.info.duration')
trigger_read('player.info.album')
Expand All @@ -159,7 +159,7 @@ def trigger_read(command):
trigger_read('player.info.path')

# update on new song
if command == 'player.playlist.index':
if command == f'player.playlist.index{CUSTOM_SEP}{custom}':
self.logger.debug(f"Got command index {command} data {data} value {value} custom {custom} by {by}")
trigger_read('player.control.playmode')
trigger_read('player.info.duration')
Expand All @@ -170,12 +170,12 @@ def trigger_read(command):
trigger_read('player.info.title')

# update current time info
if command in ['player.control.forward', 'player.control.rewind']:
if command in [f'player.control.forward{CUSTOM_SEP}{custom}', f'player.control.rewind{CUSTOM_SEP}{custom}']:
self.logger.debug(f"Got command forward/rewind {command} data {data} value {value} custom {custom} by {by}")
trigger_read('player.control.time')

# update play and stop items based on playmode
if command == 'player.control.playmode':
if command == f'player.control.playmode{CUSTOM_SEP}{custom}':
self.logger.debug(f"Got command playmode {command} data {data} value {value} custom {custom} by {by}")
mode = data.split("mode")[-1].strip()
mode = mode.split("playlist")[-1].strip()
Expand All @@ -186,7 +186,7 @@ def trigger_read(command):
trigger_read('player.control.time')

# update play and stop items based on playmode
if command == 'player.control.stop' or (command == 'player.control.playpause' and not value):
if command == f'player.control.stop{CUSTOM_SEP}{custom}' or (command == f'player.control.playpause{CUSTOM_SEP}{custom}' and not value):
self.logger.debug(f"Got command stop or pause {command} data {data} value {value} custom {custom} by {by}")
trigger_read('player.control.playmode')

Expand Down

0 comments on commit 923acac

Please sign in to comment.