Skip to content

Commit 3a59eb0

Browse files
committed
- fixing build license warning
- fixing Sorting Error #286 - started working on not stopping playback when changing playlist and station not found
1 parent c181ca5 commit 3a59eb0

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ authors = [
77
]
88
description = "Command line internet radio player"
99
readme = "README.md"
10-
license = {file = "LICENSE"}
10+
license = "MIT"
11+
license-files = ["LICENSE"]
1112
requires-python = ">=3.7"
1213
classifiers = [
1314
"Programming Language :: Python :: 3",
14-
"License :: OSI Approved :: MIT License",
1515
"Operating System :: OS Independent",
1616
]
1717

pyradio/browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4068,7 +4068,7 @@ def keypress(self, char):
40684068
elif char in (
40694069
kbkey['l'], kbkey['pause'], curses.KEY_RIGHT,
40704070
ord('\n'), ord('\r'), curses.KEY_ENTER
4071-
) or check_localized(char, (kbkey['paluse'], kbkey['l'])):
4071+
) or check_localized(char, (kbkey['pause'], kbkey['l'])):
40724072
for i, n in enumerate(self.items.keys()):
40734073
if i == self.selection:
40744074
self.search_by = self.items[n]

pyradio/messages_system.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,15 @@ def set_text(self, parent, *args):
265265
Please play a station to get its info, (or
266266
wait until one actually starts playing).
267267
268+
'''
269+
),
270+
271+
'M_STATION_INFO_CHANGED': ('Station Info Error',
272+
r'''
273+
Station info not available at this time,
274+
since the station playing is not in the
275+
current playlist.
276+
268277
'''
269278
),
270279

pyradio/radio.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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:

pyradio/window_stack.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class Window_Stack_Constants():
100100
FOREIGN_PLAYLIST_ASK_MODE = 300
101101
CONFIG_SAVE_ERROR_MODE = 303
102102
STATION_INFO_ERROR_MODE = 308
103+
STATION_INFO_CHANGED_MODE = 309
103104
PLAYLIST_CREATE_ERROR = 311
104105
WIN_VLC_NO_RECORD_MODE = 324
105106
KEYBOARD_CONFIG_ERROR_MODE = 325
@@ -156,6 +157,7 @@ class Window_Stack_Constants():
156157
STATION_INFO_MODE: 'STATION_INFO_MODE',
157158
STATION_DATABASE_INFO_MODE: 'STATION_DATABASE_INFO_MODE',
158159
STATION_INFO_ERROR_MODE: 'STATION_INFO_ERROR_MODE',
160+
STATION_INFO_CHANGED_MODE: 'STATION_INFO_CHANGED_MODE',
159161
CREATE_PLAYLIST_MODE: 'CREATE_PLAYLIST_MODE',
160162
RENAME_PLAYLIST_MODE: 'RENAME_PLAYLIST_MODE',
161163
PLAYLIST_CREATE_ERROR: 'PLAYLIST_CREATE_ERROR',
@@ -234,6 +236,7 @@ class Window_Stack_Constants():
234236
PLAYLIST_NOT_FOUND_ERROR_MODE,
235237
SERVICE_CONNECTION_ERROR,
236238
STATION_INFO_ERROR_MODE,
239+
STATION_INFO_CHANGED_MODE,
237240
PLAYLIST_CREATE_ERROR,
238241
UNNAMED_REGISTER_MODE,
239242
STATION_DATABASE_INFO_MODE,

0 commit comments

Comments
 (0)