@@ -313,6 +313,7 @@ class PyRadio():
313313 search = None
314314
315315 _last_played_station = []
316+ _last_played_playlist = ''
316317
317318 _random_requested = False
318319
@@ -641,6 +642,7 @@ def __init__(self, pyradio_config,
641642 self.ws.CLEAR_REGISTER_MODE: self._print_clear_register,
642643 self.ws.CLEAR_ALL_REGISTERS_MODE: self._print_clear_all_registers,
643644 self.ws.STATION_INFO_ERROR_MODE: self._print_station_info_error,
645+ self.ws.STATION_INFO_CHANGED_MODE: self._print_station_info_change,
644646 self.ws.STATION_INFO_MODE: self._show_station_info,
645647 self.ws.STATION_DATABASE_INFO_MODE: self._browser_station_info,
646648 self.ws.RENAME_PLAYLIST_MODE: self._show_rename_dialog,
@@ -2623,6 +2625,8 @@ def playSelection(self, restart=False):
26232625 # stream_url = self._cnf.online_browser.url(self.selection)
26242626 self._last_played_station = self.stations[self.selection]
26252627 self._last_played_station_id = self.selection
2628+ self._last_played_playlist = self._cnf.station_title
2629+ logger.error('\n\nself._last_played_playlist = {}\n\n'.format(self._last_played_playlist))
26262630 with self._check_lock:
26272631 self._station_to_check_id = self.selection
26282632 if logger.isEnabledFor(logging.INFO):
@@ -2713,6 +2717,7 @@ def connectionFailed(self):
27132717 self.detect_if_player_exited = False
27142718 if self.ws.operation_mode in (self.ws.STATION_INFO_MODE,
27152719 self.ws.STATION_DATABASE_INFO_MODE,
2720+ self.ws.STATION_INFO_CHANGED_MODE,
27162721 self.ws.STATION_INFO_ERROR_MODE):
27172722 self.ws.close_window()
27182723 old_playing = self.playing
@@ -3627,6 +3632,12 @@ def _print_register_save_error(self):
36273632 string_to_display
36283633 )
36293634
3635+ def _print_station_info_change(self):
3636+ self._open_simple_message_by_key_and_mode(
3637+ self.ws.STATION_INFO_CHANGED_MODE,
3638+ 'M_STATION_INFO_CHANGED'
3639+ )
3640+
36303641 def _print_station_info_error(self):
36313642 self._open_simple_message_by_key_and_mode(
36323643 self.ws.STATION_INFO_ERROR_MODE,
@@ -3945,6 +3956,8 @@ def _align_stations_and_refresh(self,
39453956 self.selection, self.playing = self._get_stations_ids((
39463957 self.active_stations[0][0],
39473958 self.active_stations[1][0]))
3959+ # TODO: continue playing after changing playlist
3960+ # if self.player.isPlaying():
39483961 if self.playing == -1:
39493962 self.stopPlayer()
39503963
@@ -3953,6 +3966,7 @@ def _align_stations_and_refresh(self,
39533966 if logger.isEnabledFor(logging.DEBUG):
39543967 logger.debug('Setting playing station at {}'.format(self.playing))
39553968 self.setStation(self.playing)
3969+ self._last_played_playlist = self._cnf.station_title
39563970 else:
39573971 if self.selection == -1:
39583972 if a_selection > -1:
@@ -4807,9 +4821,13 @@ def _show_config_window(self):
48074821
48084822 def _show_station_info_from_thread(self):
48094823 if self.ws.operation_mode in (
4810- self.ws.STATION_INFO_MODE,
4824+ self.ws.STATION_INFO_MODE,
4825+ self.ws.STATION_INFO_CHANGED_MODE,
48114826 self.ws.STATION_INFO_ERROR_MODE):
4812- if self.ws.operation_mode == self.ws.STATION_INFO_ERROR_MODE:
4827+ if self.ws.operation_mode in (
4828+ self.ws.STATION_INFO_CHANGED_MODE,
4829+ self.ws.STATION_INFO_ERROR_MODE
4830+ ):
48134831 self.ws.close_window()
48144832 # logger.error('\n\nself._show_station_info() from thread\n\n')
48154833 self.ws.close_window()
@@ -5607,7 +5625,10 @@ def _handle_passive_windows(self):
56075625
56085626 def _normal_station_info(self):
56095627 if self.player.isPlaying():
5610- self._show_station_info()
5628+ if self._last_played_playlist == self._cnf.station_title:
5629+ self._show_station_info()
5630+ else:
5631+ self._print_station_info_change()
56115632 else:
56125633 self._print_station_info_error()
56135634
@@ -8023,6 +8044,9 @@ def keypress(self, char):
80238044 self.selections[0][3] = self.stations
80248045 if self.selection == self.playing:
80258046 self._last_played_station = self.stations[self.selection]
8047+ # I do not need to set it here, i'm just changing the station's encoding
8048+ # self._last_played_playlist = self._cnf.station_title
8049+ # logger.error('\n\nself._last_played_playlist = {}\n\n'.format(self._last_played_playlist))
80268050 if self._cnf.browsing_station_service:
80278051 self._cnf.dirty_playlist = False
80288052 self._cnf.online_browser.set_encoding(self.selection, ret_encoding)
@@ -8082,6 +8106,9 @@ def keypress(self, char):
80828106 self._cnf.renamed_stations[-1][-1] = self.stations[self.selection][0]
80838107 if self.selection == self.playing:
80848108 self._last_played_station = self._station_editor.new_station
8109+ # I do not need to set it here, i'm just editing a station
8110+ # self._last_played_playlist = self._cnf.station_title
8111+ # logger.error('\n\nself._last_played_playlist = {}\n\n'.format(self._last_played_playlist))
80858112 else:
80868113 ''' adding a new station '''
80878114 self._cnf.dirty_playlist = True
@@ -9334,6 +9361,9 @@ def keypress(self, char):
93349361 self.stations[self.playing][0] = icy_data_name
93359362 self._cnf.dirty_playlist = True
93369363 self._last_played_station = self.stations[self.playing]
9364+ # I do not need to set it here, i'm just renaming the station
9365+ # self._last_played_playlist = self._cnf.station_title
9366+ # logger.error('\n\nself._last_played_playlist = {}\n\n'.format(self._last_played_playlist))
93379367 self.selections[0][3] = self.stations
93389368 self._show_station_info()
93399369 else:
0 commit comments