Skip to content

Commit 048d104

Browse files
committed
- Version 0.8.6
- Finalising playlist gistory - https URLs will be converted to http before connecting - Config / Default station: pading fixed
1 parent a69fb6e commit 048d104

File tree

10 files changed

+49
-22
lines changed

10 files changed

+49
-22
lines changed

Changelog

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
2019-12-08 s-n-g
1+
2019-12-14 s-n-g
2+
* Version 0.8.6
23
* Adding playlist history (for local playlists)
3-
* WINDOWS: Volume will be saved when mplayer is installed in %APPDATA%\pyradio
4+
* https URLs will be converted to http before connecting
45
* Fixing station moving when appending station
6+
* Config / Default station: pading fixed
7+
* WINDOWS: Volume will be saved when mplayer is installed in %APPDATA%\pyradio
58

69
2019-11-15 s-n-g
710
* PyRadio will not crush with mpv 0.30.0

README.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ <h3 id="mpv">MPV</h3>
267267

268268
[pyradio]
269269
volume=50</pre>
270+
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> If <strong>MPV 0.30.0</strong> is installed, there will be no visual notification when changing the volume. Furthermore, saving the volume value will <strong><em>not be possible</em></strong>. This is a <strong>pyradio</strong> bug and will be addressed in the future.</p>
270271
<h3 id="mplayer">MPlayer</h3>
271272
<p>MPlayer uses profiles to customize its behavior as well.</p>
272273
<p><strong>PyRadio</strong> defines a profile called “<strong>[pyradio]</strong>” in MPV’s configuration file (e.g. <em>~/.mplayer/config</em>). This profile will be used every time playback is started.</p>

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ Example:
380380
[pyradio]
381381
volume=50
382382

383+
**Note:** If **MPV 0.30.0** is installed, there will be no visual notification when changing the volume. Furthermore, saving the volume value will ***not be possible***. This is a **pyradio** bug and will be addressed in the future.
384+
383385
### MPlayer
384386

385387
MPlayer uses profiles to customize its behavior as well.

pyradio.1

Lines changed: 4 additions & 1 deletion
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 "November 2019"
4+
.TH PYRADIO 1 "December 2019"
55

66
.SH NAME
77
.PP
@@ -434,6 +434,9 @@ Example:
434434
.br
435435
volume=50
436436

437+
.IP \fBNote\fR
438+
If \fBMPV 0.30.0\fR is installed, there will be no visual notification when changing the volume. Furthermore, saving the volume value will \fInot be possible\fR. This is a \fBpyradio\fR bug and will be addressed in the future.
439+
437440
.PP
438441
\fBMPlayer\fR
439442
.PP

pyradio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" pyradio -- Console radio player. "
22

3-
version_info = (0, 8, 5)
3+
version_info = (0, 8, 6)
44

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

pyradio/browser.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class PyRadioBrowserInfoBrowser(PyRadioStationsBrowser):
152152
TITLE = 'Radio Browser'
153153

154154
_open_url = \
155-
'http://www.radio-browser.info/webservice/json/stations/topvote/100'
155+
'http://www.radio-browser.info/webservice/json/stations/topvote/100'
156156
_open_headers = {'user-agent': 'PyRadio/dev'}
157157

158158
_raw_stations = []
@@ -324,6 +324,7 @@ def search(self, data):
324324
self._last_search = post_data
325325
url = 'http://www.radio-browser.info/webservice/json/stations/search'
326326
try:
327+
#r = requests.get(url=url)
327328
r = requests.get(url=url, headers=self._open_headers, json=post_data, timeout=self._search_timeout)
328329
r.raise_for_status()
329330
self._raw_stations = self._extract_data(json.loads(r.text))
@@ -447,16 +448,23 @@ def _extract_data(self, a_search_result):
447448
if a_search_result:
448449
for n in a_search_result:
449450
ret.append({'name': n['name'].replace(',', ' ')})
450-
ret[-1]['bitrate'] = n['bitrate']
451-
ret[-1]['votes'] = n['votes']
452451
ret[-1]['url'] = n['url']
453452
ret[-1]['real_url'] = False
454453
ret[-1]['played'] = False
455454
ret[-1]['hls'] = n['hls']
456455
ret[-1]['id'] = n['id']
457456
ret[-1]['country'] = n['country']
457+
if isinstance(n['clickcount'], int):
458+
# old API
459+
ret[-1]['votes'] = str(n['votes'])
460+
ret[-1]['clickcount'] = str(n['clickcount'])
461+
ret[-1]['bitrate'] = str(n['bitrate'])
462+
else:
463+
# new API
464+
ret[-1]['votes'] = n['votes']
465+
ret[-1]['clickcount'] = n['clickcount']
466+
ret[-1]['bitrate'] = n['bitrate']
458467
ret[-1]['language'] = n['language']
459-
ret[-1]['clickcount'] = n['clickcount']
460468
ret[-1]['encoding'] = ''
461469
self._get_max_len(ret[-1]['votes'],
462470
ret[-1]['clickcount'])
@@ -468,9 +476,9 @@ def _get_max_len(self, votes, clicks):
468476
Parameters
469477
----------
470478
votes
471-
Number of station's vote
479+
Number of station's vote (string)
472480
clicks
473-
Number of station's clicks
481+
Number of station's clicks (string)
474482
numeric_data
475483
476484
Returns
@@ -481,6 +489,7 @@ def _get_max_len(self, votes, clicks):
481489
"""
482490

483491
numeric_data = (votes, clicks)
492+
logger.error('DE numeric_data = {}'.format(numeric_data))
484493
min_data = (6, 7)
485494
for i, n in enumerate(numeric_data):
486495
if len(n) > self._max_len[i]:
@@ -804,6 +813,7 @@ def get_data_dict(data):
804813

805814
def probeBrowsers(a_browser_url):
806815
base_url = a_browser_url.split('/')[2]
816+
logger.error('DE base_url = ' + base_url)
807817
if not base_url:
808818
base_url = a_browser_url
809819
implementedBrowsers = PyRadioStationsBrowser.__subclasses__()

pyradio/config_window.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,9 @@ class PyRadioSelectPlaylist(object):
939939
pageChange = 5
940940
jumpnr = ''
941941

942+
# offset to current item for padding calculation
943+
pad_adjustment = 0
944+
942945
def __init__(self, parent, config_path, default_playlist):
943946
self._parent_maxY, self._parent_maxX = parent.getmaxyx()
944947
self._config_path = config_path
@@ -1006,7 +1009,8 @@ def refresh_selection(self, resizing=False):
10061009
self._win.hline(self.maxY - 4, 1, ' ', self.maxX - 2, curses.color_pair(5))
10071010

10081011
else:
1009-
pad = len(str(self.startPos + self.maxY - 2))
1012+
pad = len(str(self.startPos + self.maxY - 2 - self.pad_adjustment))
1013+
#logger.error('DE \n\npos = {0}, pad = {1}\n\n'.format(self.startPos + self.maxY - 2 - self.pad_adjustment, pad))
10101014
for i in range(0, self.maxY - 2):
10111015
if i + self.startPos < self._num_of_items:
10121016
line, pad = self._format_line(i, pad)
@@ -1290,6 +1294,8 @@ def __init__(self, parent, config_path, default_playlist, default_station):
12901294
logger.info('self._default_playlist = ' + self._default_playlist)
12911295
PyRadioSelectPlaylist.__init__(self, parent, config_path, default_station)
12921296
self._title = ' Station Selection '
1297+
# adding 2 to padding calculation (i.e. no selection and random selection
1298+
self.pad_adjustment = 2
12931299

12941300
def _calculate_width(self):
12951301
self.maxX = 64
@@ -1373,7 +1379,7 @@ def _get_color(self, i):
13731379

13741380
def _format_line(self, i, pad):
13751381
""" PyRadioSelectStation format line """
1376-
fixed_pad = pad - 2
1382+
fixed_pad = pad
13771383
if i + self.startPos < 2:
13781384
line = '{0} {1}'.format(' '.rjust(fixed_pad),
13791385
self._items[i + self.startPos])

pyradio/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def shell():
179179
logging.raiseExceptions = False
180180
logging.lastResort = None
181181

182-
if requested_player is '':
182+
if requested_player == '':
183183
requested_player = pyradio_config.player
184184
#else:
185185
# pyradio_config.requested_player = requested_player

pyradio/player.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -540,16 +540,17 @@ def _buildStartOpts(self, streamUrl, playList=False):
540540
logger.debug("--input-ipc-server is not supported.")
541541
newerMpv = 0;
542542

543+
http_url = streamUrl.replace('https://', 'http://')
543544
if playList:
544545
if newerMpv:
545-
opts = [self.PLAYER_CMD, "--quiet", "--playlist", streamUrl, "--input-ipc-server=" + self.mpvsocket]
546+
opts = [self.PLAYER_CMD, "--quiet", "--playlist", http_url, "--input-ipc-server=" + self.mpvsocket]
546547
else:
547-
opts = [self.PLAYER_CMD, "--quiet", "--playlist", streamUrl, "--input-unix-socket=" + self.mpvsocket]
548+
opts = [self.PLAYER_CMD, "--quiet", "--playlist", http_url, "--input-unix-socket=" + self.mpvsocket]
548549
else:
549550
if newerMpv:
550-
opts = [self.PLAYER_CMD, "--quiet", streamUrl, "--input-ipc-server=" + self.mpvsocket]
551+
opts = [self.PLAYER_CMD, "--quiet", http_url, "--input-ipc-server=" + self.mpvsocket]
551552
else:
552-
opts = [self.PLAYER_CMD, "--quiet", streamUrl, "--input-unix-socket=" + self.mpvsocket]
553+
opts = [self.PLAYER_CMD, "--quiet", http_url, "--input-unix-socket=" + self.mpvsocket]
553554
if self.USE_PROFILE == -1:
554555
self.USE_PROFILE = self._configHasProfile()
555556

@@ -655,10 +656,11 @@ def _configHasProfile(self):
655656

656657
def _buildStartOpts(self, streamUrl, playList=False):
657658
""" Builds the options to pass to subprocess."""
659+
http_url = streamUrl.replace('https://', 'http://')
658660
if playList:
659-
opts = [self.PLAYER_CMD, "-quiet", "-playlist", streamUrl]
661+
opts = [self.PLAYER_CMD, "-quiet", "-playlist", http_url]
660662
else:
661-
opts = [self.PLAYER_CMD, "-quiet", streamUrl]
663+
opts = [self.PLAYER_CMD, "-quiet", http_url]
662664
if self.USE_PROFILE == -1:
663665
self.USE_PROFILE = self._configHasProfile()
664666

@@ -735,7 +737,7 @@ def save_volume(self):
735737
def _buildStartOpts(self, streamUrl, playList=False):
736738
""" Builds the options to pass to subprocess."""
737739
#opts = [self.PLAYER_CMD, "-Irc", "--quiet", streamUrl]
738-
opts = [self.PLAYER_CMD, "-Irc", "-vv", streamUrl]
740+
opts = [self.PLAYER_CMD, "-Irc", "-vv", streamUrl.replace('https://', 'http://')]
739741
return opts
740742

741743
def _mute(self):

pyradio/radio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,7 +1987,7 @@ def _set_active_stations(self):
19871987
self.active_stations = [
19881988
[ '', self.selection ],
19891989
[ '', -1 ] ]
1990-
logger.error('DE active_stations = \n\n{}\n\n'.format(self.active_stations))
1990+
#logger.error('DE active_stations = \n\n{}\n\n'.format(self.active_stations))
19911991

19921992
def get_active_encoding(self, an_encoding):
19931993
if an_encoding:
@@ -2319,7 +2319,7 @@ def _open_playlist_from_history(self, reset=False):
23192319
removed_playlist_history_item = self._cnf.remove_from_playlist_history()
23202320
err_string = '"|{}|"'.format(self._cnf.station_title)
23212321

2322-
logger.error('DE\n\n Opening: "{}"\n\n'.format(self._cnf.station_path))
2322+
#logger.error('DE\n\n Opening: "{}"\n\n'.format(self._cnf.station_path))
23232323
ret = self._cnf.read_playlist_file(self._cnf.station_path)
23242324

23252325
if ret == -1:

0 commit comments

Comments
 (0)