update the readme, and beautify the menu

This commit is contained in:
Greg Gauthier 2021-03-16 09:41:38 +00:00
parent feb5277d7b
commit 6cd38adabd
2 changed files with 19 additions and 26 deletions

View File

@ -7,7 +7,7 @@ Simple python tool to grab radio stations from radio-browser.info, put them into
* Linux (any flavor, but debian based is probably best) * Linux (any flavor, but debian based is probably best)
* Python3 * Python3
* Pipenv * Pipenv
* mpg123 (or mplayer, if you want to swap it in yourself) * mpv (or mpg123, or mplayer, if you want to swap it in yourself)
### Install ### Install
@ -42,25 +42,20 @@ Radio Player Menu
2. WFMT 98.7 Chicago - IL (AAC) AAC 256 http://wowza.wfmt.com/live/smil:wfmt.smil/playlist.m3u8 2. WFMT 98.7 Chicago - IL (AAC) AAC 256 http://wowza.wfmt.com/live/smil:wfmt.smil/playlist.m3u8
3. WFMT 98.7 Chicago - IL (MP3) MP3 0 http://stream.wfmt.com/main-mp3 3. WFMT 98.7 Chicago - IL (MP3) MP3 0 http://stream.wfmt.com/main-mp3
Select Option: 3 Select Option: 3
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3 (+) Audio --aid=1 (mp3 2ch 44100Hz)
version 1.26.3; written and copyright by Michael Hipp and others AO: [coreaudio] 44100Hz stereo 2ch floatp
free software (LGPL) without any warranty but with best wishes A: 00:00:00 / 00:00:04 (22%) Cache: 3.1s/107KB
File tags:
Directory: http://stream.wfmt.com/ icy-title: Liszt, Franz - Tasso, lamento e trionfo, Symphonic Poem No. 2 (1849) - - - DG
A: 00:00:04 / 00:00:28 (18%) Cache: 22s/804KB
Terminal control enabled, press 'h' for listing of keys and functions. File tags:
icy-title: ANON 14th c, French - Au jour du bouhourdis - - - Calliope
Playing MPEG stream 1 of 1: main-mp3 ... A: 00:00:27 / 00:00:51 (53%) Cache: 23s/833KB
ICY-NAME: /main-mp3
ICY-URL: https://www.streamguys.com/
MPEG 1.0 L III cbr128 44100 j-s
ICY-META: StreamTitle='Virgil Thomson - Louisiana Story Suite - New London Orch/Ronald Corp - - Hyperion';
``` ```
When I hit `Q`, mpg123 exits, and sends me back to my menu:
When I hit `Q`, mpv exits, and sends me back to my menu:
``` ```
[1:56] Decoding of main-mp3 finished. Exiting... (Quit)
Radio Player Menu Radio Player Menu
0. Exit menu 0. Exit menu
@ -73,8 +68,8 @@ Select Option:
### CAVEATS ### CAVEATS
1. This is a VERY ROUGH script. If your search criteria are too broad, you'll get hundreds and hundres of menu items. I set the limit to 9999, and it seems to work ok. But don't push your luck. 1. This is a VERY ROUGH script. If your search criteria are too broad, you'll get hundreds and hundres of menu items. I set the limit to 9999, and it seems to work ok. But don't push your luck; try to be as precise with your searches as possible.
2. mpg123 and mplayer are primitive at best. Not all the stations on the list will play correctly, without the proper config/plugins. So, just keep trying until you find one that works. 2. ~~mpg123 and mplayer are primitive at best.~~ `mpv` is a better player than mpg123, and more streams will work out of the box. What's more, via homebrew, `mpv` is available on mac or linux. However, it's still the case that not all the stations on the list will play correctly. This is partly due to the player, but mostly due to problems with the streams themselves.
3. if you supply multiple tags in a comma-separated list, you may unintentionally filter out results. Unfortunately, the api at radio-info is such that the tag list you search for, has to be in precisely the order it is returned from the host. So, for example, if you search for "classical,chicago", your search will filter out WFMT, because their tags are "chicago,classical". So, best to keep your tags to a minimum (meaning 1 lol) 3. if you supply multiple tags in a comma-separated list, you may unintentionally filter out results. Unfortunately, the api at radio-info is such that the tag list you search for, has to be in precisely the order it is returned from the host. So, for example, if you search for "classical,chicago", your search will filter out WFMT, because their tags are "chicago,classical". So, best to keep your tags to a minimum (meaning 1 lol)
4. The country search is by country NAME, not CODE. So, "United States" will work, but "US" will not. Likewise for the United Kingdom. 4. The country search is by country NAME, not CODE. So, "United States" will work, but "US" will not. Likewise for the United Kingdom.
5. It seems many of the stations put their city in the tag list. So, you can reduce the size of your results by doing something like this: `-c "United States" -t "atlanta"`, which makes more sense for radio stations anyway. Eg: 5. It seems many of the stations put their city in the tag list. So, you can reduce the size of your results by doing something like this: `-c "United States" -t "atlanta"`, which makes more sense for radio stations anyway. Eg:
@ -97,5 +92,3 @@ Select Option:
### Potential next steps: ### Potential next steps:
* Searching by tags would be powerful, if it didn't matter how many or which order they were in. So, one approach might be to do some sort of preprocessing on them, after capture. But this requires getting an unfiltered list to begin with. The server code itself is open source on github. So, one could potentially suggest an improvement to the tag searching, via pull request. You can find it here: https://github.com/segler-alex/radiobrowser-api-rust * Searching by tags would be powerful, if it didn't matter how many or which order they were in. So, one approach might be to do some sort of preprocessing on them, after capture. But this requires getting an unfiltered list to begin with. The server code itself is open source on github. So, one could potentially suggest an improvement to the tag searching, via pull request. You can find it here: https://github.com/segler-alex/radiobrowser-api-rust
* The hard-coded call to `mpg123` is in `radiomenu.py`. This could be pull out to a config file. Then, potentially, you could even use this on windows, if you had a sufficiently similar console binary for executing audio streams.

View File

@ -11,13 +11,13 @@ class RadioMenu(AbstractMenu):
station_list = [] station_list = []
for i in range(len(station_list)): for i in range(len(station_list)):
if i < maxitems(): # The last item is the exit option, so not "<=". if i < maxitems(): # The very first item is the exit option, so not "<=".
self.add_menu_item( self.add_menu_item(
MenuItem( MenuItem(
i, i,
station_list[i]["name"] + " " + "{:<35}".format(station_list[i]["name"][:35]) + " " + # force 35 character fixed length
station_list[i]["codec"] + " " + "{:<5}".format(station_list[i]["codec"][:5]) + " " + # force 5 character fixed length
station_list[i]["bitrate"] + " " + "{:<5}".format(station_list[i]["bitrate"][:5]) + " " +
station_list[i]["url"], station_list[i]["url"],
lambda url=station_list[i]["url"]: subprocess.run([player(), options(), url]) lambda url=station_list[i]["url"]: subprocess.run([player(), options(), url])
) )