Skip to content

Commit

Permalink
- always have Crash detection enabled; changing random playback
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
s-n-g committed Jan 13, 2025
1 parent 76f5ba2 commit cb599d1
Show file tree
Hide file tree
Showing 7 changed files with 465 additions and 210 deletions.
56 changes: 49 additions & 7 deletions pyradio/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ def BACKGROUND():
CAPTION = 2
BORDER = 3

M_STRINGS = {
'init_': 'Initialization: ',
'connecting_': 'Connecting to: ',
'conn-fail_': 'Failed to connect to: ',
'playing_': 'Playing: ',
'buffering_': 'Buffering: ',
'station_': 'Station: ',
'selected_player_': 'Selected player: ',
'down-icon': 'Downloading icon...',
'player-acivated_': ': Player activated!!!',
'hist-empty': 'History is empty!!!',
'hist-first': 'Already at first item!!!',
'hist-last': 'Already at last item!!!',
}

"""
Format of theme configuration
Name, color_pair, foreground, background
Expand Down Expand Up @@ -52,13 +67,6 @@ def BACKGROUND():
('Edit Cursor', 8, 0, 0)
)

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

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

""" Messages to display when player starts / stops
Used in log to stop runaway threads from printing
messages after playback is stopped """
player_start_stop_token = {
0: M_STRINGS['init_'],
1: ': Playback stopped',
2: ': Player terminated abnormally!',
3: 'Failed to connecto to: ',
403: ': Terminated - Server returned "Forbidden" (error 403)',
404: ': Terminated - Stream not found (error 404)',
503: ': Terminated - Service not available (error 503)',
808: ': Terminated - No stream found',
809: ': Terminated - Connection refused',
810: ': Terminated - Unrecognized file format',
}

class STATES():
ANY = -1
RESET = 0
INIT = 1
CONNECT = 2
BUFFER = 4
BUFF_MSG = 5
PLAY = 10
TITLE = 11

CONNECT_ERROR = 100
VOLUME = 101

ERROR_NO_PLAYER = 200
ERROR_DEPENDENCY = 201
ERROR_CONNECT = 202
ERROR_START = 203


class StationsChanges():
'''
Expand Down
4 changes: 2 additions & 2 deletions pyradio/config
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ resource_opener = auto
# 4 : Display 12h format, with AM/PM, no seconds
# 5 : Display 12h format, no AM/PM, no seconds
#
# Default value: False (for enable_clock) / 0 (for time_format)
# Default value: False (for enable_clock) / 1 (for time_format)
enable_clock = False
time_format = 0
time_format = 1

# Desktop notifications
# If this option is enabled, a Desktop notification will be displayed using the
Expand Down
3 changes: 2 additions & 1 deletion pyradio/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .xdg import CheckDir
from .html_help import HtmlHelp
from .keyboard import kbkey, kb2str, kb2chr, check_localized
from .common import M_STRINGS

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

Expand Down Expand Up @@ -2291,7 +2292,7 @@ def __init__(self,
if self._global_functions is None:
self._global_functions = {}
self.recording = lambda: self._player.recording
self._title = ' ' + self._player.PLAYER_NAME + ' Buffering '
self._title = ' ' + self._player.PLAYER_NAME + ' ' + M_STRINGS['buffering_'].replace(':', '')
if self._player.PLAYER_NAME == 'mplayer':
self._text = 'Buffer size in KBytes: '
self._step = 250
Expand Down
Loading

0 comments on commit cb599d1

Please # to comment.