Skip to content

Commit c12d4f4

Browse files
committed
do not allow to change the Recording Directory while recording is on
1 parent 0e0d594 commit c12d4f4

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed

pyradio/config_window.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,21 @@ class PyRadioConfigWindow(object):
107107

108108
load_default_or_saved_parameters = False
109109

110-
def __init__(self, parent, config,
111-
toggle_transparency_function,
112-
update_transparency_function,
113-
show_theme_selector_function,
114-
save_parameters_function,
115-
reset_parameters_function,
116-
show_port_number_invalid,
117-
parameters_editing_error=None,
118-
global_functions=None
119-
):
110+
def __init__(
111+
self,
112+
parent,
113+
recording_function,
114+
config,
115+
toggle_transparency_function,
116+
update_transparency_function,
117+
show_theme_selector_function,
118+
save_parameters_function,
119+
reset_parameters_function,
120+
show_port_number_invalid,
121+
parameters_editing_error=None,
122+
global_functions=None
123+
):
124+
self._is_recording = recording_function
120125
self.parameters_editing_error = parameters_editing_error
121126
self._local_functions = {
122127
ord('j'): self._go_down,
@@ -723,7 +728,8 @@ def keypress(self, char):
723728
1 cancel saving config
724729
2 cancel a dirty config (not active currently)
725730
3 open online browser config
726-
4 open recording dir selection window
731+
4 open recording dir selection window
732+
5 show recording is on error message
727733
'''
728734
if self.too_small:
729735
return 1, []
@@ -761,6 +767,8 @@ def keypress(self, char):
761767
return -1, []
762768

763769
elif val[0] == 'recording_dir':
770+
if self._is_recording() > 0:
771+
return 5, []
764772
return self.n_u.INSERT_RECORDINGS_DIR_MODE, []
765773

766774
elif val[0] == 'radiobrowser':

pyradio/messages_system.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,19 @@ def set_text(self, parent, *args):
11091109
If none of them is installed, close this window and
11101110
press |F8| to get to the player installation window.
11111111
1112+
'''
1113+
),
1114+
1115+
'M_REC_IS_ON_NO_DIR': ('Recording is active',
1116+
r'''
1117+
|PyRadio| is currently recording a station!
1118+
1119+
Changing the |Recording Directory| while recording a
1120+
station is not allowed.
1121+
1122+
Please stop the playback of the station (effectively
1123+
stopping the recording) and try again.
1124+
11121125
'''
11131126
),
11141127

pyradio/player.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3860,12 +3860,16 @@ def write_chapters_to_file_thread(self, input_file):
38603860
'--attachment-name', 'cover',
38613861
'--attach-file', cover_file
38623862
])
3863+
logger.error('\n\nopts = {}\n\n'.format(opts))
3864+
logger.error(f'{self._output_file = }')
3865+
logger.error(f'{self._mkv_file = }')
38633866
opts.extend([
38643867
'-o', self._output_file,
38653868
self._mkv_file
38663869
])
38673870
if logger.isEnabledFor(logging.DEBUG):
38683871
logger.debug('merge options = {}'.format(opts))
3872+
logger.error('\n\nopts = {}\n\n'.format(opts))
38693873
p = subprocess.Popen(
38703874
opts, shell=False,
38713875
stdout=subprocess.PIPE,

pyradio/radio.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4306,6 +4306,7 @@ def _show_config_window(self):
43064306
if self._config_win is None:
43074307
self._config_win = PyRadioConfigWindow(
43084308
self.outerBodyWin,
4309+
lambda: self.player.recording > 0 and self.player.isPlaying(),
43094310
self._cnf,
43104311
self._toggle_transparency,
43114312
self._update_transparency,
@@ -6837,7 +6838,7 @@ def keypress(self, char):
68376838
msg = ( 'Error saving config. Press any key to exit...',
68386839
'Config saved successfully!!!',
68396840
'Config saved - Restarting playback (parameters changed)')
6840-
if ret not in (2, 3):
6841+
if ret not in (2, 3, 5):
68416842
self.ws.close_window()
68426843
self.bodyWin.box()
68436844
self._print_body_header()
@@ -6969,6 +6970,14 @@ def keypress(self, char):
69696970
# elif ret ==2:
69706971
# ''' cancel a dirty config '''
69716972

6973+
elif ret == 5:
6974+
''' recording is on
6975+
cannot open recording dir selection window
6976+
'''
6977+
if logger.isEnabledFor(logging.DEBUG):
6978+
logger.debug('Cannot open Recording Selector Window; recording is on!')
6979+
self._open_simple_message_by_key('M_REC_IS_ON_NO_DIR')
6980+
return
69726981
else:
69736982
''' restore transparency, if necessary '''
69746983
if self._config_win._config_options['use_transparency'][1] != self._config_win._saved_config_options['use_transparency'][1]:

0 commit comments

Comments
 (0)