Skip to content

Commit 480355d

Browse files
committed
- version 0.9.3.11.4 - 0.9.3.12-beta4
- adding --d-player-input command line parameter - refining player error detection mechanism, so that we do not falsely report connection failure - radio.py: renaming stopPlayerFromKeyboard to stopPlayerOnConnectionFailed - log.py: set_win_title will not scan strings any more - fixing not displaying player activation message when player changed - fixing vlc displaying crash error when stopped - updating mpv windows download link
1 parent cb599d1 commit 480355d

21 files changed

+494
-322
lines changed

Changelog

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
2025-01-18 s-n-g
2+
* version 0.9.3.11.4 - 0.9.3.12-beta4
3+
* adding a clock displayed at the beginning of the Status Line
4+
* adding a new system theme: lambda_by_amski1
5+
* all players will try to catch (and display) HTTP errors (403, 404,
6+
503, etc) and player errors through Crash detection
7+
* rearranging options in the Config Window
8+
* the remove control server will be cleanly terminated when the terminal closes
9+
* titles log: fixing a bug that would disallow writing the station name to the log
10+
* when the External Player is used, pyradio will not exit; it will reload the tui
11+
and continue from where it left off
12+
* keep working on keyboard.py
13+
* started working on localized shortcuts
14+
* updating mpv player link on Windows
15+
* fixing issues reported by pylint
16+
* removing more python 2 code
17+
* updating docs
18+
119
2024-12-05 s-n-g
220
* version 0.9.3.11.3 - 0.9.3.12-beta3
321
* fixing a crash when opening RadioBrowser Config

docs/index.html

+33-9
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,24 @@ <h2 id="requirements">Requirements <span style="padding-left: 10px;"><sup style=
191191
<h2 id="changelog">Changelog <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
192192
<pre style="height: 200px;">
193193

194+
2025-01-18 s-n-g
195+
* version 0.9.3.11.4 - 0.9.3.12-beta4
196+
* adding a clock displayed at the beginning of the Status Line
197+
* adding a new system theme: lambda_by_amski1
198+
* all players will try to catch (and display) HTTP errors (403, 404,
199+
503, etc) and player errors through Crash detection
200+
* rearranging options in the Config Window
201+
* the remove control server will be cleanly terminated when the terminal closes
202+
* titles log: fixing a bug that would disallow writing the station name to the log
203+
* when the External Player is used, pyradio will not exit; it will reload the tui
204+
and continue from where it left off
205+
* keep working on keyboard.py
206+
* started working on localized shortcuts
207+
* updating mpv player link on Windows
208+
* fixing issues reported by pylint
209+
* removing more python 2 code
210+
* updating docs
211+
194212
2024-12-05 s-n-g
195213
* version 0.9.3.11.3 - 0.9.3.12-beta3
196214
* fixing a crash when opening RadioBrowser Config
@@ -1338,14 +1356,15 @@ <h2 id="installation">Installation <span style="padding-left: 10px;"><sup style=
13381356
Furthermore, please refrain from using any third-party packaging methods, such as <strong>Snap</strong> or <strong>AppImage</strong>. I am not affiliated with these services or projects, and I cannot guarantee the functionality or version of <strong>PyRadio</strong> provided through them. Additionally, I am unable to offer support for any issues related to these packaging methods.</p>
13391357
<h2 id="command-line-options">Command line options <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
13401358
<pre># pyradio -h
1359+
13411360
Usage: pyradio [-h] [-c CONFIG_DIR] [-p [STATION_NUMBER]] [-x] [-u PLAYER]
1342-
[-l] [-lt] [-sds] [-sd] [-od] [-pc] [-d] [-ul] [-us] [-U] [-R]
1343-
[-V] [-ls] [-s PLAYLIST] [-tlp] [-t THEME] [--show-themes]
1344-
[--no-themes] [--write-theme IN_THEME OUT_THEME,]
1345-
[--terminal TERMINAL] [--terminal-param TERMINAL_PARAM] [-oc]
1346-
[-sc] [-cc] [-gc] [-r] [-or] [-lr] [-mkv MKV_FILE]
1347-
[-scv PNG_FILE] [-srt] [-ach] [--headless IP_AND_PORT]
1348-
[--address] [-fd]
1361+
[-l] [-lt] [-sds] [-sd] [-od] [-pc] [-d]
1362+
[--d-player-input D_PLAYER_INPUT] [-ul] [-us] [-U] [-R] [-V] [-ls]
1363+
[-s PLAYLIST] [-tlp] [-t THEME] [--show-themes] [--no-themes]
1364+
[--write-theme IN_THEME OUT_THEME,] [--terminal TERMINAL]
1365+
[--terminal-param TERMINAL_PARAM] [-oc] [-sc] [-cc] [-gc] [-r]
1366+
[-or] [-lr] [-mkv MKV_FILE] [-scv PNG_FILE] [-srt] [-ach]
1367+
[--headless IP_AND_PORT] [--address] [-fd]
13491368

13501369
Curses based Internet Radio Player
13511370

@@ -1375,6 +1394,10 @@ <h2 id="command-line-options">Command line options <span style="padding-left: 10
13751394
manager.
13761395
-pc, --print-config Print PyRadio config.
13771396
-d, --debug Start PyRadio in debug mode.
1397+
--d-player-input D_PLAYER_INPUT
1398+
When -d is used, this option will not log player input
1399+
(value = 0), log accepted input (value = 1) or raw
1400+
input (value = 2).
13781401
-ul, --unlock Remove sessions&#39; lock file.
13791402
-us, --update-stations
13801403
Update &quot;stations.csv&quot; (if needed).
@@ -2024,7 +2047,7 @@ <h2 id="favorites-playlist">Favorites playlist <span style="padding-left: 10px;"
20242047
<p>The <strong>favorites</strong> playlist, residing in the configuration folder, is a normal playlist in any other respect, which can be subsequently opened, edited, deleted even, as any other playlist.</p>
20252048
<h2 id="displaying-the-current-time">Displaying the Current Time <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
20262049
<p>The <strong>Clock</strong> feature allows you to display the current time in the bottom left corner of the window. This can be helpful for keeping track of time while using the application.</p>
2027-
<p>You can easily toggle the clock display by pressing "\t" (the backslash followed by “<em>t</em>”).</p>
2050+
<p>You can easily toggle the clock display by pressing "\t".</p>
20282051
<h3 id="configuration">Configuration</h3>
20292052
<p>The configuration window has a group labeled “<strong>Clock</strong>, which presents the following options:</p>
20302053
<ul>
@@ -2045,7 +2068,7 @@ <h3 id="configuration">Configuration</h3>
20452068
</tr>
20462069
<tr>
20472070
<td>1</td>
2048-
<td>24-hour format, no seconds</td>
2071+
<td>24-hour format, no seconds (<strong>default</strong>)</td>
20492072
</tr>
20502073
<tr>
20512074
<td>2</td>
@@ -2065,6 +2088,7 @@ <h3 id="configuration">Configuration</h3>
20652088
</tr>
20662089
</tbody>
20672090
</table>
2091+
<p>By default, the <strong>Clock</strong> is turned off, with the default format set to “<em>HH:MM</em>” (value <strong>1</strong>). Enabling the clock will introduce a few additional threads, which may make <strong>PyRadio</strong> slightly heavier than usual.</p>
20682092
<h2 id="pyradio-themes">PyRadio Themes <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
20692093
<p><strong>PyRadio</strong> supports <strong>CSS themes</strong>; it comes with a number of predefined ones and can use external programs that can provide automatically created and updated themes.</p>
20702094
<p>To set a theme you just press “<strong>t</strong>” and</p>

docs/index.md

+16-10
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,15 @@ Furthermore, please refrain from using any third-party packaging methods, such a
131131

132132
```
133133
# pyradio -h
134+
134135
Usage: pyradio [-h] [-c CONFIG_DIR] [-p [STATION_NUMBER]] [-x] [-u PLAYER]
135-
[-l] [-lt] [-sds] [-sd] [-od] [-pc] [-d] [-ul] [-us] [-U] [-R]
136-
[-V] [-ls] [-s PLAYLIST] [-tlp] [-t THEME] [--show-themes]
137-
[--no-themes] [--write-theme IN_THEME OUT_THEME,]
138-
[--terminal TERMINAL] [--terminal-param TERMINAL_PARAM] [-oc]
139-
[-sc] [-cc] [-gc] [-r] [-or] [-lr] [-mkv MKV_FILE]
140-
[-scv PNG_FILE] [-srt] [-ach] [--headless IP_AND_PORT]
141-
[--address] [-fd]
136+
[-l] [-lt] [-sds] [-sd] [-od] [-pc] [-d]
137+
[--d-player-input D_PLAYER_INPUT] [-ul] [-us] [-U] [-R] [-V] [-ls]
138+
[-s PLAYLIST] [-tlp] [-t THEME] [--show-themes] [--no-themes]
139+
[--write-theme IN_THEME OUT_THEME,] [--terminal TERMINAL]
140+
[--terminal-param TERMINAL_PARAM] [-oc] [-sc] [-cc] [-gc] [-r]
141+
[-or] [-lr] [-mkv MKV_FILE] [-scv PNG_FILE] [-srt] [-ach]
142+
[--headless IP_AND_PORT] [--address] [-fd]
142143
143144
Curses based Internet Radio Player
144145
@@ -168,6 +169,10 @@ General options:
168169
manager.
169170
-pc, --print-config Print PyRadio config.
170171
-d, --debug Start PyRadio in debug mode.
172+
--d-player-input D_PLAYER_INPUT
173+
When -d is used, this option will not log player input
174+
(value = 0), log accepted input (value = 1) or raw
175+
input (value = 2).
171176
-ul, --unlock Remove sessions' lock file.
172177
-us, --update-stations
173178
Update "stations.csv" (if needed).
@@ -996,7 +1001,7 @@ The **favorites** playlist, residing in the configuration folder, is a normal pl
9961001

9971002
The **Clock** feature allows you to display the current time in the bottom left corner of the window. This can be helpful for keeping track of time while using the application.
9981003

999-
You can easily toggle the clock display by pressing `"\t"` (the backslash followed by "*t*").
1004+
You can easily toggle the clock display by pressing `"\t"`.
10001005

10011006
### Configuration
10021007

@@ -1006,15 +1011,16 @@ The configuration window has a group labeled "**Clock**, which presents the foll
10061011

10071012
- You can choose how the time is displayed using the "*Time format*" option. Here are the available formats:
10081013

1009-
| Value | Format Description |
1014+
| Value | Format Description |
10101015
|-------|---------------------------------------------|
10111016
| 0 | 24-hour format, with seconds |
1012-
| 1 | 24-hour format, no seconds |
1017+
| 1 | 24-hour format, no seconds (**default**) |
10131018
| 2 | 12-hour format, with AM/PM and seconds |
10141019
| 3 | 12-hour format, no AM/PM, with seconds |
10151020
| 4 | 12-hour format, with AM/PM, no seconds |
10161021
| 5 | 12-hour format, no AM/PM, no seconds |
10171022

1023+
By default, the **Clock** is turned off, with the default format set to "*HH:MM*" (value **1**). Enabling the clock will introduce a few additional threads, which may make **PyRadio** slightly heavier than usual.
10181024

10191025
## PyRadio Themes
10201026

docs/pyradio.1

+7-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ manager.
5151
Print PyRadio sonfig.
5252
.IP\ \fB-d\fR,\ \fB--debug\fR
5353
Start PyRadio in debug mode.
54+
.IP\ \fB--d-player-input\ \fID_PLAYER_INPUT\fR
55+
When \fB-d\fR is used, this option will not log player input (value
56+
= \fI0\fR), log accepted input (value = \fI1\fR) or raw input
57+
(value = \fI2\fR).
5458
.IP\ \fB-ul\fR,\ \fB--unlock\fR
5559
Remove sessions' lock file.
5660
.IP\ \fB-us\fR,\ \fB--update\fR\fB-stations\fR
@@ -1185,6 +1189,8 @@ The \fBfavorites\fR playlist, residing in the configuration folder, is a normal
11851189
.SH Displaying The Current Time
11861190
The \fBClock\fR feature allows you to display the current time in the bottom left corner of the window. This can be helpful for keeping track of time while using the application.
11871191

1192+
By default, the \fBClock\fR is turned off, with the default format set to \fIHH:MM\fR (value \fI1\fR). Enabling the clock will introduce a few additional threads, which may make \fBpyradio\fR slightly heavier than usual.
1193+
11881194
You can easily toggle the clock display by pressing "\fB\\t\fR".
11891195

11901196
.IP \fBConfiguration\fR
@@ -1204,7 +1210,7 @@ center;
12041210
l l.
12051211
\fBValue Format Description\fR
12061212
\fI0\fR 24-hour format, with seconds
1207-
\fI1\fR 24-hour format, no seconds
1213+
\fI1\fR 24-hour format, no seconds (\fIdefault\fR)
12081214
\fI2\fR 12-hour format, with AM/PM and seconds
12091215
\fI3\fR 12-hour format, no AM/PM, with seconds
12101216
\fI4\fR 12-hour format, with AM/PM, no seconds

docs/pyradio_rb.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.\" Copyright (C) 2018-2024 Spiros Georgaras <[email protected]>
1+
.\" Copyright (C) 2018-2025 Spiros Georgaras <[email protected]>
22
.\" This manual is freely distributable under the terms of the GPL.
33
.\"
44
.TH pyradio_rb 1 "June 2024" pyradio

docs/pyradio_server.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.\" Copyright (C) 2018-2024 Spiros Georgaras <[email protected]>
1+
.\" Copyright (C) 2018-2025 Spiros Georgaras <[email protected]>
22
.\" This manual is freely distributable under the terms of the GPL.
33
.\"
44
.TH pyradio_server 1 "June 2024" pyradio

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pyradio"
3-
version = "0.9.3.11.3"
3+
version = "0.9.3.11.4"
44
authors = [
55
{ name="Ben Dowling", email="[email protected]" },
66
{ name="Spiros Georgaras", email="[email protected]" },

pyradio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
" pyradio -- Console radio player. "
33

4-
version_info = (0, 9, 3, 11, 3)
4+
version_info = (0, 9, 3, 11, 4)
55

66
# Set it to True if new stations have been
77
# added to the package's stations.csv

pyradio/client.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from sys import platform
77
from rich import print
88
import requests
9+
from .common import STATES, M_STRINGS
910

1011
def format_list(a_string):
1112
print(a_string.replace(
@@ -105,7 +106,7 @@ def last_reply(self):
105106
out = self._last_reply.splitlines()
106107
out.insert(1, ' Server: ' + self._host + ':' + self._port)
107108
self._last_reply = '\n'.join(out) + '\n'
108-
if 'Title: ' in self._last_reply:
109+
if M_STRINGS['title_'] in self._last_reply:
109110
self._last_reply = re.sub(r'Title: "([^"]*)"', r'Title: "[red3]\1[/red3]"', self._last_reply)
110111
self._last_reply = self._last_reply.replace(r'PyRadio', r'[magenta]PyRadio[/magenta]')
111112
self._last_reply = self._last_reply.replace(r'headless', r'[blue]headless[/blue]')

pyradio/common.py

+65-35
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,84 @@ def BACKGROUND():
2424
BORDER = 3
2525

2626
M_STRINGS = {
27+
'session-locked': ' (Session Locked)',
28+
'session-locked-title': 'Session Locked',
29+
'win-title': 'Your Internet Radio Player',
2730
'init_': 'Initialization: ',
2831
'connecting_': 'Connecting to: ',
29-
'conn-fail_': 'Failed to connect to: ',
3032
'playing_': 'Playing: ',
3133
'buffering_': 'Buffering: ',
3234
'station_': 'Station: ',
35+
'station-open': ' - Opening connection...',
3336
'selected_player_': 'Selected player: ',
3437
'down-icon': 'Downloading icon...',
3538
'player-acivated_': ': Player activated!!!',
3639
'hist-empty': 'History is empty!!!',
3740
'hist-first': 'Already at first item!!!',
3841
'hist-last': 'Already at last item!!!',
42+
'muted': '[Muted] ',
43+
'title_': 'Title: ',
44+
'player-stopped': 'Player is stopped!',
45+
'plb-stopped': 'Playback stopped',
46+
'html-player-stopped': '<div class="alert alert-danger">Player is <b>stopped!</b></div>',
47+
'press-?': ' Press ? for help',
48+
'error-str': 'error',
49+
'error-403': 'Server returned "Forbidden" (error 403)',
50+
'error-404': 'Station does not exist (error 404)',
51+
'error-503': 'Service not available (error 503)',
52+
'error-1000': 'Player terminated abnormally! (error 1000)',
53+
'error-1001': 'Connection failed (error 1001)',
54+
'error-1002': 'No stream found (error 1002)',
55+
'error-1003': 'Connection refused (error 1003)',
56+
'error-1004': 'Unrecognized file format (error 1004)',
57+
'error-1005': 'DNS Resolution failure (error 1005)',
58+
'error-1006': 'Server is unreachable (error 1006)',
59+
'error-1007': 'Permission denied (error 1007)',
60+
'error-1008': 'Unrecognized file format (error 1008)',
3961
}
4062

63+
""" Messages to display when player starts / stops
64+
Used in log to stop runaway threads from printing
65+
messages after playback is stopped """
66+
player_start_stop_token = {
67+
0: M_STRINGS['init_'],
68+
1: M_STRINGS['plb-stopped'],
69+
3: M_STRINGS['player-acivated_'],
70+
403: M_STRINGS['error-403'],
71+
404: M_STRINGS['error-404'],
72+
503: M_STRINGS['error-503'],
73+
1000: M_STRINGS['error-1000'],
74+
1001: M_STRINGS['error-1001'],
75+
1002: M_STRINGS['error-1002'],
76+
1003: M_STRINGS['error-1003'],
77+
1004: M_STRINGS['error-1004'],
78+
1005: M_STRINGS['error-1005'],
79+
1006: M_STRINGS['error-1006'],
80+
1007: M_STRINGS['error-1007'],
81+
1008: M_STRINGS['error-1008'],
82+
}
83+
84+
class STATES():
85+
ANY = -1
86+
RESET = 0
87+
INIT = 1
88+
CONNECT = 2
89+
BUFFER = 4
90+
BUFF_MSG = 5
91+
PLAY = 10
92+
TITLE = 11
93+
STOPPED = 12
94+
# Do not move it!
95+
PLAYER_ACTIVATED = 13
96+
97+
CONNECT_ERROR = 100
98+
VOLUME = 101
99+
100+
ERROR_NO_PLAYER = 200
101+
ERROR_DEPENDENCY = 201
102+
ERROR_CONNECT = 202
103+
ERROR_START = 203
104+
41105
"""
42106
Format of theme configuration
43107
Name, color_pair, foreground, background
@@ -106,40 +170,6 @@ def curses_rgb_to_hex(rgb):
106170
def rgb_to_curses_rgb(rgb):
107171
return tuple(int(y *1000 / 255) for y in rgb)
108172

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-
143173

144174
class StationsChanges():
145175
'''

pyradio/config

+1-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ remove_station_icons = True
108108
# PyRadio will wait for this number of seconds to get a station/server message
109109
# indicating that playback has actually started. If this does not happen
110110
# (within this number of seconds after the connection is initiated), PyRadio
111-
# will consider the station unreachable, and display the "Failed to connect to:
112-
# [station]" message.
111+
# will consider the station unreachable, and display a relevant message.
113112
#
114113
# Valid values: 5 - 60, 0 disables check
115114
# Default value: 10

pyradio/config.py

+10
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,16 @@ def find_history_by_station_title(self, a_title):
12701270
class PyRadioConfig(PyRadioStations):
12711271
''' PyRadio Config Class '''
12721272

1273+
''' if degub is on, this will tell the logger to
1274+
0: not log input from the player
1275+
1: input accepted input from the player
1276+
2: input raw input from the player
1277+
1278+
It applies to the updateStatus, updateMPVStatus and
1279+
updateWinVLCStatus functions
1280+
'''
1281+
debug_log_player_input = 0
1282+
12731283
localize = None
12741284
_old_localize = None
12751285

0 commit comments

Comments
 (0)