@@ -516,6 +516,8 @@ def __init__(self, pyradio_config,
516
516
ord ('m' ): self ._volume_mute ,
517
517
ord ('v' ): self ._volume_save ,
518
518
ord ('~' ): self ._toggle_claculated_colors ,
519
+ ord ('<' ): self ._stations_history_previous ,
520
+ ord ('>' ): self ._stations_history_next ,
519
521
}
520
522
521
523
@@ -5228,6 +5230,28 @@ def _show_stations_history_notification(self, msg_id):
5228
5230
callback_function = self .refreshBody
5229
5231
)
5230
5232
5233
+ def _stations_history_previous (self ):
5234
+ self ._update_status_bar_right (status_suffix = '' )
5235
+ if int (self ._cnf .connection_timeout_int ) == 0 :
5236
+ self ._show_stations_history_notification (0 )
5237
+ else :
5238
+ if self .player .connecting :
5239
+ self ._show_stations_history_notification (1 )
5240
+ else :
5241
+ self ._cnf .play_from_history = True
5242
+ self ._cnf .stations_history .play_previous ()
5243
+
5244
+ def _stations_history_next (self ):
5245
+ self ._update_status_bar_right (status_suffix = '' )
5246
+ if int (self ._cnf .connection_timeout_int ) == 0 :
5247
+ self ._show_stations_history_notification (0 )
5248
+ else :
5249
+ if self .player .connecting :
5250
+ self ._show_stations_history_notification (1 )
5251
+ else :
5252
+ self ._cnf .play_from_history = True
5253
+ self ._cnf .stations_history .play_next ()
5254
+
5231
5255
def keypress (self , char ):
5232
5256
if self ._system_asked_to_terminate :
5233
5257
''' Make sure we exit when signal received '''
@@ -7182,27 +7206,7 @@ def keypress(self, char):
7182
7206
return
7183
7207
7184
7208
if self .ws .operation_mode == self .ws .NORMAL_MODE :
7185
- if char == ord ('<' ):
7186
- self ._update_status_bar_right (status_suffix = '' )
7187
- if int (self ._cnf .connection_timeout_int ) == 0 :
7188
- self ._show_stations_history_notification (0 )
7189
- else :
7190
- if self .player .connecting :
7191
- self ._show_stations_history_notification (1 )
7192
- else :
7193
- self ._cnf .play_from_history = True
7194
- self ._cnf .stations_history .play_previous ()
7195
- elif char == ord ('>' ):
7196
- self ._update_status_bar_right (status_suffix = '' )
7197
- if int (self ._cnf .connection_timeout_int ) == 0 :
7198
- self ._show_stations_history_notification (0 )
7199
- else :
7200
- if self .player .connecting :
7201
- self ._show_stations_history_notification (1 )
7202
- else :
7203
- self ._cnf .play_from_history = True
7204
- self ._cnf .stations_history .play_next ()
7205
- elif char == curses .KEY_F8 and platform .startswith ('win' ):
7209
+ if char == curses .KEY_F8 and platform .startswith ('win' ):
7206
7210
''' manage players on Windows
7207
7211
will present them after curses end
7208
7212
'''
@@ -8482,19 +8486,19 @@ def _add_station_to_stations_history(self):
8482
8486
self ._cnf .stations_history .add (self ._cnf .station_file_name [:- 4 ], self .stations [self .playing ][0 ], self .playing )
8483
8487
8484
8488
def _load_playlist_and_station_from_station_history (self , h_item , func ):
8489
+ num = - 1
8490
+ current_playlist = self ._cnf .station_file_name [:- 4 ]
8485
8491
if h_item [0 ] == h_item [1 ] or \
8486
8492
h_item [1 ].startswith ('register_' ) or \
8487
8493
h_item [- 1 ] < 0 or \
8488
- h_item [- 1 ] >= self .number_of_items :
8494
+ ( h_item [- 1 ] >= self .number_of_items and current_playlist == h_item [ 0 ]) :
8489
8495
if logger .isEnabledFor (logging .ERROR ):
8490
8496
logger .error ('\n ===============\n Invalid h_item: "{0}"\n Number of stations = {1}\n ===============' .format (h_item , self .number_of_items ))
8491
8497
func ()
8492
8498
return
8493
8499
if logger .isEnabledFor (logging .DEBUG ):
8494
8500
logger .debug ('Activating station history item: {}' .format (h_item ))
8495
8501
8496
- num = - 1
8497
- current_playlist = self ._cnf .station_file_name [:- 4 ]
8498
8502
if current_playlist == h_item [0 ] or \
8499
8503
h_item [0 ] == 'Online Browser' :
8500
8504
''' I am moving within the loaded playlist '''
@@ -8568,13 +8572,18 @@ def _load_playlist_and_station_from_station_history(self, h_item, func):
8568
8572
self ._playlist_in_editor = self ._cnf .station_path
8569
8573
self ._playlist_error_message = ''
8570
8574
''' update station header on top of window '''
8571
- self .outerBodyWin .box ()
8572
- self ._print_body_header ()
8573
- self .outerBodyWin .refresh ()
8575
+ if not (self ._limited_height_mode or self ._limited_width_mode ):
8576
+ logger .error ('==== update outer Body!' )
8577
+ self .outerBodyWin .box ()
8578
+ self ._print_body_header ()
8579
+ self .outerBodyWin .refresh ()
8574
8580
self .playSelection ()
8575
8581
self ._set_active_stations ()
8576
8582
self ._get_playlists_data_from_playlist_name (h_item [0 ])
8577
8583
self .saved_active_stations = [['' , 0 ], ['' , - 1 ]]
8584
+ if self ._limited_height_mode or self ._limited_width_mode :
8585
+ logger .error ('==== update body' )
8586
+ self ._print_limited_info ()
8578
8587
return
8579
8588
8580
8589
try :
@@ -8597,6 +8606,9 @@ def _load_playlist_and_station_from_station_history(self, h_item, func):
8597
8606
self .stations
8598
8607
]
8599
8608
self .saved_active_stations = [['' , 0 ], ['' , - 1 ]]
8609
+ if self ._limited_height_mode or self ._limited_width_mode :
8610
+ logger .error ('==== update body' )
8611
+ self ._print_limited_info ()
8600
8612
8601
8613
def _get_playlists_data_from_playlist_name (self , a_playlist ):
8602
8614
change_regs_too = False
@@ -8636,14 +8648,22 @@ def _scan_playlist_for_station(self, stations, start, station_to_find):
8636
8648
logger .error ('Scanning playlist...' )
8637
8649
up = down = 0
8638
8650
num = - 1
8651
+ if logger .isEnabledFor (logging .DEBUG ):
8652
+ logger .debug (' checking start={0}: "{1}"' .format (start , stations [start ]))
8653
+ if stations [start ][0 ] == station_to_find :
8654
+ return start
8639
8655
for i in range (start , - 1 , - 1 ):
8640
8656
up = i + 1
8641
8657
down = i - 1
8642
8658
if down > - 1 :
8659
+ if logger .isEnabledFor (logging .DEBUG ):
8660
+ logger .debug (' checking down={0}: "{1}"' .format (down , stations [down ]))
8643
8661
if stations [down ][0 ] == station_to_find :
8644
8662
num = down
8645
8663
break
8646
8664
if up < self ._cnf .number_of_stations :
8665
+ if logger .isEnabledFor (logging .DEBUG ):
8666
+ logger .debug (' checking up={0}: "{1}"' .format (up , stations [up ]))
8647
8667
if stations [up ][0 ] == station_to_find :
8648
8668
num = up
8649
8669
break
@@ -8653,6 +8673,8 @@ def _scan_playlist_for_station(self, stations, start, station_to_find):
8653
8673
if logger .isEnabledFor (logging .DEBUG ):
8654
8674
logger .debug ('Station not found... Scanning to top...' )
8655
8675
for i in range (down , - 1 , - 1 ):
8676
+ if logger .isEnabledFor (logging .DEBUG ):
8677
+ logger .debug (' checking {0}: "{1}"' .format (i , stations [i ]))
8656
8678
if stations [i ][0 ] == station_to_find :
8657
8679
num = i
8658
8680
break
@@ -8661,6 +8683,8 @@ def _scan_playlist_for_station(self, stations, start, station_to_find):
8661
8683
if logger .isEnabledFor (logging .DEBUG ):
8662
8684
logger .debug ('Station not found... Scanning to bottom...' )
8663
8685
for i in range (up , self ._cnf .number_of_stations - 1 ):
8686
+ if logger .isEnabledFor (logging .DEBUG ):
8687
+ logger .debug (' checking {0}: "{1}"' .format (i , stations [i ]))
8664
8688
if stations [i ][0 ] == station_to_find :
8665
8689
num = i
8666
8690
break
0 commit comments