Skip to content

Commit c5219d3

Browse files
committed
Version 0.7.5
- Adding loading default options to config window - Trasnparency and Theme settings will not be automatically saved in Config window - Canceling theme selection will restore saved theme (not in config) - Adding empty space around Config second level Help windows - Done a bit of refactoring - Updating docs
1 parent ad638d3 commit c5219d3

13 files changed

+443
-234
lines changed

Changelog

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
2019-04-16 s-n-g
1+
2019-04-18 s-n-g
2+
* Version 0.7.5
23
* Minimum python version supported changed. Now it's 2.7+/3.5+
34
* Added configuration window (opens with "c").
5+
* Canceling theme selection (not in config) will restore saved theme.
6+
* Done a bit of refactoring.
47

58
2019-02-14 s-n-g
69

README.html

+5-12
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ <h2 id="controls">Controls</h2>
116116
<h2 id="config-file">Config file</h2>
117117
<p><strong>PyRadio</strong> upon its execution tries to read its configuration file (i.e. <em>~/.config/pyradio/config</em>). If this file is not found, it will be created. If an error occurs while parsing it, an error message will be displayed and <strong><em>PyRadio</em></strong> will terminate.</p>
118118
<p>The file contains parameters such as the player to use, the playlist to load etc. It is heavily commented (as you can see <a href="pyradio/config">here</a>), so that manual editing is really easy. The best practice to manually edit this file is executing <strong><em>PyRadio</em></strong> with the <strong>-ocd</strong> command line option, which will open the configuration directory in your file manager, and then edit it using your preferable text editor.</p>
119-
<p>The file can also be altered while <strong>PyRadio</strong> is running by pressing “<strong><em>c</em></strong>”, which will open the “<strong><em>Configuration window</em></strong>”. This window presents all <strong>PyRadio</strong> options and provide the way to change them.</p>
119+
<p>The file can also be altered while <strong>PyRadio</strong> is running by pressing “<strong><em>c</em></strong>”, which will open the “<strong><em>Configuration window</em></strong>”. This window presents all <strong>PyRadio</strong> options and provide the way to change them and finally save them by pressing “<strong><em>s</em></strong>.</p>
120120
<p>In any case, <strong>PyRadio</strong> will save the file before exiting (or in case Ctrl-C is pressed) if needed (e.g. if a config parameter has been changed during its execution).</p>
121+
<p>If saving the configuration file fails, <strong>PyRadio</strong> will create a back up file and terminate. When restarted, <strong>PyRadio</strong> will try to restore previously used settings from the said back up file.</p>
121122
<h2 id="about-playlist-files">About Playlist files</h2>
122123
<p><strong>PyRadio</strong> reads the stations to use from a CSV file, where each line contains two columns, the first being the station name and the second being the stream URL.</p>
123124
<p>Optionally, a third column can be inserted, stating the encoding used by the station (more on this at <a href="#specifying-stations-encoding">Specifying stations’ encoding</a>).</p>
@@ -185,17 +186,9 @@ <h3 id="global-encoding-declaration">Global encoding declaration</h3>
185186
<p>Setting this parameter to a different encoding, will permit <strong>PyRadio</strong> to successfully decode such stations.</p>
186187
<p>This would be useful in the case where most of your stations do not use <strong>utf-8</strong>. Instead of editing the playlist and add the encoding to each and every affected station, you just set it globally.</p>
187188
<h3 id="finding-the-right-encoding">Finding the right encoding</h3>
188-
<p>A valid encoding list can be found (depends on python version):</p>
189-
<ul>
190-
<li><a href="https://docs.python.org/2.3/lib/node130.html">https://docs.python.org/2.3/lib/node130.html</a></p></li>
191-
<li><a href="https://docs.python.org/2.4/lib/standard-encodings.html">https://docs.python.org/2.4/lib/standard-encodings.html</a></p></li>
192-
<li><a href="https://docs.python.org/2.5/lib/standard-encodings.html">https://docs.python.org/2.5/lib/standard-encodings.html</a></p></li>
193-
</ul>
194-
<p>Or use this URL</p>
195-
<ul>
196-
<li><a href="https://docs.python.org/2.6/library/codecs.html#standard-encodings">https://docs.python.org/2.6/library/codecs.html#standard-encodings</a></li>
197-
</ul>
198-
<p>replacing <strong>2.6</strong> with specific version: <strong>2.7</strong>, <strong>3.0</strong> up to current python version.</p>
189+
<p>A valid encoding list can be found at:</p>
190+
<p><a href="https://docs.python.org/2.7/library/codecs.html#standard-encodings">https://docs.python.org/2.7/library/codecs.html#standard-encodings</a></p>
191+
<p>replacing <strong>2.7</strong> with specific version: <strong>3.0</strong> up to current python version.</p>
199192
<h2 id="player-detection-selection">Player detection / selection</h2>
200193
<p><strong>PyRadio</strong> is basically built around the existence of a valid media player it can use. Thus, it will auto detect the existence of its supported players upon its execution.</p>
201194
<p>Currently, it supports MPV, MPlayer and VLC, and it will look for them in that order. If none of them is found, the program will terminate with an error.</p>

README.md

+6-12
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ The same logic applies to all **PyRadio** windows.
109109

110110
The file contains parameters such as the player to use, the playlist to load etc. It is heavily commented (as you can see [here](pyradio/config)), so that manual editing is really easy. The best practice to manually edit this file is executing ***PyRadio*** with the **-ocd** command line option, which will open the configuration directory in your file manager, and then edit it using your preferable text editor.
111111

112-
The file can also be altered while **PyRadio** is running by pressing "***c***", which will open the "***Configuration window***". This window presents all **PyRadio** options and provide the way to change them.
112+
The file can also be altered while **PyRadio** is running by pressing "***c***", which will open the "***Configuration window***". This window presents all **PyRadio** options and provide the way to change them and finally save them by pressing "***s***".
113113

114114
In any case, **PyRadio** will save the file before exiting (or in case Ctrl-C is pressed) if needed (e.g. if a config parameter has been changed during its execution).
115115

116+
If saving the configuration file fails, **PyRadio** will create a back up file and terminate. When restarted, **PyRadio** will try to restore previously used settings from the said back up file.
117+
116118
## About Playlist files
117119

118120
**PyRadio** reads the stations to use from a CSV file, where each line contains two columns, the first being the station name and the second being the stream URL.
@@ -247,19 +249,11 @@ This would be useful in the case where most of your stations do not use **utf-8*
247249

248250
### Finding the right encoding
249251

250-
A valid encoding list can be found (depends on python version):
251-
252-
* [https://docs.python.org/2.3/lib/node130.html](https://docs.python.org/2.3/lib/node130.html)
253-
254-
* [https://docs.python.org/2.4/lib/standard-encodings.html](https://docs.python.org/2.4/lib/standard-encodings.html)
255-
256-
* [https://docs.python.org/2.5/lib/standard-encodings.html](https://docs.python.org/2.5/lib/standard-encodings.html)
257-
258-
Or use this URL
252+
A valid encoding list can be found at:
259253

260-
* [https://docs.python.org/2.6/library/codecs.html#standard-encodings](https://docs.python.org/2.6/library/codecs.html#standard-encodings)
254+
[https://docs.python.org/2.7/library/codecs.html#standard-encodings](https://docs.python.org/2.7/library/codecs.html#standard-encodings)
261255

262-
replacing **2.6** with specific version: **2.7**, **3.0** up to current python version.
256+
replacing **2.7** with specific version: **3.0** up to current python version.
263257

264258

265259
## Player detection / selection

pyradio.1

+6-19
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ All windows support changing the volume and muting / unmuting the player (provid
9292

9393
The file contains parameters such as the player to use, the playlist to load etc. It is heavily commented, so that manual editing is really easy. The best practice to manually edit this file is executing \fBpyradio\fR with the \fB-ocd\fR command line option, which will open the configuration directory in your file manager, and then edit it using your preferable text editor.
9494

95-
The file can also be altered while \fBpyradio\fR is running, by pressing "\fIc\fR", which will open the "\fIConfiguration window\fR". This window presents all \fBpyradio\fR options and provide the way to change them.
95+
The file can also be altered while \fBpyradio\fR is running, by pressing "\fIc\fR", which will open the "\fIConfiguration window\fR". This window presents all \fBpyradio\fR options and provide the way to change them and finally save them by pressing "\fIs\fR".
9696

9797
In any case, \fBpyradio\fR will save the file before exiting (or in case Ctrl-C is pressed) if needed (e.g. if a config parameter has been changed during its execution).
9898

99+
If saving the configuration file fails, \fBpyradio\fR will create a back up file and terminate. When restarted, \fBpyradio\fR will try to restore previously used settings from the said back up file.
100+
99101
.SH ABOUT PLAYLIST FILES
100102
.PP
101103
\fBpyradio\fR reads the stations to use from a CSV file, where each line contains two columns, the first being the station name and the second being the stream URL.
@@ -262,26 +264,11 @@ This would be useful in the case where most of your stations do not use \fIutf-8
262264
.B
263265
FINDING THE RIGHT ENCODING
264266

265-
A valid encoding list can be found (depends on python version):
266-
267-
.HP
268-
269-
\fIhttps://docs.python.org/2.3/lib/node130.html
270-
271-
https://docs.python.org/2.4/lib/standard-encodings.html
272-
273-
https://docs.python.org/2.5/lib/standard-encodings.html
267+
A valid encoding list can be found at:
274268

275-
.PP
276-
277-
Or use this URL
278-
279-
.HP
280-
281-
\fIhttps://docs.python.org/2.6/library/codecs.html#standard-encodings
269+
\fIhttps://docs.python.org/2.7/library/codecs.html#standard-encodings
282270

283-
.PP
284-
replacing \fI2.6\fR with specific version: \fI2.7\fR, \fI3.0\fR up to current python version.
271+
\fRreplacing \fI2.7\fR with specific version: \fI3.0\fR up to current python version.
285272

286273
.SH PLAYER DETECTION / SELECTION
287274
.PP

pyradio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" pyradio -- Console radio player. "
22

3-
version_info = (0, 7, 4)
3+
version_info = (0, 7, 5)
44

55
__version__ = version = '.'.join(map(str, version_info))
66
__project__ = __name__

pyradio/common.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
ASK_TO_SAVE_PLAYLIST_MODE = 52
1616
MAIN_HELP_MODE = 100
1717
PLAYLIST_HELP_MODE = 101
18-
THEME_HELP_MODE = 102
19-
CONFIG_HELP_MODE = 103
18+
CONFIG_HELP_MODE = 102
19+
THEME_HELP_MODE = 103
2020
SELECT_PLAYER_HELP_MODE = 104
2121
SELECT_ENCODING_HELP_MODE = 105
2222
SELECT_PLAYLIST_HELP_MODE = 106
@@ -31,6 +31,7 @@
3131
FOREIGN_PLAYLIST_ASK_MODE = 300
3232
FOREIGN_PLAYLIST_MESSAGE_MODE = 301
3333
FOREIGN_PLAYLIST_COPY_ERROR_MODE = 302
34+
CONFIG_SAVE_ERROR_MODE = 303
3435
THEME_MODE = 400
3536
NOT_IMPLEMENTED_YET_MODE = 1000
3637

pyradio/config

+7-11
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,19 @@ default_playlist = stations
1919
# Default station
2020
# This is the equivalent to the -p , --play command line parameter
2121
# The station number within the default playlist to play
22-
# Value is 1..number of stations, -1 means no auto play
23-
# "0" or "random" means play a random station
24-
default_station = -1
22+
# Value is 1..number of stations, "-1" or "False" means no auto play,
23+
# "0" or "Random" means play a random station
24+
default_station = False
2525

2626
# Default encoding
2727
# This is the encoding used by default when reading data provided by
2828
# a station (such as song title, etc.) If reading said data ends up
2929
# in an error, 'utf-8' will be used instead.
3030
#
31-
# A valid encoding list can be found (depends on python version):
32-
# https://docs.python.org/2.3/lib/node130.html
33-
# https://docs.python.org/2.4/lib/standard-encodings.html
34-
# https://docs.python.org/2.5/lib/standard-encodings.html
35-
# Or use this URL
36-
# https://docs.python.org/2.6/library/codecs.html#standard-encodings
37-
# replacing 2.6 with specific version:
38-
# 2.7, 3.0 up to current python version.
31+
# A valid encoding list can be found at:
32+
# https://docs.python.org/2.7/library/codecs.html#standard-encodings
33+
# replacing 2.7 with specific version:
34+
# 3.0 up to current python version.
3935
#
4036
# Default value: utf-8
4137
default_encoding = utf-8

pyradio/config.py

+18-16
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,8 @@ def theme(self):
552552

553553
@theme.setter
554554
def theme(self, val):
555-
logger.info('{}, {}'.format(self.opts['theme'], self.opts['dirty_config']))
556555
self.opts['theme'][1] = val
557556
self.opts['dirty_config'][1] = True
558-
logger.info('{}, {}'.format(self.opts['theme'], self.opts['dirty_config']))
559557

560558
@property
561559
def dirty_config(self):
@@ -611,7 +609,7 @@ def read_config(self):
611609
st = sp[1].strip()
612610
if st == '-1' or st.lower() == 'false':
613611
self.opts['default_station'][1] = 'False'
614-
elif st == 'random':
612+
elif st == "0" or st == 'random':
615613
self.opts['default_station'][1] = None
616614
else:
617615
self.opts['default_station'][1] = st
@@ -638,11 +636,18 @@ def read_config(self):
638636
self.opts['dirty_config'][1] = False
639637
return 0
640638

641-
def _save_config(self):
639+
def save_config(self):
640+
""" Save config file
641+
642+
Creates config.restore (back up file)
643+
Returns:
644+
-1: Error saving config
645+
0: Config saved successfully
646+
1: Config not saved (not modified"""
642647
if not self.opts['dirty_config'][1]:
643648
if logger.isEnabledFor(logging.INFO):
644649
logger.info('Config not saved (not modified)')
645-
return 0
650+
return 1
646651
txt ='''# PyRadio Configuration File
647652
648653
# Player selection
@@ -666,24 +671,20 @@ def _save_config(self):
666671
# Default station
667672
# This is the equivalent to the -p , --play command line parameter
668673
# The station number within the default playlist to play
669-
# Value is 0..number of stations, -1 means no auto play
670-
# "random" means play a random station
671-
# Default value: -1
674+
# Value is 1..number of stations, "-1" or "False" means no auto play
675+
# "0" or "Random" means play a random station
676+
# Default value: False
672677
default_station = {2}
673678
674679
# Default encoding
675680
# This is the encoding used by default when reading data provided by
676681
# a station (such as song title, etc.) If reading said data ends up
677682
# in an error, 'utf-8' will be used instead.
678683
#
679-
# A valid encoding list can be found (depends on python version):
680-
# https://docs.python.org/2.3/lib/node130.html
681-
# https://docs.python.org/2.4/lib/standard-encodings.html
682-
# https://docs.python.org/2.5/lib/standard-encodings.html
683-
# Or use this URL
684-
# https://docs.python.org/2.6/library/codecs.html#standard-encodings
685-
# replacing 2.6 with specific version:
686-
# 2.7, 3.0 up to current python version.
684+
# A valid encoding list can be found at:
685+
# https://docs.python.org/2.7/library/codecs.html#standard-encodings
686+
# replacing 2.7 with specific version:
687+
# 3.0 up to current python version.
687688
#
688689
# Default value: utf-8
689690
default_encoding = {3}
@@ -768,6 +769,7 @@ def _save_config(self):
768769
pass
769770
if logger.isEnabledFor(logging.INFO):
770771
logger.info('Config saved')
772+
self.opts['dirty_config'][1] = False
771773
return 0
772774

773775
def read_playlist_file(self, stationFile=''):

0 commit comments

Comments
 (0)