Skip to content

Commit c92afac

Browse files
committed
when saving players' extra parameters reduce the list by removing the
unused porifles from the list
1 parent 5a618d1 commit c92afac

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pyradio/config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,6 +2782,20 @@ def save_config(self, from_command_line=False):
27822782
copyfile(self.player_params_file, self.player_params_file + '.restore')
27832783
except:
27842784
pass
2785+
# fix self.saved_params (remove profiles)
2786+
profiles_params_changed = False
2787+
for a_key in self.saved_params.keys():
2788+
the_id = self.saved_params[a_key][0]
2789+
the_profile = self.saved_params[a_key][self.saved_params[a_key][0]]
2790+
# logger.error('\n\na_key = {0}\nthe_id = {1}\nthe_profile = {2}\n\n'.format(a_key, the_id, the_profile))
2791+
for i in range(len(self.saved_params[a_key])-1, 0, -1):
2792+
if self.saved_params[a_key][i].startswith('profile:'):
2793+
if self.saved_params[a_key][i] != the_profile:
2794+
del self.saved_params[a_key][i]
2795+
profiles_params_changed = True
2796+
self.saved_params[a_key][0] = self.saved_params[a_key].index(the_profile)
2797+
if profiles_params_changed and logger.isEnabledFor(logging.DEBUG):
2798+
logger.debug('reduced saved params = {}'.format(self.saved_params))
27852799
try:
27862800
with open(self.player_params_file, 'w', encoding='utf-8') as jf:
27872801
jf.write(json.dumps(self.saved_params))

0 commit comments

Comments
 (0)