Skip to content

Commit

Permalink
- version 0.9.3.10
Browse files Browse the repository at this point in the history
- remove ~/pyradio-recordings at startup, if empty
- recording and titles' log functions will create recordings dir if it does not exist
  • Loading branch information
s-n-g committed Aug 30, 2024
1 parent 3fc0147 commit 52b0a5b
Show file tree
Hide file tree
Showing 15 changed files with 258 additions and 58 deletions.
16 changes: 16 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
2024-08-30 s-n-g
* version 0.9.3.10
* do not enable xdg compliant if user_config_dir is specified
* do not create the default recording directory until it is
actually needed (to save data in it)
* when saving players' extra parameters reduce the list by removing
the unused porifles from the list
* Fixing player_params_file and schedule_file location when XDG
compliance is ON
* fixing a pyradio-client crash when no command is specified
* fixing: MPV Volume resets to 0% when trying to increase
beyond maximum #251
* fixing a help crash: adding H_CONFIG_PLAYER help key
* added a gruvbox variation system theme
* updating docs and fixing broken links

2024-06-04 s-n-g
* version 0.9.3.9
* fixing a crash when adding a station to favorites
Expand Down
16 changes: 16 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,22 @@ <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;">

2024-08-30 s-n-g
* version 0.9.3.10
* do not enable xdg compliant if user_config_dir is specified
* do not create the default recording directory until it is
actually needed (to save data in it)
* when saving players' extra parameters reduce the list by removing
the unused porifles from the list
* Fixing player_params_file and schedule_file location when XDG
compliance is ON
* fixing a pyradio-client crash when no command is specified
* fixing: MPV Volume resets to 0% when trying to increase
beyond maximum #251
* fixing a help crash: adding H_CONFIG_PLAYER help key
* added a gruvbox variation system theme
* updating docs and fixing broken links

2024-06-04 s-n-g
* version 0.9.3.9
* fixing a crash when adding a station to favorites
Expand Down
4 changes: 2 additions & 2 deletions docs/pyradio.1
Original file line number Diff line number Diff line change
Expand Up @@ -1220,8 +1220,8 @@ Two themes by \fBedunfelt\fR (\fIhttps://github.com/edunfelt\fR) inspired by the
.IP \fBdracula_by_Plyply99\fR
A theme based of the Dracula theme by \fBPlyply99\fR (\fIhttps://github.com/Plyply99\fR).

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

.IP \fBhyprland_amber_gold\fR\ and\ \fBhyprland_dracula\fR
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).
Expand Down
10 changes: 10 additions & 0 deletions docs/rec-dir.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,15 @@ <h2 id="pre-0.9.3-installation-behavior">Pre 0.9.3 installation behavior <span s
<p>Pre 0.9.3 installations will use ~/.config/pyradio/data/recordings as the recording directory, by default.</p>
<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>
<p>Then the user can change the folder’s location from <em>Config / General options / Recording dir</em>.</p>
<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>
<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>
<p>This eventually creates the following problem:</p>
<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>
<p>The solution is that <strong>PyRadio</strong> will remove the “<em>recording directory</em>” upon execution, if</p>
<ol type="1">
<li>the default location is used</li>
<li>the directory is empty</li>
</ol>
<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>
</body>
</html>
14 changes: 14 additions & 0 deletions docs/rec-dir.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,17 @@ After updating to v. 0.9.3 (and newer), **PyRadio** will move this directory to

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

## Post 0.9.3.10 behavior

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.

This eventually creates the following problem:

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).

The solution is that **PyRadio** will remove the "*recording directory*" upon execution, if

1. the default location is used
2. the directory is empty

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.
15 changes: 12 additions & 3 deletions docs/themes.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ <h2 id="table-of-contents">Table of Contents <span style="padding-left: 10px;"><
<ul>
<li><a href="#pyradio-themes">PyRadio Themes</a>
<ul>
<li><a href="#virtual-terminal-restrictions">Virtual terminal restrictions</a></li>
<li><a href="#virtual-terminal-restrictions">Virtual terminal restrictions</a>
<ul>
<li><a href="#workaround-for-not-supported-terminals">Workaround for not supported terminals</a></li>
</ul></li>
<li><a href="#css-color-themes-restrictions">CSS color themes restrictions</a></li>
<li><a href="#secondary-windows-background">Secondary windows background</a>
<ul>
Expand Down Expand Up @@ -108,8 +111,8 @@ <h2 id="pyradio-themes-1">PyRadio Themes <span style="padding-left: 10px;"><sup
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>
<li><strong>dracula_by_Plyply99</strong><br />
A theme based of the Dracula theme by <a target="_blank" href="https://github.com/Plyply99">Plyply99</a>.</li>
<li><strong>gruvbox_dark_by_sng</strong> and <strong>gruvbox_light_by_sng</strong><br />
Two themes based on the <a target="_blank" href="https://github.com/morhetz/gruvbox">gruvbox</a> theme.</li>
<li><em>gruvbox_dark_by_farparticul</em>, <strong>gruvbox_dark_by_sng</strong> and <strong>gruvbox_light_by_sng</strong><br />
Three themes based on the <a target="_blank" href="https://github.com/morhetz/gruvbox">gruvbox</a> theme.</li>
<li><strong>hyprland_amber_gold</strong> and <strong>hyprland_dracula</strong><br />
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>
<li><strong>minima_by_ben_chile</strong><br />
Expand Down Expand Up @@ -180,6 +183,12 @@ <h3 id="virtual-terminal-restrictions">Virtual terminal restrictions</h3>
<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>
<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>
<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>
<h4 id="workaround-for-not-supported-terminals">Workaround for not supported terminals</h4>
<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>
<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>
<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>
<pre>tmux_pyradio -h</pre>
<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>
<h3 id="css-color-themes-restrictions">CSS color themes restrictions</h3>
<p>Using CSS colors imposes a couple of restrictions on the type of terminals <strong>PyRadio</strong> will be able to run:</p>
<ol type="1">
Expand Down
17 changes: 15 additions & 2 deletions docs/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

* [PyRadio Themes](#pyradio-themes)
* [Virtual terminal restrictions](#virtual-terminal-restrictions)
* [Workaround for not supported terminals](#workaround-for-not-supported-terminals)
* [CSS color themes restrictions](#css-color-themes-restrictions)
* [Secondary windows background](#secondary-windows-background)
* [Theme defined secondary windows color](#theme-defined-secondary-windows-color)
Expand Down Expand Up @@ -57,8 +58,8 @@ A clasic theme by [The OpenBSD Guy](https://github.com/OpenBSDGuy), originally c
Two themes by [edunfelt](https://github.com/edunfelt) inspired by the [base16](https://github.com/base16-project) project.
- **dracula_by_Plyply99** \
A theme based of the Dracula theme by [Plyply99](https://github.com/Plyply99).
- **gruvbox_dark_by_sng** and **gruvbox_light_by_sng** \
Two themes based on the [gruvbox](https://github.com/morhetz/gruvbox) theme.
- *gruvbox_dark_by_farparticul*, **gruvbox_dark_by_sng** and **gruvbox_light_by_sng** \
Three themes based on the [gruvbox](https://github.com/morhetz/gruvbox) theme.
- **hyprland_amber_gold** and **hyprland_dracula** \
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).
- **minima_by_ben_chile** \
Expand Down Expand Up @@ -146,6 +147,18 @@ Some of the terminals that work ok, are: *gnome-terminal*, *mate-terminal*, *xfc

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).

#### Workaround for not supported terminals

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.

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.

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:

tmux_pyradio -h

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.

### CSS color themes restrictions

Using CSS colors imposes a couple of restrictions on the type of terminals **PyRadio** will be able to run:
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.9"
version = "0.9.3.10"
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, 9)
version_info = (0, 9, 3, 10)

# Set it to True if new stations have been
# added to the package's stations.csv
Expand Down
64 changes: 43 additions & 21 deletions pyradio/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2420,23 +2420,25 @@ def _read_config(self, distro_config=False):
except:
pass
self._first_read = False
logger.error('\n\nfile = {0}\nplayer extra params = {1}\n\n'.format(self.player_params_file, self.params))
# logger.error('\n\nfile = {0}\nplayer extra params = {1}\n\n'.format(self.player_params_file, self.params))

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


def _make_sure_dirs_exist(self):
home_rec_dir = path.join(path.expanduser('~'), 'pyradio-recordings')
if self.opts['recording_dir'][1] == '':
self.opts['recording_dir'][1] = path.join(path.expanduser('~'), 'pyradio-recordings')
ch_dir = CheckDir(
self.opts['recording_dir'][1],
path.join(path.expanduser('~'), 'pyradio-recordings')
home_rec_dir,
remove_after_validation=True
)
if not ch_dir.is_dir:
if not ch_dir.can_be_created:
print('Error: Recordings directory is for a folder: "{}"'.format(self.opts['recording_dir'][1]))
sys.exit(1)
elif not ch_dir.is_writable:
elif not ch_dir.can_be_writable:
print('Error: Recordings directory is not writable: "{}"'.format(self.opts['recording_dir'][1]))
sys.exit(1)

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

# remove recordings dir from home dir if it is empty, as per #253
if path.exists(self.opts['recording_dir'][1]) and \
self.opts['recording_dir'][1] == home_rec_dir and \
len(listdir(self.opts['recording_dir'][1])) == 0:
remove_tree(self.opts['recording_dir'][1])

def get_last_playlist(self):
''' read last opened playlist
reads: ~/pyradio/last_playlist
Expand Down Expand Up @@ -3360,24 +3368,37 @@ def configure_logger(self, recording_dir=None, debug=None, titles=None):
self.log_degub = True

if titles and not self.log_titles:
logger.error('setting up pyradio-titles.py')
self.titles_handler = logging.handlers.RotatingFileHandler(
path.join(
recording_dir,
'pyradio-titles.log'),
maxBytes=50000,
backupCount=5)
self.titles_handler.setFormatter(logging.Formatter(
fmt=self.PATTERN_TITLE,
datefmt='%b %d (%a) %H:%M')
)
self.titles_handler.setLevel(logging.CRITICAL)
#l = logging.getLogger()
logger.addHandler(self.titles_handler)
self.log_titles = True
logger.critical('=== Logging started')
if logger.isEnabledFor(logging.INFO):
logger.info('starting titles logg on: "{}"'.format(recording_dir))
logger.info('setting up pyradio-titles.log')
if not path.exists(recording_dir):
try:
makedirs(recording_dir)
except:
pass
if not path.exists(recording_dir):
self.log_titles = False
self.titles_handler = None
if logger.isEnabledFor(logging.ERROR):
logger.error('cannot start titles log on: "{}"; directory does not exist'.format(recording_dir))
return False
else:
self.titles_handler = logging.handlers.RotatingFileHandler(
path.join(
recording_dir,
'pyradio-titles.log'),
maxBytes=50000,
backupCount=5)
self.titles_handler.setFormatter(logging.Formatter(
fmt=self.PATTERN_TITLE,
datefmt='%b %d (%a) %H:%M')
)
self.titles_handler.setLevel(logging.CRITICAL)
#l = logging.getLogger()
logger.addHandler(self.titles_handler)
self.log_titles = True
logger.critical('=== Logging started')
if logger.isEnabledFor(logging.INFO):
logger.info('starting titles log on: "{}"'.format(recording_dir))

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

def tag_title(self, the_log):
''' tags a title
Expand Down
2 changes: 1 addition & 1 deletion pyradio/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
''' This is PyRadio version this
install.py was released for
'''
PyRadioInstallPyReleaseVersion = '0.9.3.9'
PyRadioInstallPyReleaseVersion = '0.9.3.10'

import locale
locale.setlocale(locale.LC_ALL, "")
Expand Down
1 change: 1 addition & 0 deletions pyradio/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,7 @@ def play(self,
logger.info('Executing command: {}'.format(' '.join(opts)))
except:
pass

if platform.startswith('win') and self.PLAYER_NAME == 'vlc':
self.stop_win_vlc_status_update_thread = False
''' Launches vlc windowless '''
Expand Down
Loading

0 comments on commit 52b0a5b

Please sign in to comment.