Skip to content

Commit abb9daa

Browse files
committed
execute mkvmerge only once
1 parent c12d4f4 commit abb9daa

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

pyradio/config_window.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class PyRadioConfigWindow(object):
5555
'This is the equivalent to the -u , --use-player command line option.', '|',
5656
'Example:', ' player = vlc', 'or', ' player = vlc,mpv, mplayer', '|',
5757
'Default value: mpv,mplayer,vlc'])
58-
_help_text.append([r'If this option is enabled, the last local playlist loaded before terminating, will be automatically opened the next time PyRadio is executed. Furthermore, playback will resume, if it was on when PyRadio exited. Otherwise, station selection will be restored.', '|', 'This option will take precedence over the "Def. playlist" configuration option and the "-s" command line option.', '|', 'It can also be toggled on the fly by pressing \l while on Main mode.', '|', 'Default value: False'])
58+
_help_text.append([r'If this option is enabled, the last local playlist loaded before terminating, will be automatically opened the next time PyRadio is executed. Furthermore, playback will resume, if it was on when PyRadio exited. Otherwise, station selection will be restored.', '|', 'This option will take precedence over the "Def. playlist" configuration option and the "-s" command line option.', '|', r'It can also be toggled on the fly by pressing \l while on Main mode.', '|', 'Default value: False'])
5959
_help_text.append(['This is the playlist to open at start up, if none is specified and "Open last playlist" is not set.', '|',
6060
'This is the equivalent to the -s, --stations command line option.', '|',
6161
'Default value: stations'])

pyradio/player.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3738,6 +3738,7 @@ def __init__(
37383738
encoding='urf-8'
37393739
):
37403740
# cover_dir is the data dir
3741+
self._mkvmerge_is_done = False
37413742
self._cnf = config
37423743
self._playlist = os.path.basename(self._cnf.station_path)[:-4]
37433744
self._chapters_time_function = chapter_time
@@ -3828,18 +3829,32 @@ def write_chapters_to_file(self, input_file):
38283829
logger.info('mkvmerge not found!')
38293830

38303831
def write_chapters_to_file_thread(self, input_file):
3832+
if self._mkvmerge_is_done:
3833+
if logger.isEnabledFor(logging.INFO):
3834+
logger.info('Already execute mkvmerge; terminating')
3835+
return
38313836
opts = []
38323837
self._tag_file = input_file[:-4] + '.xml'
38333838
# remove tmp_ from begining of filename
38343839
self._tag_file = self._remove_starting_tmp_string(self._tag_file)
38353840
opts = [self.mkvmerge,
38363841
'--global-tags', self._tag_file,
38373842
]
3843+
self._output_file = None
3844+
self._mkv_file = None
38383845
if self.create_chapter_file(input_file):
38393846
if len(self._list) > 1:
38403847
opts.extend([
38413848
'--chapters', self._chapters_file,
38423849
])
3850+
if self._output_file is None:
3851+
if logger.isEnabledFor(logging.INFO):
3852+
logger.info('Output file is None... Quiting mkvmerge')
3853+
return
3854+
elif self._mkv_file is None:
3855+
if logger.isEnabledFor(logging.INFO):
3856+
logger.info('MKV file is None... Quiting mkvmerge')
3857+
return
38433858
t_dir_dir = os.path.dirname(self._tag_file)
38443859
cover_file = None
38453860
for n in (
@@ -3860,9 +3875,6 @@ def write_chapters_to_file_thread(self, input_file):
38603875
'--attachment-name', 'cover',
38613876
'--attach-file', cover_file
38623877
])
3863-
logger.error('\n\nopts = {}\n\n'.format(opts))
3864-
logger.error(f'{self._output_file = }')
3865-
logger.error(f'{self._mkv_file = }')
38663878
opts.extend([
38673879
'-o', self._output_file,
38683880
self._mkv_file
@@ -3881,6 +3893,7 @@ def write_chapters_to_file_thread(self, input_file):
38813893
if p.returncode == 0:
38823894
if logger.isEnabledFor(logging.INFO):
38833895
logger.info('MKV merge successful!')
3896+
self._mkvmerge_is_done = True
38843897
for n in self._chapters_file, self._tag_file, self._mkv_file:
38853898
try:
38863899
os.remove(n)

0 commit comments

Comments
 (0)