Skip to content

Commit 725f36d

Browse files
committed
updating documents, adding server{md,html}
1 parent ae385e0 commit 725f36d

14 files changed

+606
-55
lines changed

README.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ <h2 id="table-of-contents">Table of Contents <span style="padding-left: 10px;"><
150150
<ul>
151151
<li><a href="#updating-a-pre-0.8.9-installation">Updating a pre 0.8.9 installation</a></li>
152152
</ul></li>
153+
<li><a href="#remote-control-server">Remote Control Server</a></li>
153154
<li><a href="#cleaning-up">Cleaning up</a></li>
154155
<li><a href="#debug-mode">Debug mode</a></li>
155156
<li><a href="#reporting-bugs">Reporting bugs</a></li>
@@ -170,6 +171,7 @@ <h2 id="features">Features <span style="padding-left: 10px;"><sup style="font-si
170171
<li>Search function</li>
171172
<li>Theming support</li>
172173
<li><a href="radio-browser.html">RadioBrowser</a> support</li>
174+
<li>Remote Control</li>
173175
<li>Easy installation / updating</li>
174176
<li>Runs on Linux, macOS and Windows</li>
175177
</ul>
@@ -1595,7 +1597,7 @@ <h2 id="titles-logging">Titles logging <span style="padding-left: 10px;"><sup st
15951597
<li>using the -lt (--log-titles) command line option, or</li>
15961598
<li>by pressing “<strong>W</strong>” while in the <strong>Main</strong>, the <strong>Playlist</strong> or the <strong>Register</strong> mode.</li>
15971599
</ol>
1598-
<p>The titles are written in a file called pyradio-titles.log which is saved at <strong>PyRadio</strong> configuration directory.</p>
1600+
<p>The titles are written in a file called <em>pyradio-titles.log</em> which is saved at <strong>PyRadio</strong> configuration directory.</p>
15991601
<p>Log file sample:</p>
16001602
<pre>Apr 18 (Mon) 13:12 | &gt;&gt;&gt; Station: Lounge (Illinois Street Lounge - SomaFM)
16011603
Apr 18 (Mon) 13:12 | Jack Costanzo - La Cumparsa, Harlem Nocturne
@@ -1669,6 +1671,9 @@ <h3 id="updating-a-pre-0.8.9-installation">Updating a pre 0.8.9 installation</h3
16691671
<p><strong>Note</strong>: If you have neither <em>wget</em> or <em>curl</em> installed, or you are on Windows, just right click on <a target="_blank" href="https://raw.githubusercontent.com/coderholic/pyradio/master/pyradio/install.py">this link</a> and use your browser “<strong>Save link as</strong>” menu entry to save the file in your home folder.</p>
16701672
<p>Finally, execute the command:</p>
16711673
<pre>python install.py --force</pre>
1674+
<h2 id="remote-control-server">Remote Control Server <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
1675+
<p><strong>PyRadio</strong> can be controlled remotely using normal http requests either form the command line (with <em>curl</em> for example) or from a browser.</p>
1676+
<p>For more information, please refer to <a href="server.html">the relevant page</a>.</p>
16721677
<h2 id="cleaning-up">Cleaning up <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
16731678
<p><strong>PyRadio</strong> will uninstall all previously installed versions when updated (using the <strong>-U</strong> command line option), so no extra steps are needed any more to house keep your system.</p>
16741679
<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></span></h2>
@@ -1709,8 +1714,8 @@ <h2 id="packaging-pyradio">Packaging PyRadio <span style="padding-left: 10px;"><
17091714
<p>to have notifications every 60 seconds, for example. You can use any value here, starting from 30 to 300 (meaning every 30 seconds up to 5 minutes), using a step of 30.</p>
17101715
<p>Finally, make sure you install:</p>
17111716
<ul>
1712-
<li>devel/pyradio.png to /usr/share/icons or /usr/local/share/icons or any other suitable location.</li>
1713-
<li>devel/pyradio.desktop to /usr/share/applications or /usr/local/share/applications or any other suitable location.</li>
1717+
<li><em>devel/pyradio.png</em> to <em>/usr/share/icons</em> or <em>/usr/local/share/icons</em> or any other suitable location.</li>
1718+
<li><em>devel/pyradio.desktop</em> to <em>/usr/share/applications</em> or <em>/usr/local/share/applications</em> or any other suitable location.</li>
17141719
</ul>
17151720
<h2 id="todo">TODO <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
17161721
<ul class="task-list">

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Ben Dowling - [https://github.com/coderholic](https://github.com/coderholic)
7676
* [Session unlocking](#session-unlocking)
7777
* [Update notification](#update-notification)
7878
* [Updating a pre 0.8.9 installation](#updating-a-pre-0.8.9-installation)
79+
* [Remote Control Server](#remote-control-server)
7980
* [Cleaning up](#cleaning-up)
8081
* [Debug mode](#debug-mode)
8182
* [Reporting bugs](#reporting-bugs)
@@ -98,6 +99,7 @@ Ben Dowling - [https://github.com/coderholic](https://github.com/coderholic)
9899
- Search function
99100
- Theming support
100101
- [RadioBrowser](radio-browser.md) support
102+
- Remote Control
101103
- Easy installation / updating
102104
- Runs on Linux, macOS and Windows
103105

@@ -1087,7 +1089,7 @@ The function can be enabled:
10871089
1. using the `-lt` (`--log-titles`) command line option, or
10881090
2. by pressing "**W**" while in the **Main**, the **Playlist** or the **Register** mode.
10891091

1090-
The titles are written in a file called `pyradio-titles.log` which is saved at **PyRadio** configuration directory.
1092+
The titles are written in a file called *pyradio-titles.log* which is saved at **PyRadio** configuration directory.
10911093

10921094
Log file sample:
10931095

@@ -1216,6 +1218,12 @@ Finally, execute the command:
12161218

12171219
python install.py --force
12181220

1221+
## Remote Control Server
1222+
1223+
**PyRadio** can be controlled remotely using normal http requests either form the command line (with *curl* for example) or from a browser.
1224+
1225+
For more information, please refer to [the relevant page](server.md).
1226+
12191227
## Cleaning up
12201228

12211229
**PyRadio** will uninstall all previously installed versions when updated (using the **-U** command line option), so no extra steps are needed any more to house keep your system.
@@ -1285,8 +1293,8 @@ to have notifications every 60 seconds, for example. You can use any value here,
12851293

12861294
Finally, make sure you install:
12871295

1288-
- `devel/pyradio.png` to `/usr/share/icons` or `/usr/local/share/icons` or any other suitable location.
1289-
- `devel/pyradio.desktop` to `/usr/share/applications` or `/usr/local/share/applications` or any other suitable location.
1296+
- *devel/pyradio.png* to */usr/share/icons* or */usr/local/share/icons* or any other suitable location.
1297+
- *devel/pyradio.desktop* to */usr/share/applications* or */usr/local/share/applications* or any other suitable location.
12901298

12911299
## TODO
12921300

desktop-notification.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ <h2 id="on-windows-7">On Windows 7 <span style="padding-left: 10px;"><sup style=
146146

147147
<p>If you are on <strong>Windows 7</strong>, you will have a differently looking notification (shown above).</p>
148148
<p>If you click on the little tool-like “icon” next to the “X”, you get to the “<strong>Notification Area Icons</strong>”, the notifications configuration window. A couple of options are available, and again, I do not know how easy it will be to enable the notification if disabled once.</p>
149-
<p><a href="https://members.hellug.gr/sng/pyradio/win7-icons.jpg" target="_blank"><img style="width: 574px" src="https://members.hellug.gr/sng/pyradio/win7-icons.jpg" alt="Windows 7 Nontification Icons" /></a></p>
149+
<p><a href="https://members.hellug.gr/sng/pyradio/win7-icons.jpg" target="_blank"><img style="width: 482px" src="https://members.hellug.gr/sng/pyradio/win7-icons.jpg" alt="Windows 7 Nontification Icons" /></a></p>
150150

151151
<p>Again, Window considers that the program sending the notifications is <strong>Python</strong>, not <strong>PyRadio</strong>, so that’s what you will be changing.</p>
152152
</body>

devel/pre-commit

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ sed -i 's/\t/ /g' Changelog
3434

3535

3636
# Create HTML file from md files
37-
for afile in README.md build.md windows.md windows-mplayer.md windows-mpv.md radio-browser.md desktop-notification.md
37+
for afile in README.md build.md windows.md windows-mplayer.md windows-mpv.md radio-browser.md desktop-notification.md server.md
3838
do
3939
#[ -z "$(git status | grep ${afile})" ] || {
4040
out=${afile/%.md/.html}
@@ -52,6 +52,8 @@ do
5252
echo '% PyRadio RadioBrowser Implementation' > tmp.md
5353
elif [ "$afile" = "desktop-notification.md" ];then
5454
echo '% PyRadio Desktop Notifications' > tmp.md
55+
elif [ "$afile" = "server.md" ];then
56+
echo '% PyRadio Remote Control Server' > tmp.md
5557
fi
5658
cat ${afile} >> tmp.md
5759
pandoc --wrap=none -s -t html tmp.md -o ${out} || {
@@ -132,7 +134,10 @@ do
132134
sed -i -e '/win-notif/s/src=/style="width: 411px" src=/' "$out"
133135
sed -i -e '/win7-notif/s/src=/style="width: 411px" src=/' "$out"
134136
sed -i -e '/win-python-props/s/src=/style="width: 574px" src=/' "$out"
135-
sed -i -e '/win7-icons.jpg/s/src=/style="width: 574px" src=/' "$out"
137+
sed -i -e '/win7-icons.jpg/s/src=/style="width: 482px" src=/' "$out"
138+
fi
139+
if [ "$out" = "server.html" ];then
140+
sed -i -e '/server-on.jpg/s/src=/style="width: 574px" src=/' "$out"
136141
fi
137142

138143
sed -i '/^<[Aa]/s|.*|<p>&</p>|' "$out"

pyradio.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.\" Copyright (C) 2011 Ben Dowling <http://www.coderholic.com/pyradio>
2-
.\" Copyright (C) 2018 Spiros Georgaras <[email protected]>
2+
.\" Copyright (C) 2018-2023 Spiros Georgaras <[email protected]>
33
.\" This manual is freely distributable under the terms of the GPL.
44
.\"
55
.TH pyradio 1 "November 2022" pyradio
@@ -1595,4 +1595,4 @@ You can see a complete list of contributors at
15951595

15961596
.SH See also
15971597

1598-
pyradio_rb(1)
1598+
pyradio_rb(1) pyradio_server(1)

pyradio/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,6 +2989,7 @@ def configure_logger(self, debug=None, titles=None):
29892989

29902990
logging.raiseExceptions = False
29912991
logging.lastResort = None
2992+
# logger.info('self.log_titles = {}'.format(self.log_titles))
29922993

29932994
def tag_title(self, the_log):
29942995
''' tags a title

pyradio/config_window.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ class PyRadioConfigWindow(object):
8888
'|', 'Default value: True'])
8989
_help_text.append(['Specify whether you will be asked to save a modified playlist whenever it needs saving.', '|', 'Default value: False'])
9090
_help_text.append(None)
91-
_help_text.append(['This is the IP for the Remote Control Server.', '|', 'Available options:', '- localhost', ' PyRadio will be accessible from within the current system only.', '- LAN', ' PyRadio will be accessible from any computer in the local network.', '|', 'One can see the active IP using the "\s" command from the program\'s Main Window.', '|', 'Use "Space", "h/Left", "l/Right" to change the value.','|', 'Default value: localhost'])
91+
_help_text.append(['This is the IP for the Remote Control Server.', '|', 'Available options:', '- localhost', ' PyRadio will be accessible from within the current system only.', '- LAN', ' PyRadio will be accessible from any computer in the local network.', '|', 'One can see the active IP using the "\s" command from the program\'s Main Window.', '|', 'Use "Space", "Enter", "l/Right" to change the value.','|', 'Default value: localhost'])
9292
_help_text.append(
93-
['This is the port used by the Remote Control Server (the port the server is listening to).', '|', 'Please make sure that a "free" port is specified here, to avoid any conflicts with existing services and daemons.', '|', 'None of the one-letter commands will work here; use the arrows (and PgUp / PgDn) to move to other fields.', '|', 'If an invalid port number is inserted, the cursor will not move to another field.', '|', 'Valid values: 1025-65535', 'Default value: 9998'])
93+
['This is the port used by the Remote Control Server (the port the server is listening to).', '|', 'Please make sure that a "free" port is specified here, to avoid any conflicts with existing services and daemons.', '|', 'If an invalid port number is inserted, the cursor will not move to another field.', '|', 'Valid values: 1025-65535', 'Default value: 9998'])
9494
_help_text.append(['If set to True, the Server wiil be automatically started when PyRadio starts.', 'If set to False, one can start the Server using the "\s" command from the Main program window.', '|', 'Default value: False'])
9595
_help_text.append(None)
9696
_help_text.append(['This options will open the configuration window for the RadioBrowser Online Stations Directory.', '|', "In order to use RadioBrowser, python's requests module must be installed."])
@@ -752,7 +752,7 @@ def keypress(self, char):
752752
return -1, []
753753

754754
elif val[0] == 'remote_control_server_ip':
755-
if char in (curses.KEY_RIGHT, ord('l'), ord(' ')):
755+
if char in (curses.KEY_RIGHT, ord('l'), ord(' '), ord('\n'), curses.KEY_ENTER):
756756
if self._config_options[val[0]][1] == 'localhost':
757757
self._config_options[val[0]][1] = 'LAN'
758758
disp = 'LAN '

pyradio/log.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ def _set_web_title(self, msg):
309309
# 'abnormal' in msg:
310310
# title = msg
311311
if msg.startswith('Playing: ') or \
312-
'abnormal' in msg:
313-
title = msg
314-
elif msg.startswith('Failed to'):
312+
msg.startswith('Connecting to: ') or \
313+
'abnormal' in msg or \
314+
msg.startswith('Failed to'):
315315
title = msg
316316
with self._song_title_lock:
317317
old_song_title = self._song_title

pyradio/radio.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,8 +1510,10 @@ def ctrl_c_handler(self, signum, frame):
15101510
terminates at program exit.
15111511
If that causes problems, uncomment lines
15121512
'''
1513-
# if self._remote_control_server:
1514-
# self._remote_control_server.close_server()
1513+
while self._remote_control_server is not None:
1514+
ret, _ = self._remote_control_server.close_server()
1515+
if ret:
1516+
self._remote_control_server = None
15151517
self.restore_colors()
15161518

15171519
def _wait_for_threads(self):
@@ -9275,7 +9277,7 @@ def _start_remote_control_server(self):
92759277
If that causes problems, commane the following line
92769278
and uncomment lines in ctrl_c_handler()
92779279
'''
9278-
self._remote_control_server_thread.daemon = True
9280+
# self._remote_control_server_thread.daemon = True
92799281
self._remote_control_server_thread.start()
92809282

92819283
def _stop_remote_control_server(self):

0 commit comments

Comments
 (0)