Skip to content

Commit

Permalink
- version 0.9.3.11.4 - 0.9.3.12-beta4
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
s-n-g committed Jan 18, 2025
1 parent cb599d1 commit 480355d
Show file tree
Hide file tree
Showing 21 changed files with 494 additions and 322 deletions.
18 changes: 18 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
2025-01-18 s-n-g
* version 0.9.3.11.4 - 0.9.3.12-beta4
* adding a clock displayed at the beginning of the Status Line
* adding a new system theme: lambda_by_amski1
* all players will try to catch (and display) HTTP errors (403, 404,
503, etc) and player errors through Crash detection
* rearranging options in the Config Window
* the remove control server will be cleanly terminated when the terminal closes
* titles log: fixing a bug that would disallow writing the station name to the log
* when the External Player is used, pyradio will not exit; it will reload the tui
and continue from where it left off
* keep working on keyboard.py
* started working on localized shortcuts
* updating mpv player link on Windows
* fixing issues reported by pylint
* removing more python 2 code
* updating docs

2024-12-05 s-n-g
* version 0.9.3.11.3 - 0.9.3.12-beta3
* fixing a crash when opening RadioBrowser Config
Expand Down
42 changes: 33 additions & 9 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,24 @@ <h2 id="requirements">Requirements <span style="padding-left: 10px;"><sup style=
<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>
<pre style="height: 200px;">

2025-01-18 s-n-g
* version 0.9.3.11.4 - 0.9.3.12-beta4
* adding a clock displayed at the beginning of the Status Line
* adding a new system theme: lambda_by_amski1
* all players will try to catch (and display) HTTP errors (403, 404,
503, etc) and player errors through Crash detection
* rearranging options in the Config Window
* the remove control server will be cleanly terminated when the terminal closes
* titles log: fixing a bug that would disallow writing the station name to the log
* when the External Player is used, pyradio will not exit; it will reload the tui
and continue from where it left off
* keep working on keyboard.py
* started working on localized shortcuts
* updating mpv player link on Windows
* fixing issues reported by pylint
* removing more python 2 code
* updating docs

2024-12-05 s-n-g
* version 0.9.3.11.3 - 0.9.3.12-beta3
* fixing a crash when opening RadioBrowser Config
Expand Down Expand Up @@ -1338,14 +1356,15 @@ <h2 id="installation">Installation <span style="padding-left: 10px;"><sup style=
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>
<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>
<pre># pyradio -h

Usage: pyradio [-h] [-c CONFIG_DIR] [-p [STATION_NUMBER]] [-x] [-u PLAYER]
[-l] [-lt] [-sds] [-sd] [-od] [-pc] [-d] [-ul] [-us] [-U] [-R]
[-V] [-ls] [-s PLAYLIST] [-tlp] [-t THEME] [--show-themes]
[--no-themes] [--write-theme IN_THEME OUT_THEME,]
[--terminal TERMINAL] [--terminal-param TERMINAL_PARAM] [-oc]
[-sc] [-cc] [-gc] [-r] [-or] [-lr] [-mkv MKV_FILE]
[-scv PNG_FILE] [-srt] [-ach] [--headless IP_AND_PORT]
[--address] [-fd]
[-l] [-lt] [-sds] [-sd] [-od] [-pc] [-d]
[--d-player-input D_PLAYER_INPUT] [-ul] [-us] [-U] [-R] [-V] [-ls]
[-s PLAYLIST] [-tlp] [-t THEME] [--show-themes] [--no-themes]
[--write-theme IN_THEME OUT_THEME,] [--terminal TERMINAL]
[--terminal-param TERMINAL_PARAM] [-oc] [-sc] [-cc] [-gc] [-r]
[-or] [-lr] [-mkv MKV_FILE] [-scv PNG_FILE] [-srt] [-ach]
[--headless IP_AND_PORT] [--address] [-fd]

Curses based Internet Radio Player

Expand Down Expand Up @@ -1375,6 +1394,10 @@ <h2 id="command-line-options">Command line options <span style="padding-left: 10
manager.
-pc, --print-config Print PyRadio config.
-d, --debug Start PyRadio in debug mode.
--d-player-input D_PLAYER_INPUT
When -d is used, this option will not log player input
(value = 0), log accepted input (value = 1) or raw
input (value = 2).
-ul, --unlock Remove sessions&#39; lock file.
-us, --update-stations
Update &quot;stations.csv&quot; (if needed).
Expand Down Expand Up @@ -2024,7 +2047,7 @@ <h2 id="favorites-playlist">Favorites playlist <span style="padding-left: 10px;"
<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>
<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>
<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>
<p>You can easily toggle the clock display by pressing "\t" (the backslash followed by “<em>t</em>”).</p>
<p>You can easily toggle the clock display by pressing "\t".</p>
<h3 id="configuration">Configuration</h3>
<p>The configuration window has a group labeled “<strong>Clock</strong>, which presents the following options:</p>
<ul>
Expand All @@ -2045,7 +2068,7 @@ <h3 id="configuration">Configuration</h3>
</tr>
<tr>
<td>1</td>
<td>24-hour format, no seconds</td>
<td>24-hour format, no seconds (<strong>default</strong>)</td>
</tr>
<tr>
<td>2</td>
Expand All @@ -2065,6 +2088,7 @@ <h3 id="configuration">Configuration</h3>
</tr>
</tbody>
</table>
<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>
<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>
<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>
<p>To set a theme you just press “<strong>t</strong>” and</p>
Expand Down
26 changes: 16 additions & 10 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,15 @@ Furthermore, please refrain from using any third-party packaging methods, such a

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

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.

You can easily toggle the clock display by pressing `"\t"` (the backslash followed by "*t*").
You can easily toggle the clock display by pressing `"\t"`.

### Configuration

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

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

| Value | Format Description |
| Value | Format Description |
|-------|---------------------------------------------|
| 0 | 24-hour format, with seconds |
| 1 | 24-hour format, no seconds |
| 1 | 24-hour format, no seconds (**default**) |
| 2 | 12-hour format, with AM/PM and seconds |
| 3 | 12-hour format, no AM/PM, with seconds |
| 4 | 12-hour format, with AM/PM, no seconds |
| 5 | 12-hour format, no AM/PM, no seconds |

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.

## PyRadio Themes

Expand Down
8 changes: 7 additions & 1 deletion docs/pyradio.1
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ manager.
Print PyRadio sonfig.
.IP\ \fB-d\fR,\ \fB--debug\fR
Start PyRadio in debug mode.
.IP\ \fB--d-player-input\ \fID_PLAYER_INPUT\fR
When \fB-d\fR is used, this option will not log player input (value
= \fI0\fR), log accepted input (value = \fI1\fR) or raw input
(value = \fI2\fR).
.IP\ \fB-ul\fR,\ \fB--unlock\fR
Remove sessions' lock file.
.IP\ \fB-us\fR,\ \fB--update\fR\fB-stations\fR
Expand Down Expand Up @@ -1185,6 +1189,8 @@ The \fBfavorites\fR playlist, residing in the configuration folder, is a normal
.SH Displaying The Current Time
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.

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.

You can easily toggle the clock display by pressing "\fB\\t\fR".

.IP \fBConfiguration\fR
Expand All @@ -1204,7 +1210,7 @@ center;
l l.
\fBValue Format Description\fR
\fI0\fR 24-hour format, with seconds
\fI1\fR 24-hour format, no seconds
\fI1\fR 24-hour format, no seconds (\fIdefault\fR)
\fI2\fR 12-hour format, with AM/PM and seconds
\fI3\fR 12-hour format, no AM/PM, with seconds
\fI4\fR 12-hour format, with AM/PM, no seconds
Expand Down
2 changes: 1 addition & 1 deletion docs/pyradio_rb.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" Copyright (C) 2018-2024 Spiros Georgaras <sng@hellug.gr>
.\" Copyright (C) 2018-2025 Spiros Georgaras <sng@hellug.gr>
.\" This manual is freely distributable under the terms of the GPL.
.\"
.TH pyradio_rb 1 "June 2024" pyradio
Expand Down
2 changes: 1 addition & 1 deletion docs/pyradio_server.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" Copyright (C) 2018-2024 Spiros Georgaras <sng@hellug.gr>
.\" Copyright (C) 2018-2025 Spiros Georgaras <sng@hellug.gr>
.\" This manual is freely distributable under the terms of the GPL.
.\"
.TH pyradio_server 1 "June 2024" pyradio
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pyradio"
version = "0.9.3.11.3"
version = "0.9.3.11.4"
authors = [
{ name="Ben Dowling", email="ben.m.dowling@gmail.com" },
{ name="Spiros Georgaras", email="sng@hellug.gr" },
Expand Down
2 changes: 1 addition & 1 deletion pyradio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
" pyradio -- Console radio player. "

version_info = (0, 9, 3, 11, 3)
version_info = (0, 9, 3, 11, 4)

# Set it to True if new stations have been
# added to the package's stations.csv
Expand Down
3 changes: 2 additions & 1 deletion pyradio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from sys import platform
from rich import print
import requests
from .common import STATES, M_STRINGS

def format_list(a_string):
print(a_string.replace(
Expand Down Expand Up @@ -105,7 +106,7 @@ def last_reply(self):
out = self._last_reply.splitlines()
out.insert(1, ' Server: ' + self._host + ':' + self._port)
self._last_reply = '\n'.join(out) + '\n'
if 'Title: ' in self._last_reply:
if M_STRINGS['title_'] in self._last_reply:
self._last_reply = re.sub(r'Title: "([^"]*)"', r'Title: "[red3]\1[/red3]"', self._last_reply)
self._last_reply = self._last_reply.replace(r'PyRadio', r'[magenta]PyRadio[/magenta]')
self._last_reply = self._last_reply.replace(r'headless', r'[blue]headless[/blue]')
Expand Down
100 changes: 65 additions & 35 deletions pyradio/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,84 @@ def BACKGROUND():
BORDER = 3

M_STRINGS = {
'session-locked': ' (Session Locked)',
'session-locked-title': 'Session Locked',
'win-title': 'Your Internet Radio Player',
'init_': 'Initialization: ',
'connecting_': 'Connecting to: ',
'conn-fail_': 'Failed to connect to: ',
'playing_': 'Playing: ',
'buffering_': 'Buffering: ',
'station_': 'Station: ',
'station-open': ' - Opening connection...',
'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!!!',
'muted': '[Muted] ',
'title_': 'Title: ',
'player-stopped': 'Player is stopped!',
'plb-stopped': 'Playback stopped',
'html-player-stopped': '<div class="alert alert-danger">Player is <b>stopped!</b></div>',
'press-?': ' Press ? for help',
'error-str': 'error',
'error-403': 'Server returned "Forbidden" (error 403)',
'error-404': 'Station does not exist (error 404)',
'error-503': 'Service not available (error 503)',
'error-1000': 'Player terminated abnormally! (error 1000)',
'error-1001': 'Connection failed (error 1001)',
'error-1002': 'No stream found (error 1002)',
'error-1003': 'Connection refused (error 1003)',
'error-1004': 'Unrecognized file format (error 1004)',
'error-1005': 'DNS Resolution failure (error 1005)',
'error-1006': 'Server is unreachable (error 1006)',
'error-1007': 'Permission denied (error 1007)',
'error-1008': 'Unrecognized file format (error 1008)',
}

""" 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: M_STRINGS['plb-stopped'],
3: M_STRINGS['player-acivated_'],
403: M_STRINGS['error-403'],
404: M_STRINGS['error-404'],
503: M_STRINGS['error-503'],
1000: M_STRINGS['error-1000'],
1001: M_STRINGS['error-1001'],
1002: M_STRINGS['error-1002'],
1003: M_STRINGS['error-1003'],
1004: M_STRINGS['error-1004'],
1005: M_STRINGS['error-1005'],
1006: M_STRINGS['error-1006'],
1007: M_STRINGS['error-1007'],
1008: M_STRINGS['error-1008'],
}

class STATES():
ANY = -1
RESET = 0
INIT = 1
CONNECT = 2
BUFFER = 4
BUFF_MSG = 5
PLAY = 10
TITLE = 11
STOPPED = 12
# Do not move it!
PLAYER_ACTIVATED = 13

CONNECT_ERROR = 100
VOLUME = 101

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

"""
Format of theme configuration
Name, color_pair, foreground, background
Expand Down Expand Up @@ -106,40 +170,6 @@ 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
3 changes: 1 addition & 2 deletions pyradio/config
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ remove_station_icons = True
# PyRadio will wait for this number of seconds to get a station/server message
# indicating that playback has actually started. If this does not happen
# (within this number of seconds after the connection is initiated), PyRadio
# will consider the station unreachable, and display the "Failed to connect to:
# [station]" message.
# will consider the station unreachable, and display a relevant message.
#
# Valid values: 5 - 60, 0 disables check
# Default value: 10
Expand Down
10 changes: 10 additions & 0 deletions pyradio/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,16 @@ def find_history_by_station_title(self, a_title):
class PyRadioConfig(PyRadioStations):
''' PyRadio Config Class '''

''' if degub is on, this will tell the logger to
0: not log input from the player
1: input accepted input from the player
2: input raw input from the player
It applies to the updateStatus, updateMPVStatus and
updateWinVLCStatus functions
'''
debug_log_player_input = 0

localize = None
_old_localize = None

Expand Down
Loading

0 comments on commit 480355d

Please # to comment.