Skip to content

Commit 54d3204

Browse files
committed
Implementing playlist rename and updating docs
1 parent 49e2eb3 commit 54d3204

File tree

8 files changed

+459
-143
lines changed

8 files changed

+459
-143
lines changed

Changelog

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
2020-07-16 s-n-g
2-
* 0.8.8-beta2
1+
2020-09-29 s-n-g
2+
* Version 0.8.7.3 (0.8.8-beta2)
33
* Adding PASTE MODE in editing windows
4+
* Finalizing alternative modes (registers, register mode,
5+
extra commands, yank i.e. copy) - implementation
6+
started in 0.8.8-beta1
47
* Toggling transparency enabled in theme selection window
58
* Pyradio respects global encoding
69
* Info window gets updated as data are read
@@ -12,6 +15,16 @@
1215
* Build script will clean up previous installation files (not on Windows)
1316
* Fixing volume saving on Windows
1417

18+
Implemented in 0.8.8-beta1
19+
* Connection timeout counter
20+
* Station info window
21+
* Main help window has 3 pages now
22+
* Fixing playback restart when encoding changed
23+
24+
Not implemented yet
25+
* /p - Select playlist/register to paste station
26+
* /n - Create new playlist
27+
1528
2020-03-16 s-n-g
1629
* Version 0.8.7.2
1730
* Fixing macOS Catalina installation
@@ -29,7 +42,7 @@
2942
* g prefixed by a number jumps to it (same as G)
3043
* Dead keys (alternative mode and jump number) are
3144
now displayed at the bottom right corner of the window
32-
* Main help window has 3 pages nows
45+
* Main help window has 3 pages now
3346
* Fixing playback restart when encoding changed
3447
* Replacing widechar.py with cjkwrap.py and adding its
3548
update script in devel/

README.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ <h2 id="pyradio-themes">PyRadio Themes <span style="padding-left: 10px;"><sup st
352352
</ol>
353353
<p>The visual result of an applied theme greatly depends on the terminal settings (e.g. foreground and background color settings, palette used, number of colors supported, real or pseudo-transparency support, etc.)</p>
354354
<p>Pressing “<strong>t</strong>” will bring up the <em>Theme selection window</em>, which can be used to activate a theme and set the default one.</p>
355-
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> Themes that use more colors than those supported by the terminal in use, will not be present in the <em>Theme selection window</em>. Furthermore, if a such at theme is set as default (or requested using the “<strong>-t</strong>” command line option), <strong>PyRadio</strong> will silently fall-back to the “<strong>dark</strong>” theme (or the “<strong>light</strong>” theme, if the terminal supports 8 colors and default theme is set to “<em>light_16_colors</em>”).</p>
355+
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> Themes that use more colors than those supported by the terminal in use, will not be present in the <em>Theme selection window</em>. Furthermore, if a such at theme is set as default (or requested using the “<strong>-t</strong>” command line option), <strong>PyRadio</strong> will fall-back to the “<strong>dark</strong>” theme (or the “<strong>light</strong>” theme, if the terminal supports 8 colors and default theme is set to “<em>light_16_colors</em>”), and will display a relevant message at program startup.</p>
356356
<p>The <em>Theme selection window</em> will remain open after activating a theme, so that the user can inspect the visual result and easily change it, if desired. Then, when he is satisfied with the activated theme, the window will have to be manually closed (by pressing “<strong>q</strong>” or any other relevant key - pressing “<strong>?</strong>” will bring up its help).</p>
357357
<p>The use of custom themes and theme editing is not implemented yet; these are features for future releases.</p>
358358
<h3 id="using-transparency">Using transparency</h3>
@@ -384,6 +384,18 @@ <h2 id="cleaning-up">Cleaning up <span style="padding-left: 10px;"><sup style="f
384384
<p>As we see, previous versions still exist in this system: <strong>0.7.6.2</strong> and <strong>0.7.7</strong>. These files (actually directories) can safely be removed:</p>
385385
<pre>$ sudo rm -rf /usr/lib/python3.7/site-packages/pyradio-.7.6.2-py3.7.egg
386386
$ sudo rm -rf /usr/lib/python3.7/site-packages/pyradio-0.7.7-py3.7.egg</pre>
387+
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> Since version 0.8.7.3 (0.8.8-beta2), it is not necessary to follow the previous procedure any more; <strong>PyRadio</strong> will search and remove any previously installed files when the “<strong>-u</strong>” (uninstall) parameter is used.</p>
388+
<p>Example:</p>
389+
<pre>$ devel/build_install_pyradio -u
390+
Uninstalling PyRadio
391+
** Removing executable ... done
392+
** Removing help files ... done
393+
Looking for python installed files
394+
** Removing &quot;pyradio-0.8.8-py3.8.egg&quot; ... done
395+
** Removing &quot;pyradio-0.8.6-py2.7.egg&quot; ... done
396+
** Removing &quot;pyradio-0.8.8-py3.8.egg&quot; ... done
397+
PyRadio successfully uninstalled</pre>
398+
<p>In this example, running <em>devel/build_install_pyradio -u</em> has removed <strong>PyRadio</strong> python 3.8 system wide installation files, <strong>PyRadio</strong> python 2.7 system wide installation files, and <strong>PyRadio</strong> python 3.8 user installation files, found in the system.</p>
387399
<h2 id="debug-mode">Debug mode <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
388400
<p>Adding the “<strong>-d</strong>” option to the command line will instruct <strong>PyRadio</strong> to enter <em>Debug mode</em>, which means that it will print debug messages to a file. This file will always reside in the user’s home directory and will be named <em>pyradio.log</em>.</p>
389401
<p>In case of a bug or a glitch, please include this file to the issue you will <a target="_blank" href="https://github.com/coderholic/pyradio/issues">open at github</a>.</p>

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ The visual result of an applied theme greatly depends on the terminal settings (
500500

501501
Pressing "**t**" will bring up the *Theme selection window*, which can be used to activate a theme and set the default one.
502502

503-
**Note:** Themes that use more colors than those supported by the terminal in use, will not be present in the *Theme selection window*. Furthermore, if a such at theme is set as default (or requested using the "**-t**" command line option), **PyRadio** will silently fall-back to the "**dark**" theme (or the "**light**" theme, if the terminal supports 8 colors and default theme is set to "*light_16_colors*").
503+
**Note:** Themes that use more colors than those supported by the terminal in use, will not be present in the *Theme selection window*. Furthermore, if a such at theme is set as default (or requested using the "**-t**" command line option), **PyRadio** will fall-back to the "**dark**" theme (or the "**light**" theme, if the terminal supports 8 colors and default theme is set to "*light_16_colors*"), and will display a relevant message at program startup.
504504

505505
The *Theme selection window* will remain open after activating a theme, so that the user can inspect the visual result and easily change it, if desired. Then, when he is satisfied with the activated theme, the window will have to be manually closed (by pressing "**q**" or any other relevant key - pressing "**?**" will bring up its help).
506506

@@ -558,6 +558,21 @@ As we see, previous versions still exist in this system: **0.7.6.2** and **0.7.7
558558
$ sudo rm -rf /usr/lib/python3.7/site-packages/pyradio-.7.6.2-py3.7.egg
559559
$ sudo rm -rf /usr/lib/python3.7/site-packages/pyradio-0.7.7-py3.7.egg
560560

561+
**Note:** Since version 0.8.7.3 (0.8.8-beta2), it is not necessary to follow the previous procedure any more; **PyRadio** will search and remove any previously installed files when the "**-u**" (uninstall) parameter is used.
562+
563+
Example:
564+
565+
$ devel/build_install_pyradio -u
566+
Uninstalling PyRadio
567+
** Removing executable ... done
568+
** Removing help files ... done
569+
Looking for python installed files
570+
** Removing "pyradio-0.8.8-py3.8.egg" ... done
571+
** Removing "pyradio-0.8.6-py2.7.egg" ... done
572+
** Removing "pyradio-0.8.8-py3.8.egg" ... done
573+
PyRadio successfully uninstalled
574+
575+
In this example, running *devel/build_install_pyradio -u* has removed **PyRadio** python 3.8 system wide installation files, **PyRadio** python 2.7 system wide installation files, and **PyRadio** python 3.8 user installation files, found in the system.
561576

562577
## Debug mode
563578

devel/build_install_pyradio

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ APATH=$(python3 -m site --user-site 2>/dev/null) && echo "$APATH"
4242
}
4343

4444
function remove_paths(){
45+
echo "Looking for python installed files..."
4546
find_paths | sort -u > /tmp/pyradio-uninstall.$$
4647
while read line;do
4748
[ -d "$line" ] && {
@@ -64,7 +65,7 @@ function uninstall(){
6465
echo "PyRadio is not installed..."
6566
exit
6667
}
67-
echo 'Uninstalling PyRadio'
68+
sudo echo 'Uninstalling PyRadio'
6869
user=$(which pyradio | grep '\.local')
6970
[ -z "$user" ] && {
7071
echo -n '** Removing executable ... '

pyradio.1

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" Copyright (C) 2011 Ben Dowling <http://www.coderholic.com/pyradio>
22
.\" This manual is freely distributable under the terms of the GPL.
33
.\"
4-
.TH PYRADIO 1 "January 2020"
4+
.TH PYRADIO 1 "September 2020"
55

66
.SH NAME
77
.PP
@@ -595,13 +595,14 @@ The visual result of an applied theme greatly depends on the terminal settings (
595595
Pressing "\fBt\fR" will bring up the \fITheme selection window\fR, which can be used to activate a theme and set the default one.
596596

597597
.IP \fBNote\fR
598-
Themes that use more colors than those supported by the terminal in use, will not be present in the \fITheme selection window\fR. Furthermore, if a such a theme is set as default (or requested using the "\fB-t\fR" command line option), \fBpyradio\fR will silently fall-back to the "\fBdark\fR" theme. (or the "\fBlight\fR" theme, if the terminal supports 8 colors and default theme is set to "\fIlight_16_colors\fR").
598+
Themes that use more colors than those supported by the terminal in use, will not be present in the \fITheme selection window\fR. Furthermore, if a such a theme is set as default (or requested using the "\fB-t\fR" command line option), \fBpyradio\fR will fall-back to the "\fBdark\fR" theme, (or the "\fBlight\fR" theme, if the terminal supports 8 colors and default theme is set to "\fIlight_16_colors\fR"), and will display a relevant messages at program startup.
599599

600600
.PP
601601
The \fITheme selection window\fR will remain open after activating a theme, so that the user can inspect the visual result and easily change it, if desired. Then, when he is satisfied with the activated theme, the window will have to be manually closed (by pressing "\fBq\fR" or any other relevant key - pressing "\fB?\fR" will bring up its help).
602602

603603
The use of custom themes and theme editing is not implemented yet; theses are features for future releases.
604604

605+
.PP
605606
\fBUSING TRANSPARENCY\fR
606607

607608
\fBpyradio\fR themes are able to be used with a transparent background.
@@ -666,6 +667,24 @@ As we see, previous versions still exist in this system: \fB0.7.6.2\fR and \fB0.
666667
.br
667668
\fI$ \fBsudo rm -rf /usr/lib/python3.7/site-packages/pyradio-\fI0.7.7\fB-py3.7.egg
668669

670+
671+
.IP \fBNote:
672+
Since version 0.8.7.3 (0.8.8-beta2), it is not necessary to follow the previous procedure any more; \fBpyradio\fR will search and remove any previously installed files when the "\fB-u\fR" (uninstall) parameter is used.
673+
674+
Example:
675+
676+
\fI$ \fBdevel/build_install_pyradio -u\fI
677+
Uninstalling PyRadio
678+
** Removing executable ... done
679+
** Removing help files ... done
680+
Looking for python installed files
681+
** Removing "pyradio-\fB0.8.8-py3.8\fI.egg" ... done
682+
** Removing "pyradio-\fB0.8.6-py2.7\fI.egg" ... done
683+
** Removing "pyradio-\fB0.8.8-py3.8\fI.egg" ... done
684+
PyRadio successfully uninstalled\fR
685+
686+
In this example, running \fIdevel/build_install_pyradio -u\fR has removed \fBpyradio\fR python 3.8 system wide installation files, \fBpyradio\fR python 2.7 system wide installation files, and \fBpyradio\fR python 3.8 user installation files, found in the system.
687+
669688
.SH DEBUG MODE
670689
.PP
671690
Adding the \fB-d\fR option to the command line will instruct \fBpyradio\fR to enter \fBDebug mode\fR, which means that it will print debug messages to a file. This file will always reside in the user's home directory and will be named \fIpyradio.log\fR.

pyradio/config.py

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,10 @@ def switch_stations(self, source, target):
807807
return True, self.number_of_stations
808808

809809
def registers_exist(self):
810-
if glob.glob(path.join(self.registers_dir, '*.csv')):
811-
return True
812-
return False
810+
return True if glob.glob(path.join(self.registers_dir, '*.csv')) else False
811+
812+
def just_read_playlists(self):
813+
self.playlists = glob.glob(path.join(self.stations_dir, '*.csv'))
813814

814815
def read_playlists(self):
815816
self.playlists = []
@@ -900,6 +901,18 @@ def history_item(self, an_item=-1):
900901
logger.error('DE /// history_item = {}'.format(self._ps._p[an_item]))
901902
return self._ps._p[an_item][:]
902903

904+
def find_history_by_station_path(self, a_path):
905+
return self._ps._find_history_by_id(a_path, 'path')
906+
907+
def find_history_by_station_name(self, a_name):
908+
return self._ps._find_history_by_id(a_name, 'file_name')
909+
910+
def find_history_by_station_title(self, a_title):
911+
ret, ret_index, rev_ret_index = self._ps._find_history_by_id(a_title, 'title')
912+
if not ret:
913+
ret, ret_index, rev_ret_index = self._ps._find_history_by_id(a_title.replace('_', ' '), 'title')
914+
return ret, ret_index, rev_ret_index
915+
903916
class PyRadioConfig(PyRadioStations):
904917

905918
theme_not_supported = False
@@ -1326,6 +1339,7 @@ class PyRadioPlaylistStack(object):
13261339
_id = {'station_path': 0,
13271340
'path': 0,
13281341
'station_file_name': 1,
1342+
'file_name': 1,
13291343
'filename': 1,
13301344
'station_title': 2,
13311345
'title': 2,
@@ -1462,9 +1476,11 @@ def add(self, station_path='',
14621476
is_register=False,
14631477
browsing_station_service=False):
14641478
if len(self._p) > 1 and station_path:
1465-
if self._p[-2][self._id['station_path']] == station_path:
1479+
if self._p[-1][self._id['station_path']] == station_path:
14661480
if logger.isEnabledFor(logging.DEBUG):
1467-
logger.debug('PyRadioPlaylistStack.add(): Refusing to add duplicate entry: "{}"'.format(station_path))
1481+
logger.debug('PyRadioPlaylistStack.add(): Refusing to add duplicate entry: "{}"\nUpdating selections instead'.format(station_path))
1482+
logger.debug(' Updating selections instead')
1483+
self._p[-1][3:6] = [startPos, selection, playing]
14681484
return
14691485
if is_register:
14701486
while self._p[-1][self._id['is_register']]:
@@ -1483,6 +1499,27 @@ def get_item_member(self, member, item_id=-1):
14831499
else:
14841500
raise ValueError('member "{}" does not exist'.format(member))
14851501

1502+
def _find_history_by_id(self, a_search, it_id, start=0):
1503+
""" Find a history item
1504+
1505+
Parameters
1506+
==========
1507+
a_search search term
1508+
it_id one of the _id strings
1509+
start return id if >0 start
1510+
1511+
Returns
1512+
=======
1513+
history item,
1514+
index,
1515+
reversed index (len - id - 1)
1516+
"""
1517+
logger.error('DE looking for: ' + a_search + ' with id: ' + it_id)
1518+
for i, n in enumerate(self._p):
1519+
if (n[self._id[it_id]] == a_search) and (i >= start):
1520+
return n, i, len(self._p) - i - 1
1521+
return None, -1, -1
1522+
14861523
def pop(self):
14871524
if len(self._p) > 1:
14881525
return self._p.pop()

pyradio/edit.py

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import logging
66
from sys import version_info
77
from os import path, remove
8+
from string import punctuation as string_punctuation
89
try:
910
# python 3
1011
from urllib.parse import urlparse
@@ -593,6 +594,7 @@ class PyRadioRenameFile(object):
593594
""" PyRadio copy file dialog """
594595

595596
def __init__(self, filename, parent, create=False, open_afterwards=True, title='', opened_from_editor = False):
597+
self._invalid_chars = '<>|:"\\/?*'
596598
self.maxY = self.maxX = 0
597599
self._win = self._parent_win = self._line_editor = None
598600
self._focus = 0
@@ -677,16 +679,32 @@ def set_parent(self, val, refresh=True):
677679
self.show()
678680

679681
def _string_changed(self):
680-
stripped_string = self._widgets[0].string.strip()
681682
self._error_string = ''
682-
if stripped_string:
683-
check_file = path.join(self._to_path, stripped_string + '.csv')
684-
if check_file == self.filename:
685-
self._error_string = 'You must be joking!!!'
686-
elif path.exists(check_file):
687-
self._error_string = 'File already exists!!!'
688-
elif check_file.startswith('register_'):
683+
first_char = ''
684+
if self._widgets[0].string != '':
685+
first_char = self._widgets[0].string[0]
686+
if first_char in string_punctuation + ' ':
689687
self._error_string = 'Invalid filename!!!'
688+
stripped_string = self._widgets[0].string.strip()
689+
if self._error_string == '':
690+
if stripped_string:
691+
check_file = path.join(self._to_path, stripped_string + '.csv')
692+
if check_file == self.filename:
693+
self._error_string = 'You must be joking!!!'
694+
elif path.exists(check_file):
695+
self._error_string = 'File already exists!!!'
696+
elif stripped_string.startswith('register_'):
697+
self._error_string = 'Register token inserted!!!'
698+
else:
699+
for inv in self._invalid_chars:
700+
if inv in stripped_string:
701+
self._error_string = 'Invalid filename!!!'
702+
logger.error('DE inv = ' + inv)
703+
break
704+
#if self._error_string == '':
705+
# for inv in range(1, 32):
706+
# if str(inv) in stripped_string:
707+
# self._error_string = 'Invalid filename!!!'
690708
self._widgets[-2].enabled = False
691709
if stripped_string and self._error_string == '':
692710
self._widgets[-2].enabled = True
@@ -807,6 +825,11 @@ def show(self):
807825
curses.color_pair(5)
808826
)
809827
self._win.addstr(2, 2, 'To:', curses.color_pair(4))
828+
inv_tit = 'Invalid chars: '
829+
inv_chars = self._invalid_chars
830+
invX = self.maxX - len(inv_tit) - len(inv_chars) - 2
831+
self._win.addstr(4, invX, inv_tit, curses.color_pair(4))
832+
self._win.addstr(inv_chars, curses.color_pair(5))
810833

811834
if self.maxY > 18 and self.maxX > 76:
812835
try:

0 commit comments

Comments
 (0)