![]() |
![]()
| ![]() |
![]()
Namepyradio - a curses Internet radio player. Synopsispyradio [OPTIONS] Descriptionpyradio 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. OptionsGeneral options:
Playlist selection:
Themes:
Terminal selection:
Cache:
Recording stations:
Headless operation:
The following options can also be set in pyradio’s configuration file: Controls
The same logic applies to all pyradio windows.
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
PyRadio's Modespyradio has the following primary modes:
A set of secondary modes is also available (a secondary mode works within a primary one):
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).
Config Filepyradio 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 Filespyradio 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 following table presents the Station's fields and the current level of support.
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.
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:
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
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
pyradio -s 5 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:
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 historyPlaying 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 FunctionOn 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 Editorpyradio "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:
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:
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 AroundRearranging 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:
Specifying Stations' EncodingNormally, 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.
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,
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 / Selectionpyradio 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:
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.
Specifying a station's Referer URLAlthough 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]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:
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:
Please note the number of commas inserted after the
Station URL.
Extra Player ParametersAll 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:
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 ProtocolMost 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.
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 LevelAll 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]
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]
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 InfoWhen 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 - Registerspyradio 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.
To copy a station to a register one would press "y" and:
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:
Favorites playlistPressing "*" 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 TimeThe 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".
PyRadio Themespyradio comes with 6 preconfigured (hard coded) themes:
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.
The window will display the current state of the Use transparency and Force transparency configuration options in its bottom right corner:
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
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:
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:
Theme defined secondary windows color Themes have the following entry
Calculated secondary windows color
# 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:
pastel color '#fbf1f2' # show color info
pastel lighten .1 '#fbf1f2' # color lightened by 10% pastel darken .1 '#fbf1f2' # color darkened by 10%
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.
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
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).
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).
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:
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:
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.
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 SupportBeing 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:
Title loggingVersion 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:
The titles are written in a file called pyradio-titles.log which is saved at pyradio configuration 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 Servicespyradio supports the following Online Radio Directory services:
To access supported services, just press "O" at the program's main window. Desktop Notificationspyradio 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:
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:
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:
Example I have this custom command:
notify-send -i ICON -t 6000 TITLE MSG
The file I wrote is ~/.config/pyradio/notification: notify-send
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
and you are done! Desktop Filepyradio will install a Desktop File under ~/.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.
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 Lockingpyradio 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 Notificationpyradio 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 Uppyradio 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 terminalA 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 ModeAdding 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 BugsWhen 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
Then try to reproduce the bug and exit pyradio. Finally, include the file produced in your report. Acknowlegementpyradio uses code from the following projects:
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
AuthorsBen 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-2024) You can see a complete list of contributors at
Special thanks
See also
|