pyradio(1)

Name

pyradio - a curses Internet radio player.

Synopsis

pyradio [OPTIONS]

Description

pyradio is a command line Internet Radio Player based on curses, that uses external media players to perform the actual playback.

It currently supports the following players: MPV, MPlayer and VLC.

Options

General options: Use specified configuration directory instead of the default one. PyRadio will try to create it, if it does not exist. Not available on Windows. Start and play. The value is num station or empty for random. Play station in external player. Can be combined with --play. Use specified player. A comma-separated list can be used to specify detection order. Supported players: mpv, mplayer, vlc. List of available stations in a playlist. Log titles to file. Print all the directories used by PyRadio and exit. Print config directory [CONFIG DIR] location and exit. Open config directory [CONFIG DIR] with default file manager. Print PyRadio sonfig. Start PyRadio in debug mode. When -d is used, this option will not log player input (value = 0), log accepted input (value = 1) or raw input (value = 2). Remove sessions' lock file. Update "stations.csv" (if needed). Update PyRadio. Uninstall PyRadio. Display version information.

Isolated environment: Install "dbus-next" in the isolated environment and ensure it remains available after updates. This is required for MPRIS support.

Playlist selection: List of available playlists in config dir. Load the specified playlist instead of the default one. PLAYLIST can be the path to a CSV or an M3U file, the name (without extension) of a CSV or an M3U file which is in the station's folder, or the number which corresponds to a file presented at the output of the -ls command line parameter. If PLAYLIST is an M3U file, it will be converted to a CSV file and this file will be loaded instead. Toggle autoload last opened playlist.

Themes: Use specified theme. Show Internal and System Themes names. Disable themes (use default theme). Write an Internal or System Theme to themes directory.

Terminal selection: Use this terminal for Desktop file instead of the auto-detected one. Use "none" to reset to the default terminal or "auto" to reset to the auto-detected one. Use this as PyRadio parameter in the Desktop File. Please make sure that the argument is at the end of the command line, for example: --terminal-param "-p 3 -t light".

Cache: Open the Cache folder. Show Cache contents. Clear Cache contents. Download source code, keep it in the cache and exit.

Recording stations: Turn recording on (not available for VLC player on Windows). Open the Recordings folder. List recorded files. Specify a previously recorded MKV file to be used with one of the following options. The MKV_FILE can either be an absolute or a relative path, or a number provided by the -lr command line paremater. If it is a relative path, it should be found in the current or in the Recordings directory. Add or change the cover image of a previously recorded MKV file. PNG_FILE can either be an absolute or a relative path. If relative, it should be found in the current or in the Recordings directory. Export a previously recorded MKV file chapters to an SRT file. The file produced will have the name of the input file with the "mkv" extension replaced by "srt". Add (or replace) chapter markers to a previously recorded MKV file. The chapters file will be a SRT file, much like the one produced by the previous command line parameter.

Headless operation: Start in headless mode. IP_AND_IPORT can be a) auto (use localhost:11111), b) localhost:XXXXX (access the web server through localhost), c) lan:XXXXX (access the web server through the LAN) or d) IP_ADDRESS:XXXX (the IP_ADDRESS must be already assigned to one of the network interfaces). XXXXX can be any port number above 1025. Please make sure it is different than the one set in the configuration file. Show remote control server address. Use this if your headless server has terminated unexpectedly, and you cannot start a new one (you get a message that it is already running).

The following options can also be set in pyradio’s configuration file:

    -s  parameter default_playlist (default value: stations)

    -p  parameter default_station (default value: -1)

    -u  parameter player (default value: mpv, mplayer, vlc)

Controls

Up/Down/PgUp/PgDown
    Change station selection

j/k Change station selection (vi-like)

Enter/Right/l
    Play selected station

r   Select and play a random station

Space/Left/h
    Stop/start playing selected station

P   Jump to playing station

H M L
    Jump to top / middle / bottom of screen

g   Jump to the start of the playlist

<n>G
    Jump to the end of the playlist
    If <n> (line number) was entered, jump to it

-/+ or ,/.
    Change volume

m   Mute

v   Save volume (MPV and MPlayer only)

o s R
    Open / Save / Reload playlist

a A Add / append a new station

e   Edit current station

E   Change current station's encoding

DEL,x
    Delete selected station

O   Open RadioBrowser

< / >
    Browse the Stations history list

J   Create a Jump tag

<n>^U,<n>^D
    Move current station up / down
    If <n> (line number) was entered, or a Jump tag has been defined, move the station there

t   Open the Theme Selection window

T   Toggle background transparency

c   Open the Configuration window

' \\ y
    Get into Registers, Extra Commands, Yank mode, respectively

z   Toggle "Force http connections"

Z   Display the "Extra Player Parameters" window.

?   Show keys help

Esc/q
    Quit

The same logic applies to all pyradio windows.

Note:
    When inserting numbers (either to jump to a station or to move a station), the number will be displayed at the right bottom corner of the window, suffixed by a "G", i.e. pressing 35 will display [35G].

Note:
    When tagging a station position for a move action (by pressing "J"), the position will be displayed at the right bottom corner of the window, suffixed by a "J", i.e. pressing "J" on position 35 will display [35J].

Global shortcuts
    Some of the functions provided by pyradio will always be available to the user. These functions are:

    +/- and ,/.
        adjust volume

    m   mute player

    v   save volume

    T   toggle transparency

    W   toggle title logging

    w   like a station

    ^N/^P [1] [2]
        play next / previous station

    </> [1]
        play next / previous station history entry
    Every window in pyradio will respect these shortcuts, even the ones with a “Press any key to…” message. When focus is on a Line editor, all shortcuts will work when preceded by a "\". Notes

        [1] Function not available when in Playlist and Registers mode. More info on pyradio's modes below.

        [2] Function not available in the RadioBrowser Search window.

PyRadio's Modes
pyradio has the following primary modes:

    1.  The Main mode, which is the one you get when you open the program, showing you a list of stations (a playlist), that you can play and edit; this is why it is also called the editing mode. All other modes derive from this one, and it's the mode you have to get to in order to terminate the program.

    2.  The Playlist mode, which you can open by pressing "o". Then you can open, create, paste a station, etc.

    3.  The Registers mode. This is identical to the "Playlist" mode, but instead of displaying playlists, it displays register. You can enter this mode by pressing "''" (two single quotes) and exit from it by pressing "Esc" or "q". You can also press "'" (single quote) to get to the "Playlist" mode and back.

    4.  The Register Main mode, which is identical to the "Main" mode, except it displays the content of a named register.

    5.  The Listening mode, which is intended to be used when you want pyradio to just play your favorite station and not take up too much space. It is ideal for tilling window manager use, as the whole TUI can be reduced all the way down to a single line (displaying the "Status Bar"). In this mode, adjusting, muting and saving the volume are the only actions available. To get pyradio back to normal operation one would just resize its window to a reasonable size (7 lines vertically, or more).
A set of secondary modes is also available (a secondary mode works within a primary one):

    1.  The Extra Commands mode, which gives you access to extra commands. You can enter this mode by pressing "\" (backslash). Then a backslash is displayed at the bottom right corner of the window.

    2.  The Yank (Copy) mode, which is used to copy stations to registers. You can enter this mode by pressing "y". Then a "y" is displayed at the bottom right corner of the window.

    3.  The Open Register mode, which is used to open a register or get into the Registers or Register Main mode. You can enter this mode by pressing "'" (single quote). Then a single quote is displayed at the bottom right corner of the window.

    4.  The Paste mode, which is available in the Station editor window only. It is designed to help the user paste a URL (and optionally a station's name). Why you might ask... Well, the Station editor normally treats the "?" and "\" characters as special characters (actually commands). So, if a URL which contains these characters (more frequently the "?" character) is pasted it will be corrupted unless the Paste mode is enabled.
The functions availabe through the secondary modes are content dependant, so you can see what command is available by pressing "?" while within such a mode. Pressing any other key will exit the secondary mode. Tiling manager modes
    These modes are specifically designed to be used with tiling window managers, trying to face a rapid reduction of window height or width (or both).

    1.  The Limited Height mode, which is automatically enabled when the window height gets below 8 lines. In this mode, only a limited information is visible and if playback is on, the volume is the only thing that can be adjusted (or muted) and saved. This is the Limited display.

    2.  The Limited Width mode, which is automatically enabled when the window width get below certain limits:

    a.  When the width gets below 40 columns, all windows will be closed and the main window will be the only visible one (either displaying stations, playlists or registers).

    b.  When the width gets below 20 columns, the Limited display will be activated.

Config File
pyradio upon its execution will first read its package configuration file and then will try to read the user configuration file. If an error occurs while parsing it, an error message will be displayed and pyradio will terminate. The package config file
    The package configuration file contains the program’s default parameters. These are the player to use, the playlist to load etc. It is heavily commented, so that it can be used as a template in order to manual create the user configuration file. One can also get the configuration file with the active parameter values (i.e. after changed by the user config file), by executing the command:
        pyradio -pc
The user config file
    This file (typically ~/.config/pyradio/config) is created by pyradio when needed. It will contain only the parameters whose value is different to the one set in the package configuration file. One can easily edit it manually, though. The best practice to do so is by executing pyradio with the -ocd command line option, which will open the configuration directory in your file manager, and then edit (or create it) it using your preferable text editor. Don’t forget you can get the list of parameters by executing pyradio -pc. The file can also be altered while pyradio is running by pressing “c”, which will open the “Configuration window”. This window presents all pyradio options and provide the way to change them and finally save them by pressing “s”. In any case, pyradio will save the file before exiting (or in case Ctrl-C is pressed) if needed (e.g. if a config parameter has been changed during its execution). If saving the configuration file fails, pyradio will create a back up file and terminate. When restarted, pyradio will try to restore previously used settings from the said back up file.

About Playlist Files

pyradio reads the stations to use from a CSV file, where each line contains two columns, the first being the station name and the second being the stream URL.

Optionally, a number of more columns can be used.

-   The third column will define the Encoding used by the station (more on this at Specifying stations' encoding).

-   The fourth column will set an Icon URL, to be used when displaying Desktop Notifications.

-   The fifth column is the Profile to be used with this station. If a profile is set for the station, a "[P]" will be displayed at the left top corner of the window when the station starts playing.

-   The sixth column will determine whether Buffering will be used (more on this at Buffering).

-   The seventh column will determine whether the station will be forced to be using http instead of https (more on this at Player connection protocol).

-   The eighth column defines the Volume value to be used (more on this at Station volume).

-   The ninth column will define the Referer to be used (more on this at Specifying a station's Referer URL).

-   The last column will define the Player to be used (more on this at Specifying a station's preferred station).

The following table presents the Station's fields and the current level of support.

Station field Takes Effect Customizable
in Playlist in Program
Name <0.9.3.11.5 <0.9.3.11.5
URL <0.9.3.11.5 <0.9.3.11.5
Encoding <0.9.3.11.5 <0.9.3.11.5
Icon <0.9.3.11.5 <0.9.3.11.5
Profile 0.9.3.11.10 0.9.3.11.10
Buffering 0.9.3.11.8 0.9.3.11.8
Force HTTP 0.9.3.11.6 0.9.3.11.10
Volume 0.9.3.11.10 0.9.3.11.5
Referer URL <0.9.3.11.5 0.9.3.11.10
Player 0.9.3.11.16 0.9.3.11.16

pyradio will by default load the user's stations file (e.g. ~/.config/pyradio/stations.csv). If this file is not found, it will be created and populated with a default set of stations.

Tip:
    If you already have a custom stations.csv file, but want to update it with pyradio's default one, you just rename it, run pyradio (so that the default one get created) and then merge the two files.

Note:
    Older versions used to use ~/.pyradio as default stations file. If this file is found, it will be copied to use's config directory (e.g. ~/.config/pyradio) and renamed to stations.csv or if this file exists, to pyradio.csv. In this case, this file will be the default one.

Defining and using Groups In order to better organize stations within a (large) playlist, pyradio supports Groups. A Group is defined as a normal "station" entry, whose URL field is a hyphen ("-"). For example, the following will define a Group Header for a Group called Blues.
    Blues,-
A Group Header entry does not define a station, and subsequently cannot stat a playback session. Other that that, it can be moved, copied, deleted, etc, just like any other playlist entry. To add a Group Header, just press "a", fill in the name and type a "-" in the URL field. Navigation among Groups can be achieved by:

    ^E / ^Y
        Go to next / previous Group.

    ^G  Display a list of existing Groups to select from.

Integrating new stations When the package's "stations.csv" files is updated, the changes it has will not automatically appear in the user's stations file. pyradio will display a message asking the user to either update the file, ignore the changes for this version or postpone his decision for the next time PyRadio will be executed. Either way, the user can always manually update his stations file, by issuing the following command:
    pyradio -us
If changes have been applied, a message resembling the following will appear:
    Reading config...
    Updating "stations.csv"
    Last updated version: 0.9.2
     Last synced version: None
      From version: 0.9.2
        +/- updating: "Reggae Dancehall (Ragga Kings)"
        +++ adding: "Groove Salad Classic (Early 2000s Ambient)"
        +++ adding: "n5MD Radio (Ambient and Experimental)"
        +++ adding: "Vaporwaves [SomaFM]"
        +++ adding: "The Trip: [SomaFM]"
        +++ adding: "Heavyweight Reggae"
        +++ adding: "Metal Detector"
        +++ adding: "Synphaera Radio (Space Music)"
    Summary
        +++ added : 7
        +/- updated : 1
        --- deleted : 0
If the file is already up to date, the following message will be displayed:
    Reading config...
    Updating "stations.csv"
    Last updated version: 0.9.2
     Last synced version: 0.9.2
    Already synced: "stations.csv"

Specifying a playlist to load (command line)

pyradio will normally load its default playlist file, as described above, upon its execution. A different file can be loaded when the -s command line option is used.

The -s option will accept:

* a relative or absolute file name. * the name of a playlist file which is already in its configuration directory. * the number of a playlist file, as provided by the -ls command line option.

Examples:

To load a playlist called "blues.csv", one would use the command:
    pyradio -s /path/to/blues.csv
If this file was saved inside pyradio's configuration directory, one could use the following command:
    pyradio -s blues
To use the playlist number, one would execute the commands:
    pyradio -ls
        Playlists found in "/home/user/.config/pyradio"
        ┏━━━━┳━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┓
        ┃ # ┃ Name ┃ Size ┃ Date ┃
        ┡━━━━╇━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━┩
        │ 1 │ hip-hop │ 6.41 KB │ Mon Nov 7 18:17:47 2022 │
        │ 2 │ party │ 1.94 KB │ Fri Nov 29 10:49:39 2021 │
        │ 3 │ stations │ 5.30 KB │ Sat Jul 18 23:32:04 2022 │
        │ 4 │ huge │ 1.94 MB │ Wed Oct 23 11:05:09 2019 │
        │ 5 │ blues │ 5.30 KB │ Thu Jul 16 16:30:51 2020 │
        │ 6 │ rock │ 2.56 KB │ Fri Jan 10 00:20:07 2023 │
        │ 7 │ pop │ 1.01 KB │ Fri Sep 18 00:06:51 2020 │
        └────┴──────────┴─────────┴──────────────────────────┘ pyradio -s 5

    Note
        Python 2 output is much simpler, but the functionality is the same.

    Note
        The default playlist to load can also be set in pyradio’s configuration file, parameter default_playlist (default value is stations).

Autoloading playlists As already stated, pyradio will normally load its default playlist (called "stations") upon startup. This behavior can be then changed in two ways:

    1.  Changing the default playlist. This is accomplished using the "Def. playlist" configuration option (optionally along with the "Def. station" option).

    2.  Always loading the last used playlist at startup. This is accomplished using the "Open last playlist" configuration option. In this case, the last used playlist will be opened the next time pyradio will be executed, trying to restore the previously selected station or starting playback. This option will take precedence before the "Def. playlist" configuration option (if it is used) and the "-s" ("--stations") command line option.

        Note:
            When the "Open last playlist" configuration option is set, all playlist operations will be performed to the last opened playlist. In order to use the "-a" ("--add") or "-l" ("--list") command line options along with the "-s" ("--stations") command line option, the "-tlp" "--toggle-load-last-playlist") option can be used to temporarily deactivate autoloading.

Managing Playlists (within PyRadio) Once pyradio has been loaded, one can perform a series of actions on the current playlist and set of playlists saved in its configuration directory. Currently, the following actions are available: Pressing "a" or "A" will enable you to add a new station (either below the currently selected station or at the end of the list), while "e" will edit the currently selected station. All of these actions will open the "Station editor". If you just want to change the encoding of the selected station, just press "E". If the station is currently playing, playback will be restarted so that the encoding's change takes effect (hopefully correctly displaying the station/song title). Then, when this is done, you can either save the modified playlist, by pressing "s", or reload the playlist from disk, by pressing "R". A modified playlist will automatically be saved when pyradio exits (or Ctrl-C is pressed). One thing you may also want to do is remove a station from a playlist, e.g. when found that it not longer works. You can do that by pressing "DEL" or "x". Finally, opening another playlist is also possible. Just press "o" and you will be presented with a list of saved playists to choose from. These playlists must be saved beforehand in pyradio's configuration directory. While executing any of the previous actions, you may get confirmation messages (when opening a playlist while the current one is modified but not saved, for example) or error messages (when an action fails). Just follow the on screen information, keeping in mind that a capital letter as an answer will save this answer in pyradio's configuration file for future reference.

Managing “Foreign” Playlists A playlist that does not reside within the program’s configuration directory is considered a "foreign" playlist. This playlist can only be opened by the -s command line option. When this happens, pyradio will offer you the choise to copy the playlist in its configuration directory, thus making it available for manipulation within the program. If a playlist of the same name already exists in the configuration directory, the "foreign" playlist will be time-stamped. For example, if a "foreign" playlist is named "stations.csv", it will be named "2019-01-11_13-35-47_stations.csv" (provided that the action was taked on March 11, 2019 at 13:35:47).

Playlist History pyradio will keep a history of all the playlists opened (within a given session), so that navigating between them is made easy. In order to go back to the previous playlist, the user just has to press "\\" (double backslash). To get to the first playlist "\]" (backslash - closing square bracket) can be used. Going forward in history is not supported.

Stations history
Playing several stations, sometimes among different playlists, and returning to them is sometimes a tedious operation. This problem is addressed with the Station history functionality, which is actually a list of stations which have been played back. The user can go back and forth in this list using the "<" and ">" keys. The list is not saved between sessions (restarting the program will lead to an empty list). When an online service is used (e.g. RadioBrowser) the list is reseted with every search that is performed.

Search Function
On any window presenting a list of items (stations, playlists, themes) a search function is available by pressing "/". The Search Window supports normal and extend editing and in session history. One can always get help by pressing the "?" key. After a search term has been successfully found (search is case insensitive), next occurrence can be obtained using the "n" key and previous occurrence can be obtained using the "N" key.

Line Editor
pyradio "Search function" and "Station editor" use a Line editor to permit typing and editing stations' data. The Line editor works both on Python 2 and Python 3, but does not provide the same functionality for both versions:

    *   In Python 2, only ASCII characters can be inserted.

    *   In Python 3, no such restriction exists. Furthermore, using CJK characters is also supported.

One can always display help by pressing "?", but that pauses a drawback; one cannot actually have a "?" withing the string. To do that, one would have to use the backslash key "\" and then press "?". To sum it all up:

    1. Press "?" to get help.

    2. Press "\?" to get a "?".

    3. Press "\\" to get a "\".

When in Station editor, the Line editor recognizes an extra mode: Paste mode. This mode is enabled by pressing "\p" and gets automatically disabled when the focus moves off the line editors. This mode is designed to directly accept the "?" and "\" characters (which are normally used as commands indicators). This makes it possible to easily paste a station's name and URL, especially when the "?" and "\" characters exist in them; it is very common to have them in URLs.

CJK Characters Support The Line editor supports the insertion of CJK Unified Ideographs [1], as described on CJK Unified Ideographs (Unicode block) [2], also known as URO, abbreviation of Unified Repertoire and Ordering. These characters, although encoded as a single code-poin (character), actually take up a 2-character space, when rendered on the terminal. A depiction of the editor's behavior can be seen at this image: https://members.hellug.gr/sng/pyradio/pyradio-editor.jpg [1] https://en.wikipedia.org/wiki/CJK_Unified_Ideographs [2] https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_(Unicode_block)

Moving Stations Around
Rearranging the order of the stations in the playlist is another feature pyradio offers. All you have to do is specify the source station (the station to be moved) and the position it will be moved to (target). There are three way to do that:

    1.  Press Ctrl-U or Ctrl-D to move the current station up or down.

    2.  Type a station number and press Ctrl-U or Ctrl-D to move the current station there.

    3.  Go to the position you want to move a station to, and press "J". This will tag this position (making it the target of the move). Then go to the station you want to move and press Ctrl-U or Ctrl-D to move it there.

Specifying Stations' Encoding
Normally, stations provide information about their status (including the title of the song playing, which pyradio displays) in Unicode (utf-8 encoded). Therefore, pyradio will use utf-8 to decode such data, by default. In an ideal world that would be the case for all stations and everything would be ok and as far as pyradio is concerned, songs' titles would be correctly displayed. Unfortunately, this is not the case. A lot of stations encode and transmit data in a different encoding (typically the encoding used at the region the come from). The result in pyradio would be that a song title would be incorrectly displayed, not displayed at all, or trying to displaying it might even break pyradio's layout.

Note
    vlc will not work in this case; it presumably tries to decode the said data beforehand, probably using utf-8 by default, and when it fails, it provides a "(null)" string, instead of the actual data. So, you'd better not use vlc if such stations are in your playlists.

pyradio addresses this issue by allowing the user to declare the encoding to use either in a station by station mode or globally.

Station By Station Encoding Declaration As previously stated, a pyradio's playlist can optionally contain a third column (in addition to the station name and station URL columns), which declares the station's encoding. So, when a non-utf-8 encoded station is inserted in a playlist, its encoding can also be declared along with its other data. The drawback of this feature is that an encoding must be declared for all stations (so that the CSV file structure remains valid). To put it simple, since one station comprises the third column, all stations must do so as well. This may seem intimidating (and difficult to achieve), but it's actually really simple; just add a "," character at the end of the line of each station that uses the default encoding. In this way, all stations comprise the third column (either by declaring an actual encoding or leaving it empty). Example: Suppose we have a playlist with one utf-8 encoded station:

Station1,Station1_URL

Now we want to add "Station2" which is iso-8859-7 (Greek) encoded. Since we know all stations must comprise the third (encoding) column, we add it to the existing station:

Station1,Station1_URL,

This way we add an empty encoding, forcing

Finally, we insert the new station to the playlist:

Station1,Station1_URL,
Station2,Station2_URL,iso-8859-7

Note
    Using the -a command line option will save you all this trouble, as it will automatically take care of creating a valid CSV file. Alternatively, you can change the selected station's encoding by pressing "E" while in pyradio.

Global Encoding Declaration pyradio's configuration file contains the parameter default_encoding, which by default is set to utf-8. Setting this parameter to a different encoding, will permit pyradio to successfully decode such stations. This would be useful in the case where most of your stations do not use utf-8. Instead of editing the playlist and add the encoding to each and every affected station, you just set it globally.

Finding The Right Encoding A valid encoding list can be found at: https://docs.python.org/2.7/library/codecs.html#standard-encodings replacing 2.7 with specific version: 3.0 up to current python version.

Player Detection / Selection

pyradio is basically built around the existence of a valid media player it can use. Thus, it will auto detect the existence of its supported players upon its execution.

Currently, it supports MPV, MPlayer and VLC, and it will look for them in that order. If none of them is found, the program will terminate with an error.

Users can alter this default behavior by using the -u command line option. This option will permit the user either to specify the player to use, or change the detection order.

Example:

pyradio -u vlc
    will instruct pyradio to use VLC; if it is not found, the program will terminate with an error.

pyradio -u vlc,mplayer,mpv
    will instruct pyradio 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.

Note
    The default player to use can also be set in pyradio’s configuration file, parameter player (default value is mpv, mplayer, vlc).

Specifying a station's preferred player
    Some stations may perform better —offering more stable playback, faster starts, or improved compatibility— when played with a specific audio player. pyradio allows you to define a preferred player for individual stations directly within the playlist file. When such a preference is set, pyradio will automatically activate the specified player and use it to start playback for that station. If the player in not installed, the default player will be used instead.

    Note
        A station with a defined player will always use that player, regardless of the session's default player or any player changes made during the session.

Changing player mid-session
    If the user faces a playback problem with a given station, chances are that a different player will successfully play it. Pressing "\m" will bring up the "Switch Media Player" window, where a different player can be activated.

    Note
        The activated player will not be saved; **PyRadio** will still use the player defined at its config next time it is executed.

Specifying a station's Referer URL
Although pyradio is meant to be a radio station player, it can also be used to listen to video stations transmitting m3u8 playlists (HTTP Live Streaming or HLS). The thing with these transmissions is that usually a Referer URL has to be provided so that the connection does not fail. pyradio now does support the declaration of a Referer URL for individual stations; it does it in an "anorthodox" way, but it is available and it works. So, let us imagine that a station called "My video station" has been added to a playlist. The user tries to play it but it fails; the referer URL is missing. To rectify the situation, a file containing the referer URL would have to be saved in the config directory: its name must be the name of the station as it is in the playlist, followed by the ".referer.txt" extension. In our example above, the file will have to be named:
    "My video station.referer.txt"
Note
    This will unfortunately not work with MPlayer. It seems it will not use the Referer provided, as shown in the following part of the command execution output: [tcp @ 0x7f4a42c7fa60]Successfully connected to XX.XX.XXX.XX port 443
    [https @ 0x7f4a42c7fa60]request: GET /live/XXXXXXXX.m3u8 HTTP/1.1
    User-Agent: Lavf/60.16.100
    Accept: */*
    Range: bytes=0-
    Connection: close
    Host: XXXXXX-XXXXXXXXX.XXXXXX.XXX.XXX.XX
    Icy-MetaData: 1 [https @ 0x7f4a42c7fa60]HTTP error 403 Forbidden
Referer support in the playlist As of v. 0.9.3.11.5, support for the referer in the playilist has been implemented. In this case, if a referer file is found for a station, pyradio will:

    1. update the station info in the playlist

    2. mark the playlist as modified

    3. remove the referer file

    4. inform the user so that he saves the playlist

Note
    At this point, inserting the referer from pyradio TUI has not yet been implemented. One can either use the referer file method described above, or just manually edit the playlist file and add it using the following format:
        Station Name,Station URL,,,,,,Referer URL

    Please note the number of commas inserted after the Station URL.

Extra Player Parameters
All three supported players can accept a significant number of "command line parameters", which are well documented and accessible through man pages (on linux and macOs) or the documentation (on Windows). pyradio uses some of these parameters in order to execute and communicate with the players. In particular, the following parameters are in use by default:

    Player
        Parameters

    mpv --no-video, --quiet, --input-ipc-server, --input-unix-socket, --playlist, --profile

    mplayer
        -vo, -quiet, -playlist, -profile

    vlc -Irc, -vv. On Windows only: --rc-host, --file-logging, --logmode, --log-verbose, --logfile

Note
    The user should not use or change the above player parameters. Failing to do so, may render the player unusable.

pyradio provides a way for the user to add extra parameters to the player, either by a command line parameter, or the "Configuration Window" (under "Player:"). This way, 10 sets of parameters can be inserted and made available for selection.

Using The Configuration Window When the user uses the configuration window (shown in the following image), he is presented with an interface which will permit him to select the player to use with pyradio and edit its extra parameters. [pyradio-player-selection.jpg](https://members.hellug.gr/sng/pyradio/pyradio-player-selection.jpg) Each of the supported players can have up to 11 sets of extra parameters (the first one is the default). The user can add ("a") a new parameter, edit ("e") an existing set and delete ("x" or "DEL") one.

Player Connection Protocol
Most radio stations use plain old http protocol to broadcast, but some of them use https. Experience has shown that playing a https radio station depends on the combination of the station's configuration and the player used. If such a station fails to play, one might as well try to use http protocol to connect to it. 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. When the selected player is initialized (at program startup), it reads this configuration parameter and acts accordingly. 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.

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. Furthermore, changing the configuration stored value, will not affect the "working" value of the parameter.

Visual reminder
    When this option is activated, either through the config or the keyboard, a "[http forced (z)]" message appears on the top right corner of the window, as can be seen in the following image. https://members.hellug.gr/sng/pyradio/http-force.jpg The "z" in parenthesis is just a hint to remind the user that he can change the behavior by pressing "z". As the window shrinks in width, the message becomes a "[h]"; when it shrinks even more, it disappears completely.

Player Default Volume Level

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

This introduces a problem to pyradio: 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.

The way to come around it, is to save the desired volume level in a way that it will be used by the player whenever it is restarted.

This is done by typing "v" right after setting a desired volume level.

MPV

MPV uses profiles to customize its behavior.

pyradio defines a profile called "[pyradio]" in MPV's configuration file (e.g. ~/.config/mpv/mpv.conf). This profile will be used every time playback is started.

Example:

volume=100 [pyradio]
volume=50

MPlayer

MPlayer uses profiles to customize its behavior as well.

pyradio defines a profile called "[pyradio]" in MPV's configuration file (e.g. ~/.mplayer/config). This profile will be used every time playback is started.

Example:

volume=100 [pyradio]
softvol=1
softvol-max=300
volstep=1
volume=50

Note:
    Starting with pyradio v. 0.8.9, mplayer's default profile will use its internal mixer to adjust its volume; this is accompliced using the "softvol=1" and "softvol-max=300" lines above. The user may choose to remove these lines from the config (to activate system-wide volume adjustment) or add them to the config (in case the profile was created by an older pyradio version).

VLC

Although VLC can use a local configuration file, there seems to be no reliable way of defining the playback volume in it. In the past, VLC would just use any volume setting it had saved from a previous execution, but now it is possible to save the volume it will use when executed by pyradio. This means that VLC will start and connect to a station, use whatever volume level it's stored for it and then pyradio will reset the volume to the desired one (as saved within pyradio). The volume will be saved is a file called vlc.conf and reside withing the data directory, inside pyradio's configuration folder.

Station volume
    Stations in a playlist can come from various sources, each with its own default volume level. This often results in inconsistent playback volume, forcing the user to adjust pyradio volume every time a new station starts. While using a volume normalization tool could solve this, it may not always be desirable or feasible. pyradio offers a better alternative: station volume. With this feature, each station can have a specific volume value saved along with its name and URL. When the station is played, that volume is automatically applied. Though the user needs to manually set and save the ideal volume for each station (based on their own audio setup), this provides a consistent and reliable solution over time. To set a station’s volume, start playing it, adjust the volume to the desired level, and press "\v". This will silently save the updated volume to the playlist on disk. If you want to temporarily ignore all station volume settings, press "\V". This will disable volume overrides for the current session only; the setting will reset the next time pyradio is launched. When a station’s volume setting is active, a "[V]" indicator appears in the top-left corner of the window. If station volume has been disabled, you’ll see "[v]" instead. This is illustrated in the image below: https://members.hellug.gr/sng/pyradio/station-volume.png How it Works
        Both MPV and MPlayer use profiles to configure playback options. When station volume is enabled, pyradio creates a temporary profile named pyradio-volume by copying the selected base profile. It then updates the volume field in this profile to match the station’s saved volume. This custom profile is then used to launch the player. Naturally, this means the player’s user configuration file must be read, parsed, modified, and saved — which may introduce a slight delay, particularly on slower systems. VLC, on the other hand, does not support profiles. In this case, pyradio simply applies the station’s volume directly, overriding the global volume setting.

Displaying Station Info
When a connection to a radio station has been established, the station starts sending audio data for the user to listen to. Well, that's obvious, right? Yes, but this is just half of the story. The station actually also sends identification data, audio format data, notifications, etc. Part of this non-audio data transmitted by a station is the title of the song currently playing; this is why we can have this data displayed at the bottom of the screen. Now, not all stations send the whole set of data; most send their name, website, genre and bitrate, for example, but some may ommit the website or the genre. pyradio can receive, decode and display this data, and even help the user to identify an unknown station. This is the way to do it: After a connection to a station has been established (after playback has started), just press "i" to display the station's info. The window that appears includes the "Playlist Name" (the station name we have in the playlist) and the "Reported Name" (the name the station transmitted to us) among other fields (an example can be seen here: https://members.hellug.gr/sng/pyradio/pyradio-station-info.jpg . If these two names are not identical, the user can press "r" to rename the station in the playlist using the "Reported Name". This way an unknown station (when only the URL is known) can be correctly identified (after being inserted in a playlist with a dummy station name).

Copying And Pasting - Registers
pyradio takes the concept of registers from ivim (https://www.vim.org), and adapts their function to its own needs. So this is how it all works. There are 36 named registers (name is a-z, 0-9) and one unnamed register.

Named registers
    are actually files that contain stations and can be opened and edited as regular playlist files. There are some differences in handling them: they are accessible either individually or using a special window, they are automatically saved, and writing errors are ignored. The later means that registers should not be regarded as normal playlist files that can be safely saved and used forever; this is true as long as there's no problem with writing to them; if a writing error occurs they may get overwritten or emptied. To permanently save a register, on would rename it to a normal playlist file.

The unnamed register
    holds just one station (the one that has been copied or added to a register or deleted from a playlist), and it is the one used when pasting to a register or a playlist. One can see its contents by pressing "\u".

To copy a station to a register one would press "y" and:

    *   one of "a-z", "0-9" to add it to the corresponding named register. The unnamed register is also populated.

    *   ENTER to add it to the unnamed register.
To open a named register, one would press "'" (single quote) and:

    *   one of "a-z", "0-9" to open the corresponding register.

    *   "'" (single quote) to open the "Registers window", so that a register can be selected.
To rename a named register, one would press "\r" either in the "Registers window" or while editing the register. To clear a named register, one would press "\c" either in the "Registers window" or while editing the register. To clear all registers, one would press "\C" either in the "Registers window" or while editing a playlist or a register. To paste the unnamed register to a playlist or register, one would press:

    *   "p" while editing a playlist or register.

    *   "\p" while editing a playlist or register. This would open the "Paste selection" window.

    *   "\p" in the "Playlist Selection or the "Registers" window.

Favorites playlist
Pressing "*" in Main Mode will add the selected station to the favorites playlist. If the station is already there, it will either be updated if its name has been changed, for example, or will be ignored, to avoid creating duplicate entries. The favorites playlist, residing in the configuration folder, is a normal playlist in any other respect, which can be subsequently opened, edited, deleted even, as any other playlist.

Displaying The Current Time
The Clock feature allows you to display the current time in the bottom left corner of the window. This can be helpful for keeping track of time while using the application. By default, the Clock is turned off, with the default format set to HH:MM (value 1). Enabling the clock will introduce a few additional threads, which may make pyradio slightly heavier than usual. You can easily toggle the clock display by pressing "\t".

Configuration
    The configuration window has a group labeled Clock, which presents the following options:

    Display on startup
        This option determines whether the clock is displayed when the application starts. Set it to True to show the clock at startup, or leave it as False (the default) to hide it.

    Time format
        You can choose how the time is displayed using the "Time format" option. Here are the available formats:
        Value Format Description
        0 24-hour format, with seconds
        1 24-hour format, no seconds (default)
        2 12-hour format, with AM/PM and seconds
        3 12-hour format, no AM/PM, with seconds
        4 12-hour format, with AM/PM, no seconds
        5 12-hour format, no AM/PM, no seconds

PyRadio Themes

pyradio comes with 6 preconfigured (hard coded) themes:

    dark (8 color theme)
        This is the appearance pyradio has always had. Enabled by default.

    light (8 color theme)
        A theme for light terminal background settings.

    dark_16_colors (16 color theme)
        dark theme alternative.

    light_16_colors (16 color theme)
        light theme alternative.

    white_on_black or wob (256 color b&w theme)
        A theme for dark terminal background settings.

    black_on_white or bow (256 color b&w theme)
        A theme for light terminal background settings.

Furthermore, a number of System Themes (these are actual files saved in the themes installation directory) are also available.

Contrary to the old styling method, which was terminal and palette dependent, a new styling method has been implemented; actual CSS colors can now be defined. Pressing "t" will bring up the Theme selection window, which can be used to activate a theme and set the default one.

Note
    If the theme selected in the Theme selection window, (or requested using the "-t" command line option), is in any way invalid, or is of the old format, pyradio will fall-back to the "dark" theme and will display a relevant message.

The window will display the current state of the Use transparency and Force transparency configuration options in its bottom right corner:

    A [T]
        means that the Use transparency option is enabled.

    A [F]
        means that the Force transparency option is enabled.

    A [TF]
        means that the both options are enabled.

Note
    the options indication will not be visible when the window is opened withing the pyradio’s “Configuration Window”.

One can get more info about these options in the “Using Transparency” section, bellow.

The Theme selection window will remain open after activating a theme, so that the user can inspect the visual result and easily change it, if desired. Then, when he is satisfied with the activated theme, the window will have to be manually closed (by pressing "q" or any other relevant key - pressing "?" will bring up its help).

Pressing "SPACE", will apply the theme and make it default, and pressing "c" will apply the theme and make it default and start a file watch function on the file, so that if the file changes, pyradio will automatically update itself.

Alternative Main Window border color
    It is also possible to change the Main Window border color. This is a feature that has been requested and implemented, but not used by default. To provide an alternative border color, one would just add the following to a theme file:
        # Border color for the Main Window
        # (background color will come from Stations)
        Border #69a9a7

    Note
        This color will be used only when the trerminal supports more than 16 colors. This is because pyradio already uses colors 0-15, and this border color will be declaread as color No 16.

Virtual terminal restrictions
    After introducing CSS color themes, it has come to my attention that pyradio will not display colors correctly when executed within specific terminals, konsole, yakuake, deepin-teminal, qterminal and terminology, just to name a few. Now, I do not know whether this is because of the terminals themselves, python curses implementation or whatever, but that’s that. pyradio will try to detect these terminals and disable themes (after displaying a relative message). Then the default theme will be used. Some of the terminals that work ok, are: gnome-terminal, mate-terminal, xfce4-terminal, lxterminal, terminator, termite, kitty, alacritty, sakura, roxterm, tilix, lilyterm, st, xst, rxvt, urxvt, uxterm, xterm. If you want to make pyradio start in one of these terminal, just follow the instructions given at Desktop File: Specifying the terminal to use.

CSS color themes restrictions
    Using CSS colors imposes a couple of restrictions on the type of terminals pyradio will be able to run:

        1.  The TERM variable must be set (Linux and MacOs only). pyradio will set it to "xterm-256color" if not set. Furthermore, if TERM is set to anything like "xterm*", "screen*" or "tmux*", pyradio will set it to "xterm-256color" as well.

        2.  Terminals that do not support at least 16 colors will not be able to display any of the new themes. The same goes for terminals that do not support changing their colors (through the curses library). These terminal will default to either the "dark" or the "light theme (determined by the configuration parameter console_theme), displaying whatever colors the active palette dictates.

        3.  There are a couple of terminals (that I know of) which will permit changing their colors but will not be able to present the changed color on the fly. This means that, in order for a theme change to take full effect, pyradio will have to be restarted.

Secondary windows background
    Secondary windows (such as messages, questions, the Theme Selection window the Encoding Selection window, etc.) originally use the same background color as the Main window. It is now possible to use a different background color for these windows, to get better visual result. There are two way to do that:

        1.  Defined in a theme

        2.  Using a calculated color

        Theme defined secondary windows color
            Themes have the following entry
                # Message window border foreground and background.
                # The background color can be left unset.
                # Please refer to the following link for more info
                # https://github.com/coderholic/pyradio#secondary-windows-background
                #
                Messages Border #a3b367
            It is possible to define a background color as well, like so
                Messages Border #a3b367 #F5DBDE
            In this case, this color will be used as the Secondary Windows background color. Although one can use any color here, it is recommended to follow these guidelines for best visual result:

                1.  The color should be 1-20% lighter or darker than the "*Stations Background*" color setting of the theme. One can use this page http://www.workwithcolor.com/hsl-color-picker-01.htm (or a similar one) to insert the base color and adjust the L component as needed. A terminal alternative is pastel (https://github.com/sharkdp/pastel), which can be used like so:
                    pastel color '#fbf1f2' # show color info
                    pastel lighten .1 '#fbf1f2' # color lightened by 10%
                    pastel darken .1 '#fbf1f2' # color darkened by 10%

                2.  If the Stations Background color is dark, create a lighter version of it; if it's light, create a darker version of it. This is just a recomenration, though; just get a color that combines well with existing ones (border foreground, stations foreground and active station). This information is actually relevant to creating a new pyradio theme, but it's very important in order to understand how the calculated background color works.
        Calculated secondary windows color
            pyradio will use the same background color for all windows by default, provided that the theme used does not define a Messages Border background color. In order to use a Messages Border background color different than the Stations background color, when Messages Border background color is not defined in the selected theme, a config option is available; "Calculated color". This config option takes a value that's between 0 and 0.2. If it is 0, no color change will occur. Otherwise, the value acts as a percentage (a factor), which indicates how much the luminance of the Stations background color will change to produce the new background color. This is how this works: pyradio will calculate the Stations background color perceived brightness, which will indicate whether the color is dark or light. Then depending on that, will add or subtract factor percent from its luminance value. Finally, a check will be made to see if this color is close to Messages Border foreground color, and re-adjusted as possible.
        Optional Calculated Color in a Theme
            Another way to use a different background color for secondary windows, is to provide one in the actual theme file. For example:
                # Luminance Color Factor
                # The factor to lighten or darken Stations background
                # color, to get a calculated color used as background
                # for secondary windows
                # Valid values: 0 - 0.2
                Color Factor 0.05
            In this case, the value provided (i.e. 0.05) will be used the same way as the config option "Calculated color". In fact, if both a theme and a config factor value is provided, the value provided by the theme will be used.

        Note
            If the "Messages Border" theme option provides both a foreground and a background, both the calculated values provided will be ignored.

        Note
            When a calculated background color is used, pressing ~ (tilde) will toggle it on and off. This setting will be valid until pyradio terminates, or a new theme is loaded.

    User themes
        Users can easiliy create their own themes, using for example CSS color names (https://www.cssportal.com/css3-color-names/) as a resource, and

            1.  Copy (and rename) one of the System Themes to the user's themes folder. This folder may not already exist; it must be created in pyradio config directory (~/.config/pyradio). To gain access to the System Themes, execute the following commands
                cd `python -c 'import site; print(site.getusersitepackages())'`
                cd pyradio/themes
                (you may have to use python2 or python3 instead of plain python, depending on your OS and distribution).

            2.  Customize it as desired

            3.  Load it from the Theme selection window (it will be found under "User Themes").

    Converting old themes
        An old theme (using the old format) can be asily converted to the new format, using the script found at this gist (https://gist.github.com/s-n-g/65aa6ae12e135481bf3a503ece4e92d2).

        Note:
            In order to get the color intended to be used, the same palette as the one used when the original theme was created, must be used.

    Using Transparency
        For pyradio, transparency means that a theme's background actually disappears, effectively making it to display whatever is on the terminal (color/picture/transparency). The visual result depends on terminal settings and whether a compositor is running. Not all themes look good when transparency is ON, so themes can now declare whether they want to use transparency or not. This is the "transparency" variable of the theme, which can have these values:

            0   means that the theme will be opaque (no transparency).

            1   means that the theme will be transparent.

            2   - 2 means that the theme looks good either way (the default), and the global transparency setting value (defined in pyradio config file) will be used.

        Please note that this behavior has changed since v. 0.9.2.7: theme transparency will always be honored, regardless of the global config value. This means that a theme which is set to be transparent (by its creator) will always be transparent, no matter if the global transparency is on or off. Similarly, if a theme is set to be opaque, it will be so regardless of the global transparency value. The only case when global transparency will come into play is when the theme does not care about it (theme transparency set to 2 - Obey config setting). Since v. 0.9.2.14, it is also possible to force the use of the Transparency setting; the “Force Transparency” configuration option. When enabled, it will effectively make all themes behave as if their transparency setting was set to 2 (Obey config setting).
    Updating themes automatically
        Terminal users have been using all kind of software to change / update / adapt their terminal colors and palettes, such as ibASE16 (https://github.com/chriskempson/base16), pywal (https://github.com/dylanaraps/pywal), wpgtk (https://github.com/deviantfero/wpgtk), theme.sh (https://github.com/lemnos/theme.sh), to name a few. pyradio is now able to "watch" a given theme for changes and update its colors whenever the theme changes. To set up a theme for auto update, one would just open the "Theme Selection window, navigate to a theme under User Themes and press "c". To create a user theme just follow the procedure described in section User themes. Consecuently, the default theme name will be preceded by:

            *   if the theme is the default one (the way it has always been).

            -   if the theme is the default one, and pyradio will watch it for changes.
    Using Project Themes
        pyradio is able to use (and watch) the output of certain projects that modify terminal colors. pyradio will detect theses projects (programs installed and initialized), and will add them under the Ext. Themes Projects section of the Themes Selection Window. If loading any of these themes fails, the default dark theme will be loaded, but contrary to a local theme being invalid, the selection will persist (so that the theme gets loaded wheneve it is available). Currently, the following projects are supported: 1. base16
            Thanks to the wonderful work by user edunfelt (https://github.com/edunfelt), there is now a pyradio base16 (https://github.com/base16-project) template in place, and themes have been produced based on the project (there are more than 900 themes available). This implementation will add four entries in the theme selection menu (with alternative and variant forms of the main theme). Then, any of the themes can either be activated or watched; in which case pyradio will download and apply the corresponding theme. Using the themes without base16
                In case one wants to use any of these themes, but not install or use base16 (https://github.com/base16-project), one can get them from this repo (https://github.com/edunfelt/base16-pyradio), and use the cycle_themes.py and install_themes.py scripts to inspect and install them.
        2. pywal
            When detected, two themes will be added to the menu; the main and the alternative form. Since these themes are generated on the fly, as the wallpaper changes, there is no way to use them if pywal (https://github.com/dylanaraps/pywal) is not in use.

            Note:
                If pywal (https://github.com/dylanaraps/pywal) themes are activated but not watched, the theme will be corrupted when the wallpaper changes, and will have to be manually reloaded. So, it's better to just always watch these themes.
        3. theme.sh
            When detected, four themes will be added to the menu; the main and the alternative forms (there are 400 plus themes available, which makes a stuggering number of around 1800 themes for pyradio!) Using the themes without theme.sh
                In case one wants to use any of these themes, but not install or use theme.sh (https://github.com/lemnos/theme.sh), one can download this repo (https://github.com/s-n-g/theme-sh-pyradio), and use the create_themes.sh script to create the themes, and cycle_themes.py and install_themes.py scripts to inspect and install them.

Mouse Support
Being a console application, pyradio was never intended to work with a mouse. Furthermore, when using the mouse on a console application, the result is highly dependent on the terminal used and the way it implements mouse support. Having said that, and since the question of using the mouse with pyradio has been risen, basic mouse support has been implemented; starting, stopping and muting the player, scrolling within the playlist and adjusting the player's volume is now possible using the mouse. All one has to do is enable mouse support in the "Config Window". Then, the mouse can be used as follows:
Action | Function
Click | Change selection
Double-click | Start / stop the player
Middle-click | Toggle player muting (does not work with all terminals)
Wheel | Scroll up / down
Shift-Wheel | Adjust volume (does not work with all terminals)

Note:
    The Wheel can be configured to adjust the player's volume instead of its default scrolling function through the Reverse wheel configuration option. Then, Shift-Wheel will scroll through the playlist. This is useful if Shift-Wheel does not work, or one is accustomed to using the wheel for volume control.

Title logging
Version 0.8.9.17 adds to pyradio the ability to log the titles displayed at the bottom of its window, in a log file, for reference. The logger, which works independantly from the "ebug" function, is actually a Rotating File Handler (https://docs.python.org/3/library/logging.handlers.html#logging.handlers.RotatingFileHandler), configured to write up to 5 files of around 50KB each (parameters maxBytes=50000 and backupCount=5). The way this works, according to the documentation, is that one "can use the maxBytes and backupCount values to allow the file to rollover at a predetermined size. When the size is about to be exceeded, the file is closed and a new file is silently opened for output. Rollover occurs whenever the current log file is nearly maxBytes in length… When backupCount is non-zero, the system will save old log files by appending the extensions ‘.1’, ‘.2’ etc., to the filename. For example, with a backupCount of 5 and a base file name of app.log, you would get app.log, app.log.1, app.log.2, up to app.log.5. The file being written to is always app.log. When this file is filled, it is closed and renamed to app.log.1, and if files app.log.1, app.log.2, etc. exist, then they are renamed to app.log.2, app.log.3 etc. respectively. The function can be enabled:

    1.  using the -lt (--log-titles) command line parameter, or

    2.  by pressing "W" while in the Main, the Playlist or the Register mode.
The titles are written in a file called pyradio-titles.log which is located in the Recordings Directory. Log file sample:
    Apr 18 (Mon) 13:12 | >>> Station: Lounge (Illinois Street Lounge - SomaFM)
    Apr 18 (Mon) 13:12 | Jack Costanzo - La Cumparsa, Harlem Nocturne
    Apr 18 (Mon) 13:14 | Don Baker Trio - Third Man Theme
    Apr 18 (Mon) 13:16 | Gillian Hills - Un Petit Baiser
Tagging a title An extra functionality is made possible because of "titles' logging": tagging a title (something like liking a song). The idea is that the user plays a station and hears a song he likes and want to look it up later. With this functionality, he can tag the song (make a note in the log file), so he can refer to it at a later time. To tag a title, one has to press the "w" key. Then, if titles's logging is already enabled, the log file will have an entry similar to the one shown below:
    Apr 18 (Mon) 13:39 | Tom Russell - Bus Station
    Apr 18 (Mon) 13:40 | Tom Russell - Bus Station (LIKED)
If title's logging is not enabled, it will be turned on, the song will be tagged and logging will be turned off again:
    Apr 18 (Mon) 15:38 | === Logging started
    Apr 18 (Mon) 15:38 | >>> Station: Folk (Folk Forward - SomaFM)
    Apr 18 (Mon) 15:38 | Lord Huron - Lullaby
    Apr 18 (Mon) 15:38 | Lord Huron - Lullaby (LIKED)
    Apr 18 (Mon) 15:38 | === Logging stopped

Online Radio Directory Services
pyradio supports the following Online Radio Directory services:

RadioBrowser - https://www.radio-browser.info/
    This is a community driven effort (like wikipedia) with the aim of collecting as many internet radio and TV stations as possible. For more information please refer to the relevant man page: pyradio_rb(1).

To access supported services, just press "O" at the program's main window.

Desktop Notifications
pyradio can provide Desktop Notifications when a notification daemon is already present (on Linux and BSD). The behavior and presentation of notifications greatly depends on the daemon/service and command line utility used to trigger a notification. If enabled, pyradio will display:

    1.  The playlist name, when playback starts.

    2.  Song info (as provided by the radio station). That means that if the radio station does not provide any info, no notification will be issued.

    3.  Connection failure messages.

    4.  Player crash messages.

Configuration
    Desktop Notifications are disabled by default. To enable them, go to pyradio config window and customize the "Enable notifications" option. Available values are:
        -1: disabled (deault)
        0: enabled (no repetition) x: enabled and repeat every x seconds
    pyradio supports notifications repetition, so that even when used with quake or yakuake and the like, you still have some info on what’s going on with it. Notifications can be set to repeat every "x" seconds, with "x" ranging from 30 to 300 (30 seconds to 5 minutes), in 30 seconds steps. Notification Icon
        The icon that is displayed in the notification message is by default pyradio icon. pyradio will search for this icon, named pyradio.png (or pyradio.ico on Windows) in the following locations:

        1.  In the configuration directory, under data (or Help folder on Windows).

        2.  In the distribution directory (under the icons folder).
            As a consequence, one could replace the icon found in the configuration directory (under data or Help) with a custom icon, preserving the icon name as appropriate (pyradio.png, or pyradio.ico on Windows).

        If the station defines a Station Icon URL (either on a local playlist or an online service; RadioBrowser includes an icon for many stations, for example), pyradio will used this one instead, provided that it is of JPG or PNG format.
On Linux
    On Linux (and the BSDs), pyradio uses the notification daemon that’s already present and whatever command line helper program it provides to send notifications to the daemon. By default, pyradio uses the following command to issue notifications:
        notify-send -i ICON TITLE MSG
    This command will:
        - display the title "TITLE" and message "MSG. - display an icon (-i).
    The "ICON", "TITLE" and "MSG" tokens are just placeholders; pyradio will replace them with real data when issuing the notification. If that does not work for you, or you want to customize the output, this is what to do:

        1.  put together a valid command that can be executed on a terminal and produce the desired notification.

        2.  create a file called notification in pyradio configuration directory.

        3.  write the above command in that file and put each field in a different line.
    Example
        I have this custom command:
            notify-send -i ICON -t 6000 TITLE MSG
        The file I wrote is ~/.config/pyradio/notification: notify-send
           -i
           ICON
           -t
           6000
           TITLE
           MSG
On MacOS
    MacOS Maverick (and later) provides a scripting service to issue notifications from the command line. The command pyradio uses is:
        osascript -e 'display notification "MSG" with title "TITLE"'
    If that does not work for you, or you want to display the icon as well, just install terminal-notifier:
        brew install terminal-notifier
    After it is installed, write the following in ~/.config/pyradio/notification: terminal-notifier
       -message
       MSG
       -title
       TITLE
       -appIcon
       ICON and you are done!

Desktop File
pyradio will install a Desktop File under ~/.local/share/applications.

Note:
    The system wide Desktop File will probably be under /usr/share/applications or /usr/local/share/applications.

By default, this Desktop File will add a “pyradio” entry under the "Internet" category (or menu), and will execute pyradio no matter if the directory it resides in is the PATH or not, using the default terminal that the system uses. In case of a local installation, when a system wide installation also exists, the entry will display "PyRadio - Local" to distinguish itself from the system wide "PyRadio" one.

Note:
    If the TERMINAL variable is set, the Desktop File will use that instead.

Specifying the terminal to use
    If a specific terminal has to be used, using the –terminal command line option is the way to go:
        pyradio --terminal kitty
    This command will set the terminal in the Desktop file, so that:
        Exec=kitty -e pyradio
    To have pyradio try to find a suitable terminal, execute:
        pyraio --terminal auto
    To restore the original functionality (specifying no terminal):
        pyradio --terminal none

Specifying pyradio parameters
    If a pyradio parameter has to be present in the Desktop File, use the -–terminal-param command line option:
        pyradio --terminal none --terminal-param "_p 2"
    This command will use no specific terminal and will pass the "-p 2" (play station No 2 automatically) parameter to pyradio. To pass such a parameter, substitute all hyphens with underscores.

Session Locking
pyradio uses session locking, which actually means that only the first instance executed within a given session will be able to write to the configuration file. Subsequent instances will be "locked. This means that the user can still play stations, load and edit playlists, load and test themes, but any changes will not be recorded in the configuration file. Session unlocking
    If for any reason pyradio always starts in locked mode, one can unclock the session, using the "--unlock" command line paremater.

Update Notification

pyradio will periodically (once every 10 days) check whether a new version has been released. If so, a notification message will be displayed, informing the user about it and asking to proceed with updating the program (provided this is not a distribution package).

Cleaning Up
pyradio will uninstall all previously installed versions when updated (using the -U command line parameter), so no extra steps are needed any more to house keep your system.

Playing a station in the terminal
A user request Shortcut to quit pyradio and launch standalone player (e.g. mpv) with currently selected station (https://github.com/coderholic/pyradio/issues/252) lead to the possibility to use any player in the terminal. This action will be triggered by pressing "X". After the player stops, pyradio will stop as well. In addition, a command line parameter has been added "-x" ("--exteranl-player") which when used in conjuction with the "-p" ("--play") command line parameter, will instruct pyradio to play a station and terminate after the playback stops.

Debug Mode

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.

In case of a bug or a glitch, please include this file to the issue you will open in github at <https://github.com/coderholic/pyradio/issues>

Reporting Bugs

When a bug is found, please do report it by opening an issue at github at <https://github.com/coderholic/pyradio/issues>, as already stated above. In you report you should, at the very least, state your pyradio version, python version and method of installation (built from source, AUR, snap, whatever). It would be really useful to include ~/pyradio.log in your report. To create it, enter the following commands in a terminal:

$ rm ~/pyradio.log
$ pyradio -d

Then try to reproduce the bug and exit pyradio. Finally, include the file produced in your report.

Acknowlegement

pyradio uses code from the following projects:

    1.  CJKwrap (https://gitlab.com/fgallaire/cjkwrap) by Florent Gallaire - A library for wrapping and filling UTF-8 CJK text.

    2.  ranger (https://ranger.github.io/) - A console file manager with VI key bindings.

    3.  Vifm (https://vifm.info/) - A file manager with curses interface, which provides a Vi[m]-like environment.

    4.  pyradio-m3u-to-playlist (https://github.com/LionyxML/pyradio-m3u-to-playlist) - An M3U to pyradio CSV converter which inspired the M3U fumctionality.

    5.  mpd-now-playable (https://git.00dani.me/00dani/mpd-now-playableR) - Expose your MPD server as a 'now playable' app on MacOS.

Files

/usr/share/doc/pyradio/README.html /usr/share/doc/pyradio/build.html /usr/share/doc/pyradio/radio-browser.html /usr/share/doc/pyradio/windows.html /usr/share/doc/pyradio/windows-mplayer.html /usr/share/licenses/pyradio/LICENSE

Note:
    On Mac OS, these file may be installed in /usr/local/share/doc/pyradio, depending on whether or not SIP is enabled.

Authors

Ben Dowling <https://github.com/coderholic>, (Origianl author)

Kirill Klenov <https://github.com/klen>, (2012)

Laurent Stacul <https://github.com/stac47>, (2013)

Peter Stevenson (2E0PGS) <https://github.com/2E0PGS>, (2018)

Spiros Georgaras <https://github.com/s-n-g>, (2018-2026)

You can see a complete list of contributors at
   https://github.com/coderholic/pyradio/graphs/contributors

Special thanks

1.  edunfelt (https://github.com/edunfelt), for her wonderful work on base16 themes (https://github.com/edunfelt/base16-pyradio), and ideas regarding theming and such.

2.  amano-kenji (https://github.com/amano-kenji), for his valuable suggestions and bug reports.

3.  Scary-Guy (https://github.com/Scary-Guy), for his suggestions on improving user experience.

4.  travis-jeans (https://github.com/travis-jeans), for his suggestions on the TTS system.

See also

pyradio_rb(1)
    RadioBrowser Implementation

pyradio_rec(1)
    Recording stations

pyradio_server(1)
    Remote Control Server

pyradio-client(1)
    Remote Control Client