I find it convenient to play FIP radio in terminal with mpv:

mpv http://direct.fipradio.fr/live/fip-midfi.mp3

enter image description here

Can I get more info on the playing song in terminal?


A friend gave me a script that should list the FIP radio list in terminal.

I think he uses it on a Mac, but the script might work in Linux if changed.

This is the script:

import requests

URL = 'http://www.fipradio.fr/livemeta/7'

data = requests.get(URL).json()
level = data['levels'][0]
uids = level['items']
for i in uids:
    step = data['steps'][i]
    print("{title} — {authors} ({anneeEditionMusique}){space:>60}".format(space=' ', **step).encode("utf-8"), end="\r”)

That's what my friend gets when running it (if I have understood it right):

enter image description here

In order to run that in Linux I have created the file list_fip.py containing the line

#! /usr/bin/python3

followed by the lines above.

I have made the file executable, then, in Dolphin, selected the file and, from right-click context menu Actions>Run in Konsole. Which gives this:

  File "/home/cip/Desktop/fip_titles.py", line 14
    print("{title} — {authors} ({anneeEditionMusique}){space:>60}".format(space=' ', **step).encode("utf-8"), end="\r”)
SyntaxError: EOL while scanning string literal

  • 1
    If you look carefully at the last double-quotes in "\r" it seems you have typed or copied the wrong character. You need the ascii ". – meuh Oct 15 '18 at 15:56
  • UPDATE no3: The error mentioned in UPDATE no1 above was just caused by a wrong character ( needs to be replace with "), as @meuh commented. – user32012 Oct 15 '18 at 16:17

This stackoverflow answered question is similar. If you look at the data stream from your URL (e.g. using curl -v) you will first get a redirect (302 Moved Temporarily) to a new URL. From that new URL you will find the header

icy-metadata: 1

but I did not see any metadata included in the stream. Since this is public radio (in France) you could try asking them to include it.

Your other alternative is to try to scrape it from the web page. There is one with the player, and another with just the current title. However, it will not be easy as the data is obtained dynamically through javascript.

  • I remember somebody mentioned to me a python script that showed such info in terminal - possibly only the playlist; I hope to talk to the man soon about that. – user32012 Jul 23 '18 at 7:41
  • I will update the question based on the script mentioned above – user32012 Oct 15 '18 at 15:43
  • I have updated the question with info on a script that was the initial motive to post the question - but I didn't remember all the details when I have posted the question, and only now I can describe what I meant in the first place. – user32012 Oct 15 '18 at 15:55
  • Please post your comment to my question in your answer please. Also, I will update the question again to ask how to show in terminal that list along with the playing song. – user32012 Oct 15 '18 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy