Skip to content

Commit 6380053

Browse files
committed
- mpv will parse "artist" field in addition to "title"
- updating the help/commands output for text based remote control server - most text based remote control server will return "/title" - commenting scheduler related code in main.py - the message to indicate failure to connect to RadioBrowser will be displayed for 2 seconds - updating docs
1 parent f4317e0 commit 6380053

File tree

10 files changed

+326
-131
lines changed

10 files changed

+326
-131
lines changed

docs/headless.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ <h2 id="goal">Goal <span style="padding-left: 10px;"><sup style="font-size: 50%"
7272
<p><strong>Screen</strong> is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells)… Programs continue to run when their window is currently not visible and even when the whole screen session <strong>is detached from the user’s terminal</strong>.”</p>
7373
<p><strong>PyRadio</strong> users <a target="_blank" href="https://github.com/Wikinaut">Wikinaut</a> and <a target="_blank" href="https://github.com/aleksandr-sabitov">aleksandr-sabitov</a> on <a target="_blank" href="https://github.com/coderholic/pyradio/issues/184">github</a> have come up with the idea to use this approach to run the application on their headless Raspberry Pi, so kudos to them!</p>
7474
<h3 id="usage">Usage</h3>
75-
<p>After the program is started, the only way (well, not really, more on this below) to interact with it is through its integrated web server.</p>
75+
<p>After the program is started, the only way to interact with it is through its integrated web server. Please refref to the relevant document for more info on the <a href="server.html">remote control server</a>.</p>
7676
<p>The web server can be accessed either through a terminal (address <strong>http://ip:port</strong>) using wget or curl, or through a web browser (address <strong>http://ip:port/html</strong>).</p>
7777
<p>The ip and port will be set using the <strong>–headless</strong> command line option.</p>
7878
<p>The ip can either be:</p>

docs/headless.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Now, **PyRadio** is a **terminal application**; it actually **needs** a terminal
3737

3838
### Usage
3939

40-
After the program is started, the only way (well, not really, more on this below) to interact with it is through its integrated web server.
40+
After the program is started, the only way to interact with it is through its integrated web server. Please refref to the relevant document for more info on the [remote control server](server.md).
4141

4242
The web server can be accessed either through a terminal (address **http://ip:port**) using `wget` or `curl`, or through a web browser (address **http://ip:port/html**).
4343

docs/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,7 @@ <h2 id="update-notification">Update notification <span style="padding-left: 10px
18641864
<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>
18651865
<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>
18661866
<p>For more information, please refer to <a href="server.html">the relevant page</a>.</p>
1867+
<p>If you’d like to set up a “headless” <strong>PyRadio</strong> operation for your linux box, please refer to the <a href="headless.html">Headless</a> page.</p>
18671868
<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>
18681869
<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>
18691870
<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>

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,8 @@ If so, a notification message will be displayed, informing the user about it and
10801080

10811081
For more information, please refer to [the relevant page](server.md).
10821082

1083+
If you'd like to set up a "headless" **PyRadio** operation for your linux box, please refer to the [Headless](headless.md) page.
1084+
10831085
## Debug mode
10841086

10851087
Adding the "**-d**" option to the command line will instruct **PyRadio** to enter *Debug mode*, 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 *pyradio.log*.

docs/server.html

Lines changed: 96 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ <h2 id="table-of-contents">Table of Contents <span style="padding-left: 10px;"><
4545
<ul>
4646
<li><a href="#remote-control-server">Remote Control Server</a>
4747
<ul>
48-
<li><a href="#using-the-web-server">Using the Web Server</a></li>
48+
<li><a href="#using-the-web-server">Using the Web Server</a>
49+
<ul>
50+
<li><a href="#web-interface-buttons">Web Interface buttons</a></li>
51+
</ul></li>
4952
<li><a href="#using-the-text-server">Using the Text Server</a></li>
5053
<li><a href="#examples">Examples</a></li>
5154
<li><a href="#text-vs.-web-commands">Text vs. Web commands</a></li>
@@ -81,40 +84,86 @@ <h3 id="using-the-web-server">Using the Web Server</h3>
8184
<p>The idea is that while <strong>PyRadio</strong> is running on the PC, people relaxing on the sofa, chilling with friends, listening to music from their favorite radio station, being able to increase / decrease the volume, change stations, etc. using their phones.</p>
8285
<p>The available commands are “encoded” in the buttons shown on the screen; the right part of the image shows the output of the “<strong>Stations List</strong>” button. To start a station, I would just click (well, tap) on its name, and viola!</p>
8386
<p>The <strong>Web</strong> interface will also show the song’s title, if availabe, or the name of the station that’s playing, if it’s not. In order to achieve this functionality, <em>javascript</em> is heavily used, so one should keep that in mind (in case <em>javascript</em> has been disabled in the browser, for example).</p>
84-
<h3 id="using-the-text-server">Using the Text Server</h3>
87+
<h4 id="web-interface-buttons">Web Interface buttons</h4>
88+
<p>The buttons shown in the web interface are:</p>
89+
<ul>
90+
<li><p><strong>Local Playlist</strong><br />
91+
This button will permit the user to toggle between opening a local playlist (default state) and a <strong>Radio Browser</strong> “playlist”, actually a search result set of players.</p></li>
92+
<li><p><strong>Play Next</strong> and <strong>Play Previous</strong><br />
93+
The buttons title says it all…<br />
94+
Subsequent clicks on a button will only be accepted after the player has “settled”, i.e. either started playing or failed to connect to the station.</p></li>
95+
<li><p><strong>Play Hist. Next</strong> and <strong>Play Hist. Previous</strong><br />
96+
Same as above, but stations will come from the “<strong>station history</strong>” instead of the current playlist.</p></li>
97+
<li><p><strong>Toggle Playback</strong><br />
98+
Nothing more to say here; start/stop the player.</p></li>
99+
<li><p><strong>Volume Up</strong> and <strong>Volume Down</strong>, <strong>Save Volume</strong>, <strong>Mute Player</strong><br />
100+
These are the volume adjustment, saving and muting the player functions.</p></li>
101+
<li><p><strong>Show Stations</strong><br />
102+
Clicking this buttons will present the list of stations in the current playlist (or search result). Clicking on a station name will start its playback.</p></li>
103+
<li><p><strong>Show Groups</strong><br />
104+
This will display, and permit the selection of the groups defined within a playlist. When a group name is selected, the list of players will be opened and scrolled to the beginning of the group.</p></li>
105+
<li><p><strong>Show Playlists</strong><br />
106+
This will show a list of the playlists already composed by the user. Clicking on a playlist’s name will open the playlist; the stations will be available through the <strong>Show Stations</strong>.<br />
107+
<br />
108+
When <strong>Radio Broeser</strong> is active, the button’s label will change to <strong>Show Searches</strong>. When clicked, the list of existing search items will be presented to the user; clicking on an item will preform the search and results can be displayed by clicking on the <strong>Show Stations</strong> button.<br />
109+
<br />
110+
No new items can be inserted using the web interface.</p></li>
111+
<li><p><strong>Enable Title Log</strong><br />
112+
This will enable or disable the titles logging function.</p></li>
113+
<li><p><strong>Like Title</strong><br />
114+
This will “like” the current (song).</p></li>
115+
<li><p><strong>System Info</strong><br />
116+
This will display useful info about <strong>PyRadio</strong>. ### Using the Text Server</p></li>
117+
</ul>
85118
<p>Why having the <strong>Text</strong> interface as well, one might ask…</p>
86119
<p>Well, first of all it’s lighter, then one can use it to locally control <strong>PyRadio</strong> from a script and provide a way to adjust the volume for example, using some assigned shortcut key combination.</p>
87120
<p>Inserting the <strong>Text</strong> address on a terminal using <em>curl</em> or <em>wget</em> or any similar software:</p>
88121
<pre>$ curl http://192.168.122.4:9998</pre>
89122
<p>or</p>
90123
<pre>$ wget http://192.168.122.4:9998 -q -O -</pre>
91124
<p>would result to displaying the list of available commands:</p>
92-
<pre>PyRadio Remote Service
125+
<pre>
126+
% Total % Received % Xferd Average Speed Time Time Time Current
127+
Dload Upload Total Spent Left Speed
128+
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 1810 100 1810 0 0 392k 0 --:--:-- --:--:-- --:--:-- 441k
129+
130+
% Total % Received % Xferd Average Speed Time Time Time Current
131+
Dload Upload Total Spent Left Speed
132+
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 1935 100 1935 0 0 1702k 0 --:--:-- --:--:-- --:--:-- 1889k
133+
PyRadio Remote Service
93134

94135
Global Commands
95-
Long Short Description
96-
--------------------------------------------------------------------
97-
/info /i display PyRadio info
98-
/volumeup /vu increase volume
99-
/volumedown /vd decrease volume
100-
/vulumesave /vs save volume
101-
/mute /m toggle mute
102-
/log /g toggle stations logging
103-
/like /l tag (like) station
136+
Long Short Description
137+
-------------------------------------------------------------------------------
138+
/info /i display PyRadio info
139+
/volume /v show volume (text only)
140+
/set_volume/x /sv/x set volume to x% (text only)
141+
/volumeup /vu increase volume
142+
/volumedown /vd decrease volume
143+
/volumesave /vs save volume
144+
/mute /m toggle mute
145+
/log /g toggle stations logging
146+
/like /l tag (like) station
147+
/title get title (HTML format)
104148

105149
Restricted Commands (Main mode only)
106-
--------------------------------------------------------------------
107-
/toggle /t toggle playback
108-
/playlists /pl get playlists list
109-
/playlists/x /pl/x get stations list from playlist id x
110-
(x comes from command /pl)
111-
/playlists/x,y /pl/x,y play station id y from playlist id x
112-
/stations /st get stations list from current playlist
113-
/stations/x /st/x play station id x from current playlist
114-
/next /n play next station
115-
/previous /p play previous station
116-
/histnext /hn play next station from history
117-
/histprev /hp play previous station from history</pre>
150+
---------------------------------------------------------------------------
151+
/toggle /t toggle playback
152+
/playlists /pl get playlists list
153+
/playlists/x /pl/x get stations list from playlist id x
154+
(x comes from command /pl)
155+
/playlists/x,y /pl/x,y play station id y from playlist id x
156+
/stations /st get stations list from current playlist
157+
/stations/x /st/x play station id x from current playlist
158+
/next /n play next station
159+
/previous /p play previous station
160+
/histnext /hn play next station from history
161+
/histprev /hp play previous station from history
162+
/open_radio_browser /orb open Radio Browser
163+
/close_radio_browser /crb close Radio Browser
164+
/list_radio_browser /lrb list Radio Browser search items
165+
/search_radio_browser/x /srb/x execute search item x
166+
(x comes from /lrb)</pre>
118167
<p>The “<strong>Restricted Commands</strong>” will not work in <strong>Playlist mode</strong>; the “<strong>Global Commands</strong>” will work everywhere.</p>
119168
<h3 id="examples">Examples</h3>
120169
<p>The following commands will increase / decrease the volume and mute the player:</p>
@@ -139,6 +188,29 @@ <h3 id="examples">Examples</h3>
139188
[&gt; ]: Selected, [+ ]: Playing, [+&gt;]: Both</pre>
140189
<p>so that in order to start playing station No 20, for example, one would just use the command:</p>
141190
<pre>$ curl http://192.168.122.4:9998/st/20</pre>
191+
<p>The following command will get the current song title:</p>
192+
<pre>$ curl http://192.168.122.4:9998/title
193+
194+
retry: 150
195+
event: /html/title
196+
data: &lt;b&gt;The Carpenters - No Place Like Home For The Holidays&lt;/b&gt;
197+
</pre>
198+
<p>The <strong>data</strong> field will contain the HTML format of the title, which is easy to parse in a script.</p>
199+
<p>If the player is idle, the output will be</p>
200+
<pre>$ curl http://127.0.0.1:9998/title
201+
retry: 150
202+
event: /html/title
203+
data: &lt;b&gt;Player is stopped!&lt;/b&gt;</pre>
204+
<p>Several commands (such as <strong>/v</strong>, <strong>/vu</strong>, <strong>/vd</strong>, etc.) will return this info; this is a side effect of the way the server works, but provides useful info for the script issuing the command.</p>
205+
<p>One thing that should be made clear is that getting the above info does not mean that the command has succeeded; for example issuing the <strong>/orc</strong> (<strong>/open-radio-browser</strong>) command, will return the above info, but to make sure about the state of <strong>PyRadio</strong>, one should issue the <strong>/i</strong> (<strong>/info</strong>) command:</p>
206+
<pre>$ curl http://127.0.0.1:9998/i
207+
208+
PyRadio 0.9.2.20
209+
Player: mpv
210+
Service: RadioBrowser (Austria)
211+
Status: In playback
212+
Station (id=5): &quot;Classical Christmas FM&quot;
213+
Selection (id=5): &quot;Classical Christmas FM&quot;</pre>
142214
<h3 id="text-vs.-web-commands">Text vs. Web commands</h3>
143215
<p>On first glance, the difference between a <strong>Text</strong> and a <strong>Web</strong> command is the <em>/html</em> part that exists in the later.</p>
144216
<p>But things are actually more complex that that.</p>

0 commit comments

Comments
 (0)