PyRadio - cli internet radio player

I believe this happens due to the player used, station selected and network connectivity (or a combination of them)…

I have tried to detect such a condition, but failed…
The only thing I can detect is player termination; sometimes the player just terminates when something happend to the stream… but not always…

I don’t think that helps you though

:slight_smile:
No, nobody implied anything like that!
I will add the corresponding instruction there, just in case other people fail to realise it, just like you

2 Likes

About the feature to obtain the infos about the music stream, I had an idea aside from mindlessly spaming the log file. I don’t know if it’s feasable, but here is my feature request :smiling_face: :


Current behaviour:

  • At the moment the information about the music stream (music title / name of show or feature) appears in the bottom left corner of the Pyradio window if provided by the radio station’s stream service.

  • It’s not possible to highlight or copy the text. User has to make notes manually (quite distracting).

  • The information is not logged and subsequently only obtainable (if lucky) from the website of the radio station (more cumbersome for the user)


Desired behaviour

  • Add a function to pipe the music info of a single, currently playing track to a “favourites”- or “liked”-list with timestamp and radio station.

  • perhaps add a keybind / “like-button” to invoke this functionality with a single stroke and to show/edit the list in Pyradio or an external editor.

  • The list could be stored in the pyradio configs directory.

  • Alternatively / additionally there could be an automatically generated list of the last heard songs / programs with a limited amount of entries (to not let it grow exorbitantly) to track back one’s own activity.


It would be really cool if that’d be possible since somewhere in the code this info is already extracted to be displayed in Pyradio, so my idea was that it wouldn’t be to hard to do this on command manually and pipe the info to a chosen destination.

Hope that request was not too audacious. If you like I could put it in your ‘Issues’ directory on Github instead. Please keep up the amazing work!

2 Likes

Hi @Faehnchen

I have already started working on it (I like the idea a lot), so here’s what I have come up with (up to now)

You execute pyradio -lt (-lt is --log-titles to enable titles’ logging)

Then you get a file ~/.config/pyradio/pyradio-titles.log with entries like

Apr 15 (Fri) 10:28 | Ennio Morricone - Meglio Stasera (Vocals Miranda Martino) (1964)
Apr 15 (Fri) 10:30 | Keith Mansfield - Young Scene
Apr 15 (Fri) 10:31 | Bob Crewe Generation - Winchester Cathedral
Apr 15 (Fri) 10:34 | Gillian Hills - Cha Cha Stop
Apr 15 (Fri) 10:37 | Martin Denny - Moonlight And Shadows
Apr 15 (Fri) 10:39 | Bernie Green - Ping Pong
Apr 15 (Fri) 10:42 | Leo Addeo - Stumbling

Enabling titles’ logging will probably be a configuration option or a key shortcut, depending on what I find easier to implement :wink:

So here’s how it works: I have used the RotatingFileHandler with maxBytes=50000 and backupCount=5. So according to the documentataion:

So, if you wanto to give it a go, you can download this archive . When you get it:

tar xvzf pyradio.tar.gz
cd pyradio
devel/build_install_pyradio
pyradio -lt

Please make sure you uninstall the official Mabox package brefore installing this archive

sudo pacman -R pyradio
5 Likes

Now also logging stations…

Apr 15 (Fri) 22:08 | >>> Station: Folk (Folk Forward - SomaFM)
Apr 15 (Fri) 22:08 |     The Civil Wars - Girl with the Red Balloon
Apr 15 (Fri) 22:09 | >>> Station: STAR FM 88.8 Kerkyra Corfu Greece
Apr 15 (Fri) 22:09 |     TRIANTAFYLOU MIX - PETROS
Apr 15 (Fri) 22:17 | >>> Station: Celtic Sounds
Apr 15 (Fri) 22:17 |     New Found Trails - Voice in the Dark
Apr 15 (Fri) 22:18 | >>> Station: Celtic (ThistleRadio - SomaFM)
Apr 15 (Fri) 22:18 |     Ashley MacIsaac - My Home/The Contradiction/Julia Delaney
Apr 15 (Fri) 22:19 | >>> Station: American Roots (Boot Liquor - SomaFM)
Apr 15 (Fri) 22:19 |     Lori McKenna - Bible Song
Apr 15 (Fri) 22:22 |     Paleface & Just About To Burn - Kick This Jam
Apr 15 (Fri) 22:25 |     Honky Tonk Disciples - Truck Stop Girl
4 Likes

Looks amazing development…definitiely a cool feature

2 Likes

Oh man, I sat the whole night writing a little bash script for logging manually for me for the time waiting and finally I got it working. Lot of new stuff I had to wrap my head around. Didn’t reckon that you would be so fast :smile:. However it was a nice exercise for me as a newbie. Perhaps someone has a use for it, since it’s pretty versatile to take quick notes and has some nice functionallity, like display of the last three entries in declining order and the ability to delete the last entry from the logfile. It doesn’t scroll down thanks to ‘tput’ prompt-manipulation (I not nearly understand all the features of it yet, but it’s quite fun to fiddle around with it.)

Pro tip: Use with Lolcat! ( scriptname.sh | lolcat )

I look forward to try your new version as soon as possible. Thanks for beeing so approachable for suggestions!

#!/bin/bash

                  # # # # # # # # # # # # # # # # # # # # # # # # # #
                  # · · · · · · · · · · · · · · · · · · · · · · · · #
                  # · · Manual logging-script for PyRadio:· · · · · #
                  # · ·¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ · ·  `ovo´· #
                  # · · · · · · · · · · · · · · · · · · · ·  /(_)\· #
                  # · · · · · · · · · · · · · · · · · · · ·   … … · #
                  # # Faehnchen Apr. 15, 2022 # # # # # # # # # # # #


#   A little script to take notes with a time stamp in the terminal
#  ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
#   Currently there is no feature in PyRadio to pipe information of a music stream like song/
#+ band/programm into a logfile or even copy text from the application. So I wrote this little
#+ script to help me at least a little bit  with that for the while. Just execute alongside PyRa-
#+ dio or any other activity you think you might need notes with a timestamp from.

#   Also, change it to your liking and use it to log when you saw a particularly beautiful
#+  bird or you have to remember at which hour your annoying neighbor heard loud music!

#   Have fun and special thanks again to Spiros Georgaras, the creator and maintainer of
#+  PyRadio!


#   Change these variables to use script universally
FILEPATH="$HOME/.config/pyradio/pyradio_favourites.list"
TEMPFILE="$HOME/.config/pyradio/pyr_fav.tmp"

ls "$FILEPATH"
favlist=$?
clear
sleep 0.5

#   Automatc creation when executing for the first time or logfile was renamed
  if [ $favlist -ne 0 ]; then
    echo -e "\n\033[0m         No default list-file detected."
    echo -e "\n Resume and create a new PyRadio-favourites-list"
    echo -e " in: ~/.config/pyradio/pyradio-favourites.list ? \n"
    echo -n " ›r‹ resume | ›ANY KEY‹ quit  > "
    read resume

      if [[ $resume != [r] ]]; then
        exit 0

    fi

    clear
    echo -e "\n             Done!     Start $NAME . . ."
    touch "$FILEPATH"
    sleep 2

fi

touch "$TEMPFILE"

clear
echo -e "\n Which radio station are you currently listening to? \n "
echo -n " ›ENTER‹ to skip  > "
read station

#   Prompt for input (don't use 'Tab'-key and a too small window! It scrambles the output pretty much.)
clear
echo -e "\033[0m ›ENTER‹ add to list | ›x‹ delete last entry | ›q‹ quit"
echo -e "\033[1;32m  Your - note  ↑ ↑ ↑ \033[0m "
echo -e "\033[1;32m  ¯¯¯¯¯¯¯¯¯¯¯ \033[0m "
count=1

  while [[ $count > 0 ]]; do
    echo -n "   > "
    read note
    tput el
    tput cuu 1
    tput el

  	  case $note in
        x) #  Delete function
          head -n -1 "$FILEPATH" > "$TEMPFILE"
          cat "$TEMPFILE" > "$FILEPATH"
          sleep 0.3
          tput cud 1
          tput el
          echo "  deleted '$note1'."
          tput cuu 2
          tput sc
         ;;
        q) #  Quit from the script
          sleep 0.3
          echo -e " Your entries added to > \n ~/.config/pyradio/pyradio/pyradio-favourites.list"
          printf "%-s           (%10s) \n" "=======QUIT=======" "$station" >> "$FILEPATH"
          tput cud 4
          rm "$TEMPFILE"
          wait; exit 0
          ;;
        *)
          dtime=`date +"%Y-%m-%d %H:%M"`
          printf "[%-16s] %2d) %-s\n" "$dtime" $count "$note" >> "$FILEPATH"
          #---Show last three entries in declining order---------------
          note3="$note2"
          count3=$count2
          tput cud 5
          tput el
          printf "\r\033[36m %3d. %-s \033[0m\n " $count2 "$note2"
          tput cuu 6
         #---------------------------------------------------------3---
          note2="$note1"
          count2=$count1
          tput cud 4
          tput el
          printf "\r\033[36m %3d. %-s \033[0m\n " $count1 "$note1"
          tput cuu 5
         #---------------------------------------------------------2---
          note1="$note"
          count1=$count
          tput cud 3
          tput el
          printf "\r\033[36m %3d. %-s \033[0m\n " $count "$note"
          tput cuu 4
         #---------------------------------------------------------1---
          ;;
    esac

      count=$(( $count+1 ))
      sleep 0.3

done


exit 1

2022-04-16_06-35

3 Likes

I think it’s ready…

Adding to the -lt command line option, W toggles titles’ logger on/off and w “likes” a title (can be pressed even if logger is not enabled).

The archive is always here

Sample

Apr 16 (Sat) 21:32 | >>> Station: Lounge (Illinois Street Lounge - SomaFM)
Apr 16 (Sat) 21:32 |     Maurice Montez - That Old Black Magic
Apr 16 (Sat) 21:33 |     George Melachrino - Sand In My Shoes
Apr 16 (Sat) 21:36 |     Stanley Black - Babalu
Apr 16 (Sat) 21:39 |     Martin Denny - The Carioca
Apr 16 (Sat) 21:42 |     Jack Costanzo - La Cumparsa, Harlem Nocturne
Apr 16 (Sat) 21:42 |        I like this song and will look it up!!!
Apr 16 (Sat) 21:48 |     Arthur Lyman - Bwana A
Apr 16 (Sat) 21:52 |     11 Acorn Lane - The Sneak
Apr 16 (Sat) 21:55 |     Joe Loco - Nightmare
2 Likes

New feature looks cool! I think I will go test it tomorrow. Regarding the sample you showed I had a suggestion: For the “like”, don’t put it in a new line but make another column right next to the listed songs with a string or symbol indicating you liked this particular song on the same line, something like this:

Apr 16 (Sat) 21:36 |     Stanley Black - Babalu                 |  ***LIKED***

That would it make it easier to extract these lines with ‘grep’ and ‘awk/sed’ later to create a list of liked songs.
Would that be possible? :smiley:

2 Likes

No, I don’t think this is possible…
Titles (and station name) are written to the log as soon as they are received…

But I could rewrite the title and include a “LIKED” token, that would be really easy.

It would be something like this:

Apr 16 (Sat) 21:36 |     Stanley Black - Babalu
Apr 16 (Sat) 21:36 |     Stanley Black - Babalu (LIKED)
3 Likes

Perfect, thanks!
+++

2 Likes

Done!

Please do give it a go and tell me if anything seems off or you find any bugs

Have a good night!

3 Likes

Ok, tested. Installation was easy. Thanks for your instructions!
Logging works fine! With ‘python -lt’ logging is forcefully enabled. When running ‘pyradio’ without the option, switching logging-mode with ‘W’ also works flawlessly and grabs the currently playing title imediatly. Liking with ‘w’ also no problem. The only thing are the doublings in the logfile. Is that only on my system? They are no big problem. I simply cut them out with the ‘uniq’ command, but it would mean that the rollover of the logfile would happen in half the time, no?

For extraction of my favs I run:

zgrep "(LIKED)" ~/.config/pyradio/pyradio-titles.log | sed 's/(LIKED)//' | uniq

and funneled the output into a new file.

For everyone wanting to test this: Make sure the package ‘python-pip’ is installed!

Conclusion: That’s exactly the feature I wished for. I’m 100% sure others will like it as well. Great job! :cake:

4 Likes

Found the reason for the doublings in the log. Apparently when starting with the ‘-lt’ option, manual logging is also enabled. Disabling with ‘W’ the logging continues normally.

2 Likes

The dublication was my bad; I’ve fixed it :slight_smile:

There’s just one thing though; muting the player. While the player is muted, titles will not be logged.

As soon as the player is unmuted, logging will resume.

What do you think? Should we log titles while the player is mutted? It’s very easy to do, either way… :slight_smile:

1 Like

I am happy you are contented!
I also think others (including me; I am a PyRadio user too :slight_smile: ) will like this feature!

2 Likes

Good morning!
Yes I think we should log titles while muted. For real pausing (and halting the log) I can press the space-key. That interrupts the mpv-player stream altogether. By pressing space again, mpv sets back in and logging also resumes (though I don’t know if vlc and mplayer behave the same in the terminal).
So I think it’s good when logging continues while muted to, for example, beeing able to check what one has missed while beeing on the telephone or something like that.

2 Likes

Good morning to you too!

ok, I will enable it and upload it again…

2 Likes

ok, done
Always here

2 Likes

Just wrote a little bash script to easily extract your ‘LIKES’ from the pyradio-titles.log and store them in a seperated list. Also with added search-links! Check it out! :slightly_smiling_face:

4 Likes

Just released PyRadio 0.8.9.17

In case you have installed the test archive mentioned in this thread, please uninstall it now using

python -m pip uninstall pyradio

Then you can install it again from Mabox repo

sudo pacman -S pyradio

and wait for @napcok to update it

Cheers!

4 Likes