Last active
August 29, 2015 14:20
-
-
Save libricoleur/a0c9b553596771bd0bbe to your computer and use it in GitHub Desktop.
Vérificateur de dispo Kimsufi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Par défaut, seul le KS-1 est surveillé. Pour les autres références, inspectez | |
# le tableau sur la page kimsufi.com et cherchez les attributs "data-ref". | |
# | |
# Pour l'exécution, vous avez le choix : en boucle dans un terminal (dans un | |
# intervalle raisonnable !), en tâche cron si vous lisez vos mails système, | |
# ou en notification graphique : | |
# while true; do r=`./kimsufi.py`; if [ "$r" != "" ]; then notify-send Kimsufi -t 30000 $r; fi; sleep 60; done | |
URL = "https://www.kimsufi.com/fr/js/dedicatedAvailability/availability-data.json" | |
REFS = ['150sk10', ] | |
import urllib.request | |
import json | |
avails = json.loads(bytes.decode(urllib.request.urlopen(URL).read())) | |
for ref in avails['availability']: | |
if ref['reference'] in REFS: | |
for s in set(filter(lambda s: s not in ['unknown', 'unavailable'], [z['availability'] for z in ref['zones']])): | |
print("{} : {}".format(ref['reference'], s)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment