![]() |
![]()
| ![]() |
![]()
Namepyradio - a curses Internet radio player. PyRadio Remote Control Serverpyradio can be controlled remotely using normal http requests either form the command line (with curl for example) or from a browser. For this purpose, a simple web server has been integrated in pyradio; this server can be started
The options one can set are:
After the server is up, pressing "\s" will display a window which will present both the server's Text and Web address. Using the Web ServerInserting the Web address displayed in the previous window in a web browser will result to loading the Remote Control Web Interface, shown in the following image (which is actually a screenshot of my mobile phone): https://members.hellug.gr/sng/pyradio/phone.jpg The interface consists of a header, a title field, and the commands buttons. The idea is that while pyradio 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 "Stations List" button. To start a station, I would just click (well, tap) on its name, and viola! The Web interface will show the song's title in the title field, if availabe, or the name of the station that's playing, if it's not. In order to achieve this functionality, javascript is heavily used, so one should keep that in mind (in case javascript has been disabled in the browser, for example). Web Interface buttons The buttons shown in the web interface are:
Navigating through RadioBrowser results All PyRadio queries to RadioBrowser will use a return limit parameter (default is 200 stations). 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. PyRadio will permit the user to navigate through them by displaying the “navigation buttons” when the stations’ list is requested, provided that there is a possibility for a subsequent page exist - PyRadio has no way of knowing that beforehand. An example can be seen in the following image. https://members.hellug.gr/sng/pyradio/radiobrowser-pages.jpg In this example, the user has already displayed the fourth “page” of results; the buttons displayed are: First Page Display the first page of results.
This button is displayed only when the third (and consequent) page is displayed. Previous Page Display the previous page of results.
This button is displayed only when the second (and consequent) page is displayed. Next Page 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 “limit” 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. Using the Text ServerWhy having the Text interface as well, one might ask... Well, first of all it's lighter, then one can use it to locally control pyradio from a script and provide a way to adjust the volume for example, using some assigned shortcut key combination. Inserting the Text address on a terminal using curl or wget or any similar software: $ curl http://192.168.122.4:9998
or $ wget http://192.168.122.4:9998 -q -O -
would result to displaying the list of available commands: PyRadio Remote Service
The Restricted Commands will not work in Playlist mode; the Global Commands will work everywhere. Examples The following commands will increase / decrease the volume and mute the player: $ curl http://192.168.122.4:9998/vu
The following command will display the contents of the loaded playlist: $ curl http://192.168.122.4:9998/st The stations will be numbered, like so: Stations List for Playlist: "stations"
so that in order to start playing station No 20, for example, one would just use the command: $ curl http://192.168.122.4:9998/st/20 The following command will get the current song title: $ curl http://192.168.122.4:9998/title
The data 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 $ curl http://192.168.122.4:9998/title
Several commands (such as /v, /vu, /vd, 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 /orc (/open-radio-browser) command, will return the above info, but to make sure about the state of pyradio, one should issue the /i (/info) command: $ curl http://192.168.122.4:9998/i
Text vs. Web commandsOn first glance, the difference between a Text and a Web command is the /html part that exists in the later. But things are actually more complex that that. For example, when the /st 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 /html/st 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 "html" 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.). See alsopyradio-client(1)
|