Skip to content

Instantly share code, notes, and snippets.

@zopieux
Last active February 4, 2024 16:32
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zopieux/ccb8d29437765083e4c80da52f2145b2 to your computer and use it in GitHub Desktop.
Save zopieux/ccb8d29437765083e4c80da52f2145b2 to your computer and use it in GitHub Desktop.
FIP radio live metadata
# Displays the currently playing media at FIP radio
# http://www.fipradio.fr/player
# You may want to update the number at the end of the URL
# if you use a specific "style" channel instead of the
# generic (main) channel, which is 7.
import requests
import time
import subprocess
URL = 'https://api.radiofrance.fr/livemeta/pull/7'
def retrieve():
data = requests.get(URL).json()
level = data['levels'][0]
uid = level['items'][level['position']]
step = data['steps'][uid]
return step
def main():
last_data = None
while True:
try:
data = retrieve()
except Exception:
time.sleep(2)
continue
if data != last_data:
msg = "{title} — {authors} ({anneeEditionMusique})".format(**data)
subprocess.check_call(['notify-send', '-i', 'applications-multimedia', 'FIP radio',
msg])
last_data = data
time.sleep(10)
if __name__ == '__main__':
import traceback
try:
main()
except:
with open('/tmp/fip-crash.log', 'w') as f:
traceback.print_exc(file=f)
@villeneuve
Copy link

Bonjour,
Depuis juillet 2019 l'url des metadata de Fip a changée c'est maintenant:
https://api.radiofrance.fr/livemeta/pull/7
Merci pour ce code :-)

@zopieux
Copy link
Author

zopieux commented Aug 13, 2019

@villeneuve Merci de m'en avoir informé ! J'ai mis à jour le script.

@natcl
Copy link

natcl commented Dec 29, 2020

Inspiré par ce script, voici un raccourci iOS qui fait la même chose:
https://www.icloud.com/shortcuts/8e8961c616ab439897d998a1e858c079

@wturrell
Copy link

wturrell commented Feb 4, 2024

A slightly modified version that prints the track listing to the terminal one line at a time (with timestamps):
https://gist.github.com/wturrell/f887b3d413339597b35549293f1bad63

@villeneuve
Copy link

@wturell: Excellent!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment