Skip to content

Commit 9b19548

Browse files
committed
Remote Control Server: introducing the /reconfig command, so that
headles instances can update their configuration when changed from a normal Pyradio instance
1 parent da55497 commit 9b19548

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

pyradio/config.py

+3
Original file line numberDiff line numberDiff line change
@@ -2084,6 +2084,9 @@ def read_config(self, distro_config=False):
20842084
self.config_opts = deepcopy(self.opts)
20852085
# for n in self.config_opts.items():
20862086
# logger.error(' {}: {}'.format(*n))
2087+
self.re_read_config()
2088+
2089+
def re_read_config(self):
20872090
self._read_config()
20882091
self.xdg.ensure_paths_exist()
20892092

pyradio/radio.py

+6
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ def __init__(self, pyradio_config,
500500
'/title': self._html_song_title,
501501
'/html_info': self._html_info,
502502
'/text_info': self._text_info,
503+
'/text_reconfig': self._text_reconfig,
503504
'/html_is_stopped': self._html_is_player_stopped,
504505
'/html_is_radio_browser': self._html_is_radio_browser,
505506
'/html_init': self._html_init_song_title,
@@ -781,6 +782,11 @@ def _save_colors(self):
781782
except:
782783
return
783784

785+
def _text_reconfig(self, html=False):
786+
self._cnf.re_read_config()
787+
if not html:
788+
return 'User config file read'
789+
784790
def _text_info(self):
785791
out = []
786792
out.append('PyRadio {0}{1}'.format(self._cnf.current_pyradio_version, ' (headless)' if self._cnf.headless else ''))

pyradio/server.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ class PyRadioServer(object):
299299
<button id="vs" onclick="js_send_simple_command('/html/volumesave', 1500);" type="button" class="btn btn-success">Save<br>Volume</button>
300300
<button id="mute" onclick="js_send_simple_command('/html/mute', 1500);" type="button" class="btn btn-warning">Mute<br>Player</button>
301301
<button id="recording" onclick="js_send_simple_command('/html/trec', 1500);" type="button" class="btn btn-danger">REC<br>Disabled</button>
302+
<!-- <button id="recondig" onclick="js_send_simple_command('/html/reconfig', 1500);" type="button" class="btn btn-success">Re-read<br>Config</button> -->
302303
</div>
303304
</div>
304305
<div class="col-xs-4 col-lg-4">
@@ -915,7 +916,8 @@ class PyRadioServer(object):
915916
/rb_page /grb get RadioBrowser searh results page number
916917
/rb_first_page /frb load RadioBrowser first results page
917918
/rb_next_page /nrb load RadioBrowser next results page
918-
/rb_previous_page /prb load RadioBrowser previous results page''',
919+
/rb_previous_page /prb load RadioBrowser previous results page
920+
/reconfig force a headless instance to read config''',
919921
'/quit': 'PyRadio Remote Service exiting!\nCheers!',
920922
'/volumeup': 'Volume increased!',
921923
'/volumedown': 'Volume decreased!',
@@ -1244,6 +1246,19 @@ def _handle_client_connection(self, address, request):
12441246
else:
12451247
self._send_text(self._text['/'])
12461248

1249+
elif self._path in ('/reconfig', ):
1250+
''' no html command '''
1251+
if not self._is_html:
1252+
if self._cnf.headless:
1253+
if self.can_send_command():
1254+
received = self._commands['/text_reconfig']()
1255+
# logger.error('received = "{}"'.format(received))
1256+
self._send_text(received)
1257+
else:
1258+
self._send_text(self._text['/perm'])
1259+
else:
1260+
self._send_text('Command not applicable in non-headless operation!')
1261+
12471262
elif self._path in ('/i', '/info'):
12481263
if self._is_html:
12491264
received = self._commands['/html_info']()

pyradio/win.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
https://sourceforge.net/projects/mpv-player-windows/files/latest/download
3939
'''
4040
zurl = [
41-
'https://sourceforge.com/projects/mpv-player-windows/files/64bit/mpv-x86_64-20240505-git-c4b6d0d.7z/download',
41+
'https://sourceforge.com/projects/mpv-player-windows/files/64bit/mpv-x86_64-20240512-git-3874145.7z/download',
4242
'https://sourceforge.net/projects/mplayerwin/files/MPlayer-MEncoder/r38151/mplayer-svn-38151-x86_64.7z/download'
4343
]
4444

0 commit comments

Comments
 (0)