Skip to content

Commit 52b0a5b

Browse files
committed
- version 0.9.3.10
- remove ~/pyradio-recordings at startup, if empty - recording and titles' log functions will create recordings dir if it does not exist
1 parent 3fc0147 commit 52b0a5b

File tree

15 files changed

+258
-58
lines changed

15 files changed

+258
-58
lines changed

Changelog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2024-08-30 s-n-g
2+
* version 0.9.3.10
3+
* do not enable xdg compliant if user_config_dir is specified
4+
* do not create the default recording directory until it is
5+
actually needed (to save data in it)
6+
* when saving players' extra parameters reduce the list by removing
7+
the unused porifles from the list
8+
* Fixing player_params_file and schedule_file location when XDG
9+
compliance is ON
10+
* fixing a pyradio-client crash when no command is specified
11+
* fixing: MPV Volume resets to 0% when trying to increase
12+
beyond maximum #251
13+
* fixing a help crash: adding H_CONFIG_PLAYER help key
14+
* added a gruvbox variation system theme
15+
* updating docs and fixing broken links
16+
117
2024-06-04 s-n-g
218
* version 0.9.3.9
319
* fixing a crash when adding a station to favorites

docs/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,22 @@ <h2 id="requirements">Requirements <span style="padding-left: 10px;"><sup style=
215215
<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>
216216
<pre style="height: 200px;">
217217

218+
2024-08-30 s-n-g
219+
* version 0.9.3.10
220+
* do not enable xdg compliant if user_config_dir is specified
221+
* do not create the default recording directory until it is
222+
actually needed (to save data in it)
223+
* when saving players' extra parameters reduce the list by removing
224+
the unused porifles from the list
225+
* Fixing player_params_file and schedule_file location when XDG
226+
compliance is ON
227+
* fixing a pyradio-client crash when no command is specified
228+
* fixing: MPV Volume resets to 0% when trying to increase
229+
beyond maximum #251
230+
* fixing a help crash: adding H_CONFIG_PLAYER help key
231+
* added a gruvbox variation system theme
232+
* updating docs and fixing broken links
233+
218234
2024-06-04 s-n-g
219235
* version 0.9.3.9
220236
* fixing a crash when adding a station to favorites

docs/pyradio.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,8 +1220,8 @@ Two themes by \fBedunfelt\fR (\fIhttps://github.com/edunfelt\fR) inspired by the
12201220
.IP \fBdracula_by_Plyply99\fR
12211221
A theme based of the Dracula theme by \fBPlyply99\fR (\fIhttps://github.com/Plyply99\fR).
12221222

1223-
.IP \fBgruvbox_dark_by_sng\fR\ and\ \fBgruvbox_light_by_sng\fR
1224-
Two themes based on the \fBgruvbox\fR (\fIhttps://github.com/morhetz/gruvbox\fR) theme.
1223+
.IP \fBgruvbox_dark_by_farparticul\fR,\ \fBgruvbox_dark_by_sng\fR\ and\ \fBgruvbox_light_by_sng\fR
1224+
Three themes based on the \fBgruvbox\fR (\fIhttps://github.com/morhetz/gruvbox\fR) theme.
12251225

12261226
.IP \fBhyprland_amber_gold\fR\ and\ \fBhyprland_dracula\fR
12271227
Two themes by \fBmechatour\fR (\fIhttps://github.com/mechatour\fR), from \fBhyprland_amber_gold\fR (\fIhttps://github.com/mechatour/hyprland_amber_gold\fR) and \fBhyprland_dotfiles\fR (\fI[https://github.com/mechatour/hyprland_dotfiles\fR).

docs/rec-dir.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,15 @@ <h2 id="pre-0.9.3-installation-behavior">Pre 0.9.3 installation behavior <span s
8787
<p>Pre 0.9.3 installations will use ~/.config/pyradio/data/recordings as the recording directory, by default.</p>
8888
<p>After updating to v. 0.9.3 (and newer), <strong>PyRadio</strong> will move this directory to the user’s home folder and rename it to “<strong>pyradio-recordings</strong>”.</p>
8989
<p>Then the user can change the folder’s location from <em>Config / General options / Recording dir</em>.</p>
90+
<h2 id="post-0.9.3.10-behavior">Post 0.9.3.10 behavior <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
91+
<p>Up until <strong>v. 0.9.3.10, Ryradio</strong> would create the “<em>recording directory</em>” upon startup, no matter where it would be located, making it available for the recording and titles’ log function.</p>
92+
<p>This eventually creates the following problem:</p>
93+
<p>A user who never wants to use the recording or the titles’ log function, ends up with an empty directory in his home folder, which will be recreated every time <strong>PyRadio</strong> is executed (even if deleted before that), as described in <a target="_blank" href="https://github.com/coderholic/pyradio/issues/253">issue No. 253</a>.</p>
94+
<p>The solution is that <strong>PyRadio</strong> will remove the “<em>recording directory</em>” upon execution, if</p>
95+
<ol type="1">
96+
<li>the default location is used</li>
97+
<li>the directory is empty</li>
98+
</ol>
99+
<p>As a consequence, both the recording and the titles’ log function will make sure the directory actually exists (and create it if it does not), before trying to save any data to it.</p>
90100
</body>
91101
</html>

docs/rec-dir.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,17 @@ After updating to v. 0.9.3 (and newer), **PyRadio** will move this directory to
3939

4040
Then the user can change the folder's location from *Config / General options / Recording dir*.
4141

42+
## Post 0.9.3.10 behavior
43+
44+
Up until **v. 0.9.3.10, Ryradio** would create the "*recording directory*" upon startup, no matter where it would be located, making it available for the recording and titles' log function.
45+
46+
This eventually creates the following problem:
47+
48+
A user who never wants to use the recording or the titles' log function, ends up with an empty directory in his home folder, which will be recreated every time **PyRadio** is executed (even if deleted before that), as described in [issue No. 253](https://github.com/coderholic/pyradio/issues/253).
49+
50+
The solution is that **PyRadio** will remove the "*recording directory*" upon execution, if
51+
52+
1. the default location is used
53+
2. the directory is empty
54+
55+
As a consequence, both the recording and the titles' log function will make sure the directory actually exists (and create it if it does not), before trying to save any data to it.

docs/themes.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ <h2 id="table-of-contents">Table of Contents <span style="padding-left: 10px;"><
4545
<ul>
4646
<li><a href="#pyradio-themes">PyRadio Themes</a>
4747
<ul>
48-
<li><a href="#virtual-terminal-restrictions">Virtual terminal restrictions</a></li>
48+
<li><a href="#virtual-terminal-restrictions">Virtual terminal restrictions</a>
49+
<ul>
50+
<li><a href="#workaround-for-not-supported-terminals">Workaround for not supported terminals</a></li>
51+
</ul></li>
4952
<li><a href="#css-color-themes-restrictions">CSS color themes restrictions</a></li>
5053
<li><a href="#secondary-windows-background">Secondary windows background</a>
5154
<ul>
@@ -108,8 +111,8 @@ <h2 id="pyradio-themes-1">PyRadio Themes <span style="padding-left: 10px;"><sup
108111
Two themes by <a target="_blank" href="https://github.com/edunfelt">edunfelt</a> inspired by the <a target="_blank" href="https://github.com/base16-project">base16</a> project.</li>
109112
<li><strong>dracula_by_Plyply99</strong><br />
110113
A theme based of the Dracula theme by <a target="_blank" href="https://github.com/Plyply99">Plyply99</a>.</li>
111-
<li><strong>gruvbox_dark_by_sng</strong> and <strong>gruvbox_light_by_sng</strong><br />
112-
Two themes based on the <a target="_blank" href="https://github.com/morhetz/gruvbox">gruvbox</a> theme.</li>
114+
<li><em>gruvbox_dark_by_farparticul</em>, <strong>gruvbox_dark_by_sng</strong> and <strong>gruvbox_light_by_sng</strong><br />
115+
Three themes based on the <a target="_blank" href="https://github.com/morhetz/gruvbox">gruvbox</a> theme.</li>
113116
<li><strong>hyprland_amber_gold</strong> and <strong>hyprland_dracula</strong><br />
114117
Two themes by <a target="_blank" href="https://github.com/mechatour">mechatour</a>, from <a target="_blank" href="https://github.com/mechatour/hyprland_amber_gold">hyprland_amber_gold</a> and <a href="%5Bhttps://github.com/mechatour/hyprland_dotfiles">hyprland_dotfiles</a>.</li>
115118
<li><strong>minima_by_ben_chile</strong><br />
@@ -180,6 +183,12 @@ <h3 id="virtual-terminal-restrictions">Virtual terminal restrictions</h3>
180183
<p><strong>PyRadio</strong> will try to detect these terminals and disable themes (after displaying a relative message). Then the default theme will be used.</p>
181184
<p>Some of the terminals that work ok, are: <em>gnome-terminal</em>, <em>mate-terminal</em>, <em>xfce4-terminal</em>, <em>lxterminal</em>, <em>terminator</em>, <em>termite</em>, <em>kitty</em>, <em>alacritty</em>, <em>sakura</em>, <em>roxterm</em>, <em>tilix</em>, <em>lilyterm</em>, <em>st</em>, <em>xst</em>, <em>rxvt</em>, <em>urxvt</em>, <em>uxterm</em>, <em>xterm</em>.</p>
182185
<p>If you want to make <strong>PyRadio</strong> start in one of these terminal, just follow the instructions given at <a href="#specifying-the-terminal-to-use">Desktop File: Specifying the terminal to use</a>.</p>
186+
<h4 id="workaround-for-not-supported-terminals">Workaround for not supported terminals</h4>
187+
<p>Thanks to github user <a target="_blank" href="https://github.com/troyvit">troyvit</a>, it is now possible to use <strong>PyRadio</strong> with full color support on most of the terminals that originally will not display colors correctly.</p>
188+
<p>Following his <a target="_blank" href="https://github.com/coderholic/pyradio/issues/254">report</a>, which proposes to execute <strong>PyRadio</strong> within a <a target="_blank" href="https://github.com/tmux/tmux/wiki">tmux</a> session, a <a target="_blank" href="https://gist.github.com/s-n-g/2f1ef5c764222d26e5bb0075b2adddb1">bash srciprt</a> has been written to accomplish the task: it is called “<strong>tmux_pyradio</strong>” and comes in the form of a github gist.</p>
189+
<p>Using “<strong>tmux_pyradio</strong>” on can execute <strong>PyRadio</strong> in any terminal (it has been tested in all the terminals referenced above); one can even run a second <strong>PyRadio</strong> instance throught it. For more info, download it and execute:</p>
190+
<pre>tmux_pyradio -h</pre>
191+
<p>There is a catch though; if <strong>PyRadio</strong> terminates prematurely, the output will not be visible to the user, since <strong>tmux</strong> will also terminate and clear the screen on exit. In this case, just add a “<em>-d</em>” before a “<em></em>” (or combine it with the custom tmux session name). Yhis will add a <em>pause</em> before exiting <strong>tmux</strong>, so you can observe the output.</p>
183192
<h3 id="css-color-themes-restrictions">CSS color themes restrictions</h3>
184193
<p>Using CSS colors imposes a couple of restrictions on the type of terminals <strong>PyRadio</strong> will be able to run:</p>
185194
<ol type="1">

docs/themes.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
* [PyRadio Themes](#pyradio-themes)
77
* [Virtual terminal restrictions](#virtual-terminal-restrictions)
8+
* [Workaround for not supported terminals](#workaround-for-not-supported-terminals)
89
* [CSS color themes restrictions](#css-color-themes-restrictions)
910
* [Secondary windows background](#secondary-windows-background)
1011
* [Theme defined secondary windows color](#theme-defined-secondary-windows-color)
@@ -57,8 +58,8 @@ A clasic theme by [The OpenBSD Guy](https://github.com/OpenBSDGuy), originally c
5758
Two themes by [edunfelt](https://github.com/edunfelt) inspired by the [base16](https://github.com/base16-project) project.
5859
- **dracula_by_Plyply99** \
5960
A theme based of the Dracula theme by [Plyply99](https://github.com/Plyply99).
60-
- **gruvbox_dark_by_sng** and **gruvbox_light_by_sng** \
61-
Two themes based on the [gruvbox](https://github.com/morhetz/gruvbox) theme.
61+
- *gruvbox_dark_by_farparticul*, **gruvbox_dark_by_sng** and **gruvbox_light_by_sng** \
62+
Three themes based on the [gruvbox](https://github.com/morhetz/gruvbox) theme.
6263
- **hyprland_amber_gold** and **hyprland_dracula** \
6364
Two themes by [mechatour](https://github.com/mechatour), from [hyprland_amber_gold](https://github.com/mechatour/hyprland_amber_gold) and [hyprland_dotfiles]([https://github.com/mechatour/hyprland_dotfiles).
6465
- **minima_by_ben_chile** \
@@ -146,6 +147,18 @@ Some of the terminals that work ok, are: *gnome-terminal*, *mate-terminal*, *xfc
146147

147148
If you want to make **PyRadio** start in one of these terminal, just follow the instructions given at [Desktop File: Specifying the terminal to use](#specifying-the-terminal-to-use).
148149

150+
#### Workaround for not supported terminals
151+
152+
Thanks to github user [troyvit](https://github.com/troyvit), it is now possible to use **PyRadio** with full color support on most of the terminals that originally will not display colors correctly.
153+
154+
Following his [report](https://github.com/coderholic/pyradio/issues/254), which proposes to execute **PyRadio** within a [tmux](https://github.com/tmux/tmux/wiki) session, a [bash srciprt](https://gist.github.com/s-n-g/2f1ef5c764222d26e5bb0075b2adddb1) has been written to accomplish the task: it is called "**tmux_pyradio**" and comes in the form of a github gist.
155+
156+
Using "**tmux_pyradio**" on can execute **PyRadio** in any terminal (it has been tested in all the terminals referenced above); one can even run a second **PyRadio** instance throught it. For more info, download it and execute:
157+
158+
tmux_pyradio -h
159+
160+
There is a catch though; if **PyRadio** terminates prematurely, the output will not be visible to the user, since **tmux** will also terminate and clear the screen on exit. In this case, just add a "*-d*" before a "*--*" (or combine it with the custom tmux session name). Yhis will add a *pause* before exiting **tmux**, so you can observe the output.
161+
149162
### CSS color themes restrictions
150163

151164
Using CSS colors imposes a couple of restrictions on the type of terminals **PyRadio** will be able to run:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pyradio"
3-
version = "0.9.3.9"
3+
version = "0.9.3.10"
44
authors = [
55
{ name="Ben Dowling", email="[email protected]" },
66
{ name="Spiros Georgaras", email="[email protected]" },

pyradio/__init__.py

Lines changed: 1 addition & 1 deletion
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, 9)
4+
version_info = (0, 9, 3, 10)
55

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

pyradio/config.py

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,23 +2420,25 @@ def _read_config(self, distro_config=False):
24202420
except:
24212421
pass
24222422
self._first_read = False
2423-
logger.error('\n\nfile = {0}\nplayer extra params = {1}\n\n'.format(self.player_params_file, self.params))
2423+
# logger.error('\n\nfile = {0}\nplayer extra params = {1}\n\n'.format(self.player_params_file, self.params))
24242424

24252425
# do this here to get proper schedule config filepath if XDG is on
24262426
self.schedule_file = path.join(self.data_dir, 'schedule.json')
24272427

24282428

24292429
def _make_sure_dirs_exist(self):
2430+
home_rec_dir = path.join(path.expanduser('~'), 'pyradio-recordings')
24302431
if self.opts['recording_dir'][1] == '':
24312432
self.opts['recording_dir'][1] = path.join(path.expanduser('~'), 'pyradio-recordings')
24322433
ch_dir = CheckDir(
24332434
self.opts['recording_dir'][1],
2434-
path.join(path.expanduser('~'), 'pyradio-recordings')
2435+
home_rec_dir,
2436+
remove_after_validation=True
24352437
)
2436-
if not ch_dir.is_dir:
2438+
if not ch_dir.can_be_created:
24372439
print('Error: Recordings directory is for a folder: "{}"'.format(self.opts['recording_dir'][1]))
24382440
sys.exit(1)
2439-
elif not ch_dir.is_writable:
2441+
elif not ch_dir.can_be_writable:
24402442
print('Error: Recordings directory is not writable: "{}"'.format(self.opts['recording_dir'][1]))
24412443
sys.exit(1)
24422444

@@ -2462,6 +2464,12 @@ def _make_sure_dirs_exist(self):
24622464
first_read=path.join(self.stations_dir, 'data', 'recordings')
24632465
)
24642466

2467+
# remove recordings dir from home dir if it is empty, as per #253
2468+
if path.exists(self.opts['recording_dir'][1]) and \
2469+
self.opts['recording_dir'][1] == home_rec_dir and \
2470+
len(listdir(self.opts['recording_dir'][1])) == 0:
2471+
remove_tree(self.opts['recording_dir'][1])
2472+
24652473
def get_last_playlist(self):
24662474
''' read last opened playlist
24672475
reads: ~/pyradio/last_playlist
@@ -3360,24 +3368,37 @@ def configure_logger(self, recording_dir=None, debug=None, titles=None):
33603368
self.log_degub = True
33613369

33623370
if titles and not self.log_titles:
3363-
logger.error('setting up pyradio-titles.py')
3364-
self.titles_handler = logging.handlers.RotatingFileHandler(
3365-
path.join(
3366-
recording_dir,
3367-
'pyradio-titles.log'),
3368-
maxBytes=50000,
3369-
backupCount=5)
3370-
self.titles_handler.setFormatter(logging.Formatter(
3371-
fmt=self.PATTERN_TITLE,
3372-
datefmt='%b %d (%a) %H:%M')
3373-
)
3374-
self.titles_handler.setLevel(logging.CRITICAL)
3375-
#l = logging.getLogger()
3376-
logger.addHandler(self.titles_handler)
3377-
self.log_titles = True
3378-
logger.critical('=== Logging started')
33793371
if logger.isEnabledFor(logging.INFO):
3380-
logger.info('starting titles logg on: "{}"'.format(recording_dir))
3372+
logger.info('setting up pyradio-titles.log')
3373+
if not path.exists(recording_dir):
3374+
try:
3375+
makedirs(recording_dir)
3376+
except:
3377+
pass
3378+
if not path.exists(recording_dir):
3379+
self.log_titles = False
3380+
self.titles_handler = None
3381+
if logger.isEnabledFor(logging.ERROR):
3382+
logger.error('cannot start titles log on: "{}"; directory does not exist'.format(recording_dir))
3383+
return False
3384+
else:
3385+
self.titles_handler = logging.handlers.RotatingFileHandler(
3386+
path.join(
3387+
recording_dir,
3388+
'pyradio-titles.log'),
3389+
maxBytes=50000,
3390+
backupCount=5)
3391+
self.titles_handler.setFormatter(logging.Formatter(
3392+
fmt=self.PATTERN_TITLE,
3393+
datefmt='%b %d (%a) %H:%M')
3394+
)
3395+
self.titles_handler.setLevel(logging.CRITICAL)
3396+
#l = logging.getLogger()
3397+
logger.addHandler(self.titles_handler)
3398+
self.log_titles = True
3399+
logger.critical('=== Logging started')
3400+
if logger.isEnabledFor(logging.INFO):
3401+
logger.info('starting titles log on: "{}"'.format(recording_dir))
33813402

33823403
if (not titles) and self.log_titles:
33833404
if self.titles_handler:
@@ -3389,6 +3410,7 @@ def configure_logger(self, recording_dir=None, debug=None, titles=None):
33893410
logging.raiseExceptions = False
33903411
logging.lastResort = None
33913412
# logger.info('self.log_titles = {}'.format(self.log_titles))
3413+
return True
33923414

33933415
def tag_title(self, the_log):
33943416
''' tags a title

pyradio/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
''' This is PyRadio version this
1717
install.py was released for
1818
'''
19-
PyRadioInstallPyReleaseVersion = '0.9.3.9'
19+
PyRadioInstallPyReleaseVersion = '0.9.3.10'
2020

2121
import locale
2222
locale.setlocale(locale.LC_ALL, "")

pyradio/player.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,7 @@ def play(self,
20302030
logger.info('Executing command: {}'.format(' '.join(opts)))
20312031
except:
20322032
pass
2033+
20332034
if platform.startswith('win') and self.PLAYER_NAME == 'vlc':
20342035
self.stop_win_vlc_status_update_thread = False
20352036
''' Launches vlc windowless '''

0 commit comments

Comments
 (0)