Skip to content

Commit bc210b0

Browse files
committed
- Version 0.8.8-beta4
- finalizing force http connections and updating docs
1 parent c888f13 commit bc210b0

File tree

8 files changed

+168
-6
lines changed

8 files changed

+168
-6
lines changed

Changelog

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
2020-11-05
1+
2020-11-17
2+
* Versio 0.8.8-beta4
3+
* Adding the "Force http connections" configuration
4+
option (#113)
5+
* Fixed a couple of bugs
26
* Installation script will use Python 3 by default
37

48
2020-10-30 s-n-g

README.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ <h2 id="table-of-contents">Table of contents <span style="padding-left: 10px;"><
3939
<li><a href="#moving-stations-around">Moving stations around</a></li>
4040
<li><a href="#specifying-stations-encoding">Specifying stations’ encoding</a></li>
4141
<li><a href="#player-detection-selection">Player detection / selection</a></li>
42+
<li><a href="#player-connection-protocol">Player connection protocol</a></li>
4243
<li><a href="#player-default-volume-level">Player default volume level</a></li>
4344
<li><a href="#displaying-station-info">Displaying Station Info</a></li>
4445
<li><a href="#copying-and-pasting---registers">Copying and pasting - Registers</a></li>
@@ -124,6 +125,7 @@ <h2 id="controls">Controls <span style="padding-left: 10px;"><sup style="font-si
124125
&lt;n&gt;^U &lt;n&gt;^D Move station up / down. - -
125126
&#39; \ y Get into Registers, Extra Commands y (yank) is not applicable -
126127
and Yank modes, respectively
128+
z Toggle &quot;Force http connections&quot; - -
127129
? Show keys help [Valid] [Valid]
128130
# Redraw window [Valid] [Valid]
129131
Esc/q Quit - -
@@ -275,6 +277,14 @@ <h2 id="player-detection-selection">Player detection / selection <span style="pa
275277
<pre>pyradio -u vlc,mplayer,mpv</pre>
276278
<p>will instruct <strong>PyRadio</strong> to look for VLC, then MPlayer and finaly for MPV and use whichever it finds first; if none is found, the program will terminate with an error.</p>
277279
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> The default player to use can also be set in <strong>PyRadio</strong>’s <a href="#config-file">configuration file</a>, parameter <strong>player</strong> (default value is <strong>mpv, mplayer, vlc</strong>).</p>
280+
<h2 id="player-connection-protocol">Player connection protocol <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
281+
<p>Most radio stations use plain old http protocol to broadcast, but some of them use https.</p>
282+
<p>Experience has shown that playing a <strong>https</strong> radio station depends on the combination of the station’s configuration and the player used.</p>
283+
<p>If such a station fails to play, one might as well try to use <strong>http</strong> protocol to connect to it.</p>
284+
<p><strong>PyRadio</strong> provides a way to instruct the player used to do so; the “<em>Force http connections</em>” configuration parameter. If it is <em>False</em> (the default), the player will use whatever protocol the station proposes (either <strong>http</strong> or <strong>https</strong>). When changed to <strong>True</strong>, all connections will use the <strong>http</strong> protocol.</p>
285+
<p>When the selected player is initialized (at program startup), it reads this configuration parameter and acts accordingly.</p>
286+
<p>If the parameter has to be changed mid-session (without restarting the program), one would press “<em>z</em>” to display the “<em>Connection Type</em>” window, where the parameter’s value can be set as desired.</p>
287+
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> Changes made using the “<em>Connection Type</em>” window are not stored; next time the program is executed, it will use whatever value the configuration parameter holds.</p>
278288
<h2 id="player-default-volume-level">Player default volume level <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
279289
<p>MPV and MPlayer, when started, use their saved (or default) volume level to play any multimedia content. Fortunately, this is not the case with VLC.</p>
280290
<p>This introduces a problem to <strong>PyRadio</strong>: every time a user plays a station (i.e restarts playback), even though he may have already set the volume to a desired level, the playback starts at the player’s default level.</p>

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Ben Dowling - [https://github.com/coderholic](https://github.com/coderholic)
1818
* [Moving stations around](#moving-stations-around)
1919
* [Specifying stations' encoding](#specifying-stations-encoding)
2020
* [Player detection / selection](#player-detection-selection)
21+
* [Player connection protocol](#player-connection-protocol)
2122
* [Player default volume level](#player-default-volume-level)
2223
* [Displaying Station Info](#displaying-station-info)
2324
* [Copying and pasting - Registers](#copying-and-pasting---registers)
@@ -112,6 +113,7 @@ J Create a jump tag
112113
<n>^U <n>^D Move station up / down. - -
113114
' \ y Get into Registers, Extra Commands y (yank) is not applicable -
114115
and Yank modes, respectively
116+
z Toggle "Force http connections" - -
115117
? Show keys help [Valid] [Valid]
116118
# Redraw window [Valid] [Valid]
117119
Esc/q Quit - -
@@ -393,6 +395,22 @@ will instruct **PyRadio** to look for VLC, then MPlayer and finaly for MPV and u
393395
**Note:** The default player to use can also be set in **PyRadio**'s [configuration file](#config-file), parameter **player** (default value is **mpv, mplayer, vlc**).
394396

395397

398+
## Player connection protocol
399+
400+
Most radio stations use plain old http protocol to broadcast, but some of them use https.
401+
402+
Experience has shown that playing a **https** radio station depends on the combination of the station's configuration and the player used.
403+
404+
If such a station fails to play, one might as well try to use **http** protocol to connect to it.
405+
406+
**PyRadio** provides a way to instruct the player used to do so; the "*Force http connections*" configuration parameter. If it is *False* (the default), the player will use whatever protocol the station proposes (either **http** or **https**). When changed to **True**, all connections will use the **http** protocol.
407+
408+
When the selected player is initialized (at program startup), it reads this configuration parameter and acts accordingly.
409+
410+
If the parameter has to be changed mid-session (without restarting the program), one would press "*z*" to display the "*Connection Type*" window, where the parameter's value can be set as desired.
411+
412+
**Note:** Changes made using the "*Connection Type*" window are not stored; next time the program is executed, it will use whatever value the configuration parameter holds.
413+
396414
## Player default volume level
397415

398416
MPV and MPlayer, when started, use their saved (or default) volume level to play any multimedia content. Fortunately, this is not the case with VLC.

pyradio.1

Lines changed: 22 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 "October 2020"
4+
.TH PYRADIO 1 "November 2020"
55

66
.SH NAME
77
.PP
@@ -459,6 +459,24 @@ will instruct \fBpyradio\fR to look for VLC, then MPlayer and finaly for MPV and
459459
.IP \fBNote\fR
460460
The default player to use can also be set in \fBpyradio\fR’s configuration file, parameter \fIplayer\fR (default value is \fImpv, mplayer, vlc\fR).
461461

462+
463+
.SH PLAYER CONNECTION PROTOCOL
464+
465+
Most radio stations use plain old http protocol to broadcast, but some of them use https.
466+
467+
Experience has shown that playing a \fBhttps\fR radio station depends on the combination of the station's configuration and the player used.
468+
469+
If such a station fails to play, one might as well try to use \fBhttp\fR protocol to connect to it.
470+
471+
\fBpyradio\fR provides a way to instruct the player used to do so; the "\fIForce http connections\fR" configuration parameter. If it is \fIFalse\fR (the default), the player will use whatever protocol the station proposes (either \fBhttp\fR or \fBhttps\fR). When changed to \fBTrue\fR, all connections will use the \fBhttp\fR protocol.
472+
473+
When the selected player is initialized (at program startup), it reads this configuration parameter and acts accordingly.
474+
475+
If the parameter has to be changed mid-session (without restarting the program), one would press "\fIz\fR" to display the "\fIConnection Type\fR" window, where the parameter's value can be set as desired.
476+
477+
.IP \fBNote\fR
478+
Changes made using the "\fIConnection Type\fR" window are not stored; next time the program is executed, it will use whatever value the configuration parameter holds.
479+
462480
.SH PLAYER DEFAULT VOLUME LEVEL
463481
.PP
464482
\fIMPV\fR and \fIMPlayer\fR, when started, use their saved (or default) volume level to play any multimedia content. Fortunately, this is not the case with \fIVLC\fR.
@@ -766,4 +784,7 @@ On \fBMac OS\fR, these file may be installed in \fI/usr/local/share/doc/pyradio\
766784
\fBPeter Stevenson (2E0PGS)\fR\ \<\fIhttps://github.com/2E0PGS\fR\>,\ (2018)
767785
.PP
768786
\fBSpiros Georgaras\fR\ \<\fIhttps://github.com/s-n-g\fR\>,\ (2018-2020)
787+
.PP
788+
You can see a complete list of contributors at
789+
https://github.com/coderholic/pyradio/graphs/contributors
769790

pyradio/config_window.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class PyRadioConfigWindow(object):
6060
_help_text.append(['PyRadio will wait for this number of seconds to get a station/server message indicating that playback has actually started.', '|',
6161
'If this does not happen within this number of seconds after the connection is initiated, PyRadio will consider the station unreachable, and display the "Failed to connect to: station" message.', '|', 'Press "h"/Left or "l"/Right to change value.',
6262
'|', 'Valid values: 5 - 60', 'Default value: 10'])
63-
_help_text.append(['Most radio stations use plain old http protocol to broadcast, but some of them use https.', '|', 'If this is enabled, all connections will use http; results depend on the combination of station/player.', '|', 'This value is read at program startup, use Ctrl-S to change its effect while mid-session.',
63+
_help_text.append(['Most radio stations use plain old http protocol to broadcast, but some of them use https.', '|', 'If this parameter is enabled, all connections will use http; results depend on the combination of station/player.', '|', 'This value is read at program startup, use "z" to change its effect while mid-session.',
6464
'|', 'Default value: False'])
6565
_help_text.append(None)
6666
_help_text.append(['The theme to be used by default.', '|',

pyradio/edit.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,4 +1049,73 @@ def keypress(self, char):
10491049
#self.show()
10501050
return self._get_result(ret)
10511051

1052+
class PyRadioConnectionType(object):
1053+
1054+
_title = ' Connection Type '
1055+
_text = 'Force http connections: '
1056+
_help_text = ' Help '
1057+
1058+
def __init__(self, parent, connection_type):
1059+
self._parent = parent
1060+
self.connection_type = connection_type
1061+
1062+
def show(self, parent=None):
1063+
if parent:
1064+
self._parent = parent
1065+
y, x = self._parent.getmaxyx()
1066+
new_y = int(y/2) - 2
1067+
new_x = int( (x - len(self._text) - 9 - 4) /2 )
1068+
self.MaxX = len(self._text) + 9 + 4
1069+
self._win = None
1070+
self._win = curses.newwin(10, self.MaxX, new_y, new_x)
1071+
self._win.bkgdset(' ', curses.color_pair(3))
1072+
self._win.erase()
1073+
self._win.box()
1074+
1075+
# show title
1076+
x = int((self.MaxX - len(self._title)) / 2)
1077+
self._win.addstr(0, x, self._title, curses.color_pair(4))
1078+
1079+
# show content
1080+
self._win.addstr(2, 4, self._text, curses.color_pair(5))
1081+
self._win.addstr('{}'.format(self.connection_type), curses.color_pair(4))
1082+
1083+
# show help
1084+
try:
1085+
self._win.addstr(4, 2, '─' * (self.MaxX - 4), curses.color_pair(3))
1086+
except:
1087+
self._win.addstr(4, 2, '─'.encode('utf-8') * (self.maxX - 6), curses.color_pair(3))
1088+
self._win.addstr(4, int((self.MaxX - len(self._help_text))/2), self._help_text, curses.color_pair(3))
1089+
self._win.addstr(5, 2, 'j k l SPACE', curses.color_pair(4))
1090+
self._win.addstr(6, 2, 'RIGHT UP DOWN', curses.color_pair(4))
1091+
self._win.addstr(' Toggle parameter', curses.color_pair(5))
1092+
self._win.addstr(7, 2, 'ENTER s', curses.color_pair(4))
1093+
self._win.addstr(' Accept parameter', curses.color_pair(5))
1094+
self._win.addstr(8, 2, 'Esc q h RIGHT', curses.color_pair(4))
1095+
self._win.addstr(' Cancel operation', curses.color_pair(5))
1096+
1097+
1098+
self._win.refresh()
1099+
1100+
def keypress(self, char):
1101+
""" Returns:
1102+
-1: Cancel
1103+
0: go on
1104+
1: Ok
1105+
"""
1106+
if char in (curses.KEY_ENTER, ord('\n'), ord('\r'), ord('s')):
1107+
return 1
1108+
1109+
elif char in (curses.KEY_EXIT, 27, ord('q'), ord('h'), curses.KEY_LEFT):
1110+
return -1
1111+
1112+
elif char in (ord('j'), ord('k'), ord('l'), ord(' '),
1113+
curses.KEY_RIGHT, curses.KEY_UP, curses.KEY_DOWN):
1114+
self.connection_type = not self.connection_type
1115+
self._win.addstr(2, len(self._text) + 3, '{}'.format(self.connection_type), curses.color_pair(3))
1116+
self._win.refresh()
1117+
1118+
return 0
1119+
1120+
10521121

pyradio/radio.py

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from .window_stack import Window_Stack
3030
from .config_window import *
3131
from .log import Log
32-
from .edit import PyRadioSearch, PyRadioEditor, PyRadioRenameFile
32+
from .edit import PyRadioSearch, PyRadioEditor, PyRadioRenameFile, PyRadioConnectionType
3333
from .themes import *
3434
from .cjkwrap import cjklen
3535
from . import player
@@ -269,6 +269,7 @@ def __init__(self, pyradio_config, play=False, req_player='', theme=''):
269269
self.ws.PLAYLIST_COPY_ERROR: self._print_playlist_copy_error,
270270
self.ws.PLAYLIST_RENAME_ERROR: self._print_playlist_rename_error,
271271
self.ws.PLAYLIST_NOT_SAVED_ERROR_MODE: self._print_playlist_not_saved_error,
272+
self.ws.CONNECTION_MODE: self._show_http_connection,
272273
}
273274

274275
""" list of help functions """
@@ -286,6 +287,9 @@ def __init__(self, pyradio_config, play=False, req_player='', theme=''):
286287
self.ws.SELECT_ENCODING_MODE: self._show_config_encoding_help,
287288
self.ws.EDIT_STATION_ENCODING_MODE: self._show_config_encoding_help,
288289
self.ws.LINE_EDITOR_HELP_MODE: self._show_line_editor_help,
290+
self.ws.REGISTER_HELP_MODE: self._show_register_help,
291+
self.ws.EXTRA_COMMANDS_HELP_MODE: self._show_extra_commands_help,
292+
self.ws.YANK_HELP_MODE: self._show_yank_help,
289293
}
290294

291295
""" search classes
@@ -1405,7 +1409,9 @@ def _show_main_help_page_3(self):
14051409
a-z| / |0-9 |Copy station to named register.
14061410
!Registe mode (')
14071411
' |Open registers list.
1408-
a-z| / |0-9 |Open named register."""
1412+
a-z| / |0-9 |Open named register.
1413+
!Connection type
1414+
z |Toggle "Force http connections" """
14091415
self._show_help(txt, mode_to_set=self.ws.MAIN_HELP_MODE_PAGE_3, reset_metrics=False)
14101416

14111417
def _show_playlist_help(self):
@@ -1654,7 +1660,6 @@ def _show_extra_commands_help(self):
16541660
self._show_help(txt, mode_to_set=self.ws.EXTRA_COMMANDS_HELP_MODE, caption=' Extra Commands Help ')
16551661

16561662
def _show_yank_help(self):
1657-
pass
16581663
txt = """ENTER |Copy station to unnamed register.
16591664
a-z| / |0-9 |Copy station to named register.
16601665
@@ -4088,6 +4093,7 @@ def keypress(self, char):
40884093

40894094
elif self.ws.operation_mode == self.ws.ASK_TO_SAVE_PLAYLIST_WHEN_EXITING_MODE:
40904095
if char in (ord('y'), ord('Y')):
4096+
self.ws.close_window()
40914097
if not self._cnf.locked and char == ord('Y'):
40924098
self._cnf.auto_save_playlist = True
40934099
ret = self.saveCurrentPlaylist()
@@ -4238,6 +4244,21 @@ def keypress(self, char):
42384244
self.refreshBody()
42394245
return
42404246

4247+
elif self.ws.operation_mode == self.ws.CONNECTION_MODE:
4248+
ret = self._connection_type_edit.keypress(char)
4249+
if ret == -1:
4250+
# Cancel
4251+
self.ws.close_window()
4252+
self._connection_type_edit = None
4253+
pass
4254+
elif ret == 1:
4255+
# changed
4256+
self.ws.close_window()
4257+
self.player.force_http = self._connection_type_edit.connection_type
4258+
self._connection_type_edit = None
4259+
self.refreshBody()
4260+
return
4261+
42414262
elif self.ws.operation_mode in self.ws.PASSIVE_WINDOWS:
42424263
if self.ws.operation_mode in (self.ws.MAIN_HELP_MODE,
42434264
self.ws.MAIN_HELP_MODE_PAGE_2,
@@ -4581,7 +4602,19 @@ def keypress(self, char):
45814602
curses.ungetch('y')
45824603
return
45834604

4605+
elif char in (ord('z'), ):
4606+
# change force http
4607+
self._random_requested = False
4608+
self.jumpnr = ''
4609+
self._cnf.jump_tag = -1
4610+
self._update_status_bar_right(status_suffix='')
4611+
self.ws.operation_mode = self.ws.CONNECTION_MODE
4612+
self._connection_type_edit = PyRadioConnectionType(parent=self.bodyWin,connection_type=self.player.force_http)
4613+
self._connection_type_edit.show()
4614+
return
4615+
45844616
elif char == ord('J'):
4617+
self._random_requested = False
45854618
self.jumpnr = ''
45864619
# tag for jump
45874620
self._cnf.jump_tag = self.selection
@@ -4590,6 +4623,7 @@ def keypress(self, char):
45904623

45914624
elif char in (curses.ascii.NAK, 21):
45924625
# ^U, move station Up
4626+
self._random_requested = False
45934627
if self.jumpnr:
45944628
self._cnf.jump_tag = int(self.jumpnr) - 1
45954629
self._move_station(-1)
@@ -4600,6 +4634,7 @@ def keypress(self, char):
46004634

46014635
elif char in (curses.ascii.EOT, 4):
46024636
# ^D, move station Down
4637+
self._random_requested = False
46034638
if self.jumpnr:
46044639
self._cnf.jump_tag = int(self.jumpnr) - 1
46054640
self._move_station(1)
@@ -5201,6 +5236,9 @@ def _search_sublist(self, a_list, ind, a_search):
52015236
except ValueError as e:
52025237
return -1
52035238

5239+
def _show_http_connection(self):
5240+
self._connection_type_edit.show(parent=self.bodyWin)
5241+
52045242
"""''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
52055243
Windows only section
52065244
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''"""

pyradio/window_stack.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Window_Stack_Constants(object):
3737
STATION_INFO_MODE = 58
3838
NEW_PLAYLIST_MODE = 59
3939
RENAME_PLAYLIST_MODE = 60
40+
CONNECTION_MODE = 61
4041
MAIN_HELP_MODE = 100
4142
MAIN_HELP_MODE_PAGE_2 = 101
4243
MAIN_HELP_MODE_PAGE_3 = 102
@@ -164,6 +165,7 @@ class Window_Stack_Constants(object):
164165
PLAYLIST_COPY_ERROR: 'PLAYLIST_COPY_ERROR',
165166
PLAYLIST_RENAME_ERROR: 'PLAYLIST_RENAME_ERROR',
166167
PLAYLIST_NOT_SAVED_ERROR_MODE: 'PLAYLIST_NOT_SAVED_ERROR_MODE',
168+
CONNECTION_MODE: 'CONNECTION_MODE',
167169
}
168170

169171
''' When PASSIVE_WINDOWS target is one of them,

0 commit comments

Comments
 (0)