@@ -90,6 +90,13 @@ class PyRadio(object):
9090 we continue playing, otherwise, we stop playback """
9191 active_stations = [ [ '' , 0 ], [ '' , - 1 ] ]
9292
93+ """ Used when loading a playlist from ' moe '.
94+ If the first station (selection) exists in the new playlist,
95+ we mark it as selected
96+ If the second station (playing) exists in the new playlist,
97+ we continue playing, otherwise, we stop playback """
98+ saved_active_stations = [ [ '' , 0 ], [ '' , - 1 ] ]
99+
93100 """ Used when opening a station after rename.
94101 If the first station (selection) exists in the new playlist,
95102 we mark it as selected
@@ -211,6 +218,7 @@ def __init__(self, pyradio_config, play=False, req_player='', theme=''):
211218 self .ws .SELECT_ENCODING_MODE : self ._redisplay_encoding_select_win_refresh_and_resize ,
212219 self .ws .SELECT_STATION_ENCODING_MODE : self ._redisplay_encoding_select_win_refresh_and_resize ,
213220 self .ws .SELECT_PLAYLIST_MODE : self ._playlist_select_win_refresh_and_resize ,
221+ self .ws .PASTE_MODE : self ._playlist_select_win_refresh_and_resize ,
214222 self .ws .SELECT_STATION_MODE : self ._redisplay_station_select_win_refresh_and_resize ,
215223 self .ws .MAIN_HELP_MODE : self ._show_main_help ,
216224 self .ws .MAIN_HELP_MODE_PAGE_2 : self ._show_main_help_page_2 ,
@@ -283,6 +291,7 @@ def __init__(self, pyradio_config, play=False, req_player='', theme=''):
283291 self .ws .CONFIG_MODE : self ._show_config_help ,
284292 self .ws .SELECT_PLAYER_MODE : self ._show_config_player_help ,
285293 self .ws .SELECT_PLAYLIST_MODE : self ._show_config_playlist_help ,
294+ self .ws .PASTE_MODE : self ._show_config_playlist_help ,
286295 self .ws .SELECT_STATION_MODE : self ._show_config_station_help ,
287296 self .ws .SELECT_STATION_ENCODING_MODE : self ._show_config_encoding_help ,
288297 self .ws .SELECT_ENCODING_MODE : self ._show_config_encoding_help ,
@@ -310,6 +319,7 @@ def __init__(self, pyradio_config, play=False, req_player='', theme=''):
310319 self .ws .PLAYLIST_MODE : 1 ,
311320 self .ws .SELECT_PLAYLIST_MODE : 1 ,
312321 self .ws .THEME_MODE : 2 ,
322+ self .ws .PASTE_MODE : 3 ,
313323 }
314324
315325 # which search mode opens from each allowed mode
@@ -318,6 +328,7 @@ def __init__(self, pyradio_config, play=False, req_player='', theme=''):
318328 self .ws .PLAYLIST_MODE : self .ws .SEARCH_PLAYLIST_MODE ,
319329 self .ws .THEME_MODE : self .ws .SEARCH_THEME_MODE ,
320330 self .ws .SELECT_PLAYLIST_MODE : self .ws .SEARCH_SELECT_PLAYLIST_MODE ,
331+ self .ws .PASTE_MODE : self .ws .SEARCH_SELECT_PLAYLIST_MODE ,
321332 self .ws .SELECT_STATION_MODE : self .ws .SEARCH_SELECT_STATION_MODE ,
322333 }
323334
@@ -2238,6 +2249,7 @@ def _align_stations_and_refresh(self,
22382249 if need_to_scan_playlist :
22392250 if logger .isEnabledFor (logging .DEBUG ):
22402251 logger .debug ('Scanning playlist for stations...' )
2252+ logger .error ('DE\n \n active_stations: {}\n \n ' .format (self .active_stations ))
22412253 self .selection , self .playing = self ._get_stations_ids ((
22422254 self .active_stations [0 ][0 ],
22432255 self .active_stations [1 ][0 ]))
@@ -2891,7 +2903,8 @@ def _apply_main_windows(ret):
28912903 _apply_main_windows (ret )
28922904 elif self .ws .operation_mode == self .ws .THEME_MODE :
28932905 self ._theme_selector .set_theme (self ._theme_selector ._themes [ret ])
2894- elif self .ws .operation_mode == self .ws .SELECT_PLAYLIST_MODE :
2906+ elif self .ws .operation_mode in (self .ws .SELECT_PLAYLIST_MODE ,
2907+ self .ws .PASTE_MODE ):
28952908 self ._playlist_select_win .setPlaylistById (ret , adjust = True )
28962909 elif self .ws .operation_mode == self .ws .SELECT_STATION_MODE :
28972910 self ._station_select_win .setPlaylistById (ret , adjust = True )
@@ -2902,7 +2915,8 @@ def _apply_main_windows(ret):
29022915 _apply_main_windows (ret )
29032916 elif self .ws .previous_operation_mode == self .ws .THEME_MODE :
29042917 self ._theme_selector .set_theme (self ._theme_selector ._themes [ret ])
2905- elif self .ws .previous_operation_mode == self .ws .SELECT_PLAYLIST_MODE :
2918+ elif self .ws .previous_operation_mode in (self .ws .SELECT_PLAYLIST_MODE ,
2919+ self .ws .PASTE_MODE ):
29062920 self ._playlist_select_win .setPlaylistById (ret , adjust = True )
29072921 elif self .ws .previous_operation_mode == self .ws .SELECT_STATION_MODE :
29082922 self ._station_select_win .setPlaylistById (ret , adjust = True )
@@ -3171,14 +3185,16 @@ def keypress(self, char):
31713185 # get station to register
31723186 # accept a-z, 0-9 and -
31733187 if char == ord ('\' ' ):
3188+ self ._set_active_stations ()
3189+ self .saved_active_stations = self .active_stations [:]
31743190 self ._status_suffix = "'"
31753191 self ._update_status_bar_right (status_suffix = "'" )
31763192 self ._cnf .open_register_list = True
31773193 """ set selections 0,1,2 to saved values """
31783194 self .selections [self .ws .REGISTER_MODE ][:- 1 ] = self .playlist_selections [self .ws .REGISTER_MODE ][:]
31793195 elif char in range (48 , 58 ) or char in range (97 , 123 ):
31803196 self ._cnf .register_to_open = chr (char ).lower ()
3181- self ._update_status_bar_right ()
3197+ self ._update_status_bar_right (status_suffix = '' )
31823198 else :
31833199 self ._update_status_bar_right (status_suffix = '' )
31843200 return
@@ -3249,6 +3265,7 @@ def keypress(self, char):
32493265 # paste
32503266 self ._update_status_bar_right (status_suffix = '' )
32513267 if self .ws .operation_mode == self .ws .NORMAL_MODE :
3268+ # paste to another playlist / register
32523269 self ._print_not_implemented_yet ()
32533270 else :
32543271 self ._paste (playlist = self .stations [self .selection ][- 1 ])
@@ -3864,6 +3881,11 @@ def keypress(self, char):
38643881 # Do this here to properly resize
38653882 return
38663883
3884+ elif self .ws .operation_mode == self .ws .PASTE_MODE :
3885+ self .ws .close_window ()
3886+ self .refreshBody ()
3887+ return
3888+
38673889 elif self .ws .operation_mode == self .ws .THEME_MODE and (
38683890 char not in self ._chars_to_bypass and \
38693891 char not in self ._chars_to_bypass_for_search and \
@@ -4646,7 +4668,7 @@ def keypress(self, char):
46464668
46474669 if char in (curses .KEY_ENTER , ord ('\n ' ), ord ('\r ' ),
46484670 curses .KEY_RIGHT , ord ('l' )):
4649- self ._update_status_bar_right ()
4671+ self ._update_status_bar_right (status_suffix = '' )
46504672 if self ._cnf .open_register_list :
46514673 self .playlist_selections [self .ws .REGISTER_MODE ] = [self .selection , self .startPos , self .playing ]
46524674 self .selections [self .ws .REGISTER_MODE ] = [self .selection , self .startPos , self .playing , self ._cnf .playlists ]
@@ -4659,7 +4681,7 @@ def keypress(self, char):
46594681 if logger .isEnabledFor (logging .DEBUG ):
46604682 logger .debug ('Loading playlist: "{}"' .format (self .stations [self .selection ][- 1 ]))
46614683 playlist_to_try_to_open = self .stations [self .selection ][- 1 ]
4662- ret = self ._cnf .read_playlist_file (stationFile = playlist_to_try_to_open )
4684+ ret = self ._cnf .read_playlist_file (stationFile = playlist_to_try_to_open )
46634685 logger .error ('DE playlist_selections = {}' .format (playlist_to_try_to_open ))
46644686
46654687 if ret == - 1 :
@@ -4690,7 +4712,9 @@ def keypress(self, char):
46904712 #self.ll('ENTER')
46914713 self .ws .close_window ()
46924714 self .selection , self .startPos , self .playing , self .stations = self .selections [self .ws .operation_mode ]
4715+ self .active_stations = self .saved_active_stations [:]
46934716 self ._align_stations_and_refresh (self .ws .PLAYLIST_MODE )
4717+ self ._set_active_stations ()
46944718 self ._give_me_a_search_class (self .ws .operation_mode )
46954719 if self .playing < 0 :
46964720 self ._put_selection_in_the_middle (force = True )
0 commit comments