Skip to content

Commit cb599d1

Browse files
committed
- always have Crash detection enabled; changing random playback
functionality in order to achieve that - all players will try to catch HTTP errors 403, 404, 503 through Crash detection and http_error - adding player counter id to log.write; this way we will not display a message coming from a terminating updateStatus thread - adding message id to log.write; this way we will not display a message coming from a terminating updateStatus thread - log.write will provide a consistent indication if player is in playback or not (self._player_stopped) - config: Clock default format is now HH:MM - started addding strings to common.py: M_STRINGS
1 parent 76f5ba2 commit cb599d1

File tree

7 files changed

+465
-210
lines changed

7 files changed

+465
-210
lines changed

pyradio/common.py

+49-7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ def BACKGROUND():
2323
CAPTION = 2
2424
BORDER = 3
2525

26+
M_STRINGS = {
27+
'init_': 'Initialization: ',
28+
'connecting_': 'Connecting to: ',
29+
'conn-fail_': 'Failed to connect to: ',
30+
'playing_': 'Playing: ',
31+
'buffering_': 'Buffering: ',
32+
'station_': 'Station: ',
33+
'selected_player_': 'Selected player: ',
34+
'down-icon': 'Downloading icon...',
35+
'player-acivated_': ': Player activated!!!',
36+
'hist-empty': 'History is empty!!!',
37+
'hist-first': 'Already at first item!!!',
38+
'hist-last': 'Already at last item!!!',
39+
}
40+
2641
"""
2742
Format of theme configuration
2843
Name, color_pair, foreground, background
@@ -52,13 +67,6 @@ def BACKGROUND():
5267
('Edit Cursor', 8, 0, 0)
5368
)
5469

55-
""" Messages to display when player starts / stops
56-
Used in log to stop runaway threads from printing
57-
messages after playback is stopped """
58-
player_start_stop_token = ('Initialization: ',
59-
': Playback stopped',
60-
': Player terminated abnormally!',
61-
': Stream not found (error 404)')
6270

6371
def erase_curses_win(Y, X, beginY, beginX, char=' ', color=5):
6472
''' empty a part of the screen
@@ -98,6 +106,40 @@ def curses_rgb_to_hex(rgb):
98106
def rgb_to_curses_rgb(rgb):
99107
return tuple(int(y *1000 / 255) for y in rgb)
100108

109+
""" Messages to display when player starts / stops
110+
Used in log to stop runaway threads from printing
111+
messages after playback is stopped """
112+
player_start_stop_token = {
113+
0: M_STRINGS['init_'],
114+
1: ': Playback stopped',
115+
2: ': Player terminated abnormally!',
116+
3: 'Failed to connecto to: ',
117+
403: ': Terminated - Server returned "Forbidden" (error 403)',
118+
404: ': Terminated - Stream not found (error 404)',
119+
503: ': Terminated - Service not available (error 503)',
120+
808: ': Terminated - No stream found',
121+
809: ': Terminated - Connection refused',
122+
810: ': Terminated - Unrecognized file format',
123+
}
124+
125+
class STATES():
126+
ANY = -1
127+
RESET = 0
128+
INIT = 1
129+
CONNECT = 2
130+
BUFFER = 4
131+
BUFF_MSG = 5
132+
PLAY = 10
133+
TITLE = 11
134+
135+
CONNECT_ERROR = 100
136+
VOLUME = 101
137+
138+
ERROR_NO_PLAYER = 200
139+
ERROR_DEPENDENCY = 201
140+
ERROR_CONNECT = 202
141+
ERROR_START = 203
142+
101143

102144
class StationsChanges():
103145
'''

pyradio/config

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ resource_opener = auto
7070
# 4 : Display 12h format, with AM/PM, no seconds
7171
# 5 : Display 12h format, no AM/PM, no seconds
7272
#
73-
# Default value: False (for enable_clock) / 0 (for time_format)
73+
# Default value: False (for enable_clock) / 1 (for time_format)
7474
enable_clock = False
75-
time_format = 0
75+
time_format = 1
7676

7777
# Desktop notifications
7878
# If this option is enabled, a Desktop notification will be displayed using the

pyradio/edit.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .xdg import CheckDir
2222
from .html_help import HtmlHelp
2323
from .keyboard import kbkey, kb2str, kb2chr, check_localized
24+
from .common import M_STRINGS
2425

2526
locale.setlocale(locale.LC_ALL, '') # set your locale
2627

@@ -2291,7 +2292,7 @@ def __init__(self,
22912292
if self._global_functions is None:
22922293
self._global_functions = {}
22932294
self.recording = lambda: self._player.recording
2294-
self._title = ' ' + self._player.PLAYER_NAME + ' Buffering '
2295+
self._title = ' ' + self._player.PLAYER_NAME + ' ' + M_STRINGS['buffering_'].replace(':', '')
22952296
if self._player.PLAYER_NAME == 'mplayer':
22962297
self._text = 'Buffer size in KBytes: '
22972298
self._step = 250

0 commit comments

Comments
 (0)