-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathpyradio_server.1
366 lines (276 loc) · 13 KB
/
pyradio_server.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
.\" Copyright (C) 2018-2025 Spiros Georgaras <[email protected]>
.\" This manual is freely distributable under the terms of the GPL.
.\"
.TH pyradio_server 1 "June 2024" pyradio
.SH Name
.PP
pyradio \- a curses Internet radio player.
.SH \fBPyRadio\ Remote\ Control\ Server
\fBpyradio\fR can be controlled remotely using normal http requests either form the command line (with \fIcurl\fR for example) or from a browser.
For this purpose, a simple web server has been integrated in \fBpyradio\fR; this server can be started
.IP -\ \fBautomatically
Setting the \fBRemote Control Server\fR options ins the config file, especially setting the \fBAuto-start Server\fR to \fITrue\fR, or
.IP -\ \fBmanually
by pressing "\fI\\s\fR" at the main window, selecting the desired options and pressing "\fIs\fR".
.P
The options one can set are:
.IP 1.\ \fBServer\ IP
This can either be \fIlocalhost\fR (the server will be accessible from the current system only) or \fILAN\fR (the server will be accessible from any PC on the local network).
If the machine has more that one interface (network card), the actual \fIIPs\fR will be available for selection.
.IP 2.\ \fBServer\ Port
This is the port the server is listening to. Any free port number between 1025 and 65535 can be set here (default value is 9998).
.IP 3.\ \fBAuto-start\ Server
This option is available in the config only. If set to \fITrue\fR, the server will be automatically started when \fBpyradio\fR starts.
.P
After the server is up, pressing "\fI\\s\fR" will display a window which
will present both the server's \fBText\fR and \fBWeb\fR address.
.SH Using the Web Server
Inserting the \fBWeb\fR address displayed in the previous window in a web browser will result to loading the \fIRemote Control Web Interface\fR, shown in the following image (which is actually a screenshot of my mobile phone):
\fIhttps://members.hellug.gr/sng/pyradio/phone.jpg\fR
The interface consists of a header, a \fBtitle field\fR, and the \fBcommands buttons\fR.
The idea is that while \fBpyradio\fR 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.
The available commands are "encoded" in the buttons shown on the screen; the right part of the image shows the output of the "\fIStations List\fR" button. To start a station, I would just click (well, tap) on its name, and viola!
The \fBWeb\fR interface will show the song's title in the \fBtitle field\fR, if availabe, or the name of the station that's playing, if it's not.
In order to achieve this functionality, \fIjavascript\fR is heavily used, so one should keep that in mind (in case \fIjavascript\fR has been disabled in the browser, for example).
\fBWeb Interface buttons
\fRThe buttons shown in the web interface are:
.IP \fILocal\ Playlist
This button will permit the user to toggle between opening a local playlist (default state) and a \fBRadioBrowser\fR “playlist”, actually a search result set of players.
.IP \fIPlay\ Next\fR\ and\ \fIPlay\ Previous
The buttons title says it all…
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.
.IP \fIPlay\ Hist.\ Next\fR\ and\ \fIPlay\ Hist.\ Previous
Same as above, but stations will come from the “station history” instead of the current playlist.
.IP \fIToggle\ Playback
Nothing more to say here; start/stop the player.
.IP \fIVolume\ Up\ \fRand\ \fIVolume\ Down\fR,\ \fISave\ Volume\fR,\ \fIMute\ Player
These are the volume adjustment, saving and muting the player functions.
.IP \fIRecording\fR
Toggle recording button. Its caption indicates whether recording is enabled or disabled. Its background color indicates whether a file is currently being recorded (a station is being recorded), in which case the button's background color is \fIgreen\fR. If the color is \fBred\fR, no file is being recorded.
.IP \fIShow\ Stations
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.
.IP \fIShow\ Groups
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.
.IP \fIShow\ Playlists
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 Show Stations.
When \fBRadioBrowser \fRis active, the button’s label will change to \fIShow Searches\fR. 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 \fIShow Stations\fR button.
No new items can be inserted using the web interface.
.IP \fIEnable\ Title\ Log
This will enable or disable the titles logging function.
.IP \fILike\ Title
This will “like” the current (song).
.IP \fISystem\ Info
This will display useful info about \fBpyradio\fB.
.PP
\fBNavigating through RadioBrowser results\bR
.RS 4
.PP
All \f[B]PyRadio\f[R] queries to \f[B]RadioBrowser\f[R] will use a
return limit parameter (default is 200 stations).
.PP
This means that the user is presented at most the first 200 stations (or
whatever limit value he has set), but the actual result set may comprise
hundreds of stations.
.PP
\f[B]PyRadio\f[R] will permit the user to navigate through them by
displaying the \[lq]\f[I]navigation buttons\f[R]\[rq] when the
stations\[cq] list is requested, provided that there is a possibility
for a subsequent page exist - \f[B]PyRadio\f[R] has no way of knowing
that beforehand.
.PP
An example can be seen in the following image.
.PP
\fIhttps://members.hellug.gr/sng/pyradio/radiobrowser-pages.jpg\fR
.PP
In this example, the user has already displayed the fourth
\[lq]\f[B]page\f[R]\[rq] of results; the buttons displayed are:
\fBFirst Page\fR
.RS 4
Display the first page of results.
This button is displayed only when the third (and consequent) page is
displayed.
.RE
\fBPrevious Page\fR
.RS 4
Display the previous page of results.
This button is displayed only when the second (and consequent) page is
displayed.
.RE
\fBNext Page\fR
.RS 4
Display the next page of results.
This button is visible only if the number of results in the current page
is equal to the limit value set for the query.
This way the user knows he has displayed the last page of results.
Chances are the last page of results contain \[lq]\f[I]limit\f[R]\[rq]
stations; in this case, clicking the button will produce no change (the
existing page will be redisplayed).
This is an indication that the last page of results has been reached.
.RE
.RE
.SH Using the Text Server
Why having the \fBText\fR interface as well, one might ask...
Well, first of all it's lighter, then one can use it to locally control \fBpyradio\fR from a script and provide a way to adjust the volume for example, using some assigned shortcut key combination.
Inserting the \fBText\fR address on a terminal using \fIcurl\fR or \fIwget\fR or any similar software:
.RS 5
\fI$ curl http://192.168.122.4:9998\fR
.RE
or
.RS 5
\fI$ wget http://192.168.122.4:9998 -q -O -\fR
.RE
would result to displaying the list of available commands:
\fIPyRadio Remote Service
.br
.br
\fIGlobal Commands
.br
\fILong Short Description
.br
\fI______________________________________________________________________________
.br
\fB/info /i \fIdisplay PyRadio info
.br
\fB/volume /v \fIshow volume (text only)
.br
\fB/set_volume/\fIx\fB /sv/\fIx \fIset volume to x% (text only)
.br
\fB/volumeup /vu \fIincrease volume
.br
\fB/volumedown /vd \fIdecrease volume
.br
\fB/vulumesave /vs \fIsave volume
.br
\fB/mute /m \fItoggle mute
.br
\fB/log /g \fItoggle stations logging
.br
\fB/like /l \fItag (like) station
.br
\fB/title \fIget title (HTML format)
.br
\fB
.br
\fIRestricted Commands (Main mode only)
.br
\fI______________________________________________________________________________
.br
\fB/toggle /t \fItoggle playback
.br
\fB/playlists /pl \fIget playlists list
.br
\fB/playlists/\fIx\fB /pl/\fIx \fIget stations list from playlist id x
.br
\fB \fI(x comes from command \fB/pl\fI)
.br
\fB/playlists/\fIx\fR,\fIy\fB /pl/\fIx\fR,\fIy \fIplay station id y from playlist id x
.br
\fB/stations /st \fIget stations list from current playlist
.br
\fB/stations/\fIx\fB /st/\fIx \fIplay station id x from current playlist
.br
\fB/next /n \fIplay next station
.br
\fB/previous /p \fIplay previous station
.br
\fB/histnext /hn \fIplay next station from history
.br
\fB/histprev /hp \fIplay previous station from history
.br
\fB/open_radio_browser /orb \fIopen RadioBrowser
.br
\fB/close_radio_browser /crb \fIclose RadioBrowser
.br
\fB/list_radio_browser /lrb \fIlist RadioBrowser search items
.br
\fB/search_radio_browser/\fIx\fB /srb/\fIx \fIexecute search item x
.br
\fI(x comes from \fB/lrb\fI)
\fR
The \fBRestricted Commands\fR will not work in \fIPlaylist mode\fR; the \fBGlobal Commands\fR will work everywhere.
\fBExamples\fR
.RS
The following commands will increase / decrease the volume and mute the player:
\fI$ curl http://192.168.122.4:9998\fB/vu\fR
.br
\fI$ wget http://192.168.122.4:9998\fB/vd\fR -q -O -
.br
\fI$ wget http://192.168.122.4:9998\fB/m\fR -q -O -\fR
The following command will display the contents of the loaded playlist:
\fI$ curl http://192.168.122.4:9998\fB/st\fR
The stations will be numbered, like so:
\fIStations List for Playlist: "\fBstations\fR"
.br
\fB 1\fI. Alternative (BAGeL Radio - SomaFM)
.br
\fB 2\fI. Alternative (The Alternative Project)
.br
\fI ...
.br
\fB 17\fI. Jazz (Sonic Universe - SomaFM)
.br
\fI+\fB 18\fI. Lounge (Illinois Street Lounge - SomaFM)
.br
\fB 19\fI. Pop (PopTron! - SomaFM)
.br
\fB 20\fI. Pop/Rock/Urban (Frequence 3 - Paris)
.br
\fI ...
.br
\fI> \fB33\fI. Echoes of Bluemars - Cryosleep
.br
\fB 34\fI. Echoes of Bluemars - Voices from Within
.br
\fIFirst column
.br
\fI [> ]: Selected, [+ ]: Playing, [+>]: Both
\fR
so that in order to start playing station No \fB20\fR, for example, one would just use the command:
\fI$ curl http://192.168.122.4:9998\fB/st/20\fR
The following command will get the current song title:
\fI$ curl http://192.168.122.4:9998\fB/title\fI
.br
retry: 150
.br
event: /html/title
.br
data: <b>Patti Page - Jingle bells</b>
.br
\fRThe \fBdata\fR field will contain the HTML format of the title, which is easy to parse in a script.
If the player is idle, the output will be
\fI$ curl http://192.168.122.4:9998\fB/title\fI
.br
retry: 150
.br
event: /html/title
.br
data: <b>Player is stopped!</b>\fR
Several commands (such as \fB/v\fR, \fB/vu\fR, \fB/vd\fR, 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.
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 \fB/orc\fR (\fB/open-radio-browser\fR) command, will return the above info, but to make sure about the state of \fBpyradio\fR, one should issue the \fB/i\fR (\fB/info\fR) command:
\fI$ curl http://192.168.122.4:9998\fB/i\fI
.br
PyRadio 0.9.2.20
.br
Player: mpv
.br
Service: RadioBrowser (Netherlands)
.br
Search: Name: christmas, Order: votes, Reverse: true
.br
Status: In playback
.br
Station (id=5): "Classical Christmas FM"
.br
Title: Patti Page - Jingle bells
.br
Selection (id=5): "Classical Christmas FM"\fB
.SH Text vs. Web commands
On first glance, the difference between a \fBText\fR and a \fBWeb\fR command is the \fI/html\fR part that exists in the later.
But things are actually more complex that that.
For example, when the \fI/st\fR command is issued, the server will return the list of stations as text and keep listening for connections. In this case, one request has been made to the server and one response has been returned.
Now, if the \fI/html/st\fR command was issued, the server will return the same list, but formatted as html, so that a browser can correctly display it.
This output would pretty much be unusable to a user issuing the "\fIhtml\fR" command on a terminal.
Furthermore, using it from a browser, clicking or tapping the corresponding button, will lead to a number of requests from the browser to the server (requesting the mute status, the player's status, the song's title, etc.).
.SH See also
pyradio-client(1)
pyradio(1)