Git Product home page Git Product logo

filau / python_divia_api Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 47 KB

đŸ‡«đŸ‡· RĂ©cupĂ©rez les horaires des prochains bus et trams Divia, et les disponibilitĂ©s des DiviaVĂ©lodi, directement depuis Python !

Home Page: https://pypi.org/project/divia-api/

License: GNU Lesser General Public License v3.0

Python 100.00%
api bus dijon divia diviavelodi horaire module package pip pypi python timetable tram tramway velodi

python_divia_api's Introduction

đŸ‘‹đŸ» Firmin Launay

Hello, my name is Firmin, and here is my GitHub profile.
You can find the coding projects that I published or that I am currently working on.

Discover my website : firminlaunay.me

Currently active projects

  • Stickopy is a little piece of software, coded in Dart, which allows to copy the whole content of a USB drive automatically (when plugged), quickly and quietly.
  • Python Divia API is a simple Python library, which aims at providing a simple way to retreive “TOTEM” schedules of Divia (the city of Dijon’s public transit authority) bus and tramways.

Skills

  • Python
  • Dart & Flutter
  • HTML, CSS & JS
  • Windows CMD
  • Unix shell
  • Git
  • MongoDB

python_divia_api's People

Contributors

filau avatar

Stargazers

 avatar

python_divia_api's Issues

Suggestion : TTLCache pour VĂ©lodi

Salut !

Merci pour ce package ! Je souhaite récupérer les données de disponibilités pour toutes les stations en une fois.

Le code actuel n'est pas optimisĂ© pour ce cas d'usage car une requĂȘte HTTP est effectuĂ©e pour chaque station.check()

class VelodiStation:
def __init__(self, code: str, raw_name: str, friendly_name: str):
self.code = code
self.raw_name = raw_name
self.friendly_name = friendly_name
def check(self):
velodi_data = update_source()

L'appel à update_source n'est nécessaire que si les données sont expirées, la page sur le site de Divia semblant avoir elle aussi une forme de cache.

Voici le monkey patch que j'ai fait localement en utilisant un TTLCache de cachedtools si jamais tu es intéressé.

RĂ©cupĂ©rer les donnĂ©es de toutes les stations dans une boucle ne fait plus qu'une seule requĂȘte HTTP.

import divia_api
from divia_api import DiviaAPI
from divia_api.velodi import update_source as update_source
from cachetools import cached, TTLCache

import math


@cached(cache=TTLCache(ttl=30, maxsize=math.inf))
def cached_update_source():
    return update_source()


divia_api.velodi.update_source = cached_update_source


velodi_api = DiviaAPI().velodi
for station in velodi_api.stations:
    availability = station.check()
    print(station.code, station.friendly_name, availability.bikes, availability.docks)

Données non temps réel pour Vélodi

Il semble malheureusement que la source utilisée pour les données temps réel de DiviaVélodi ait un cache de plusieurs heures

"https://www.divia.fr/velo/diviavelodi/ou-trouver-les-stations-diviavelodi").content.decode("utf-8")

J'ai pu trouver des différences de chiffre en regardant successivement les données de la carte puis de stations individuelles. Il y a également un champ predictions avec un datetime datant de plusieurs heures dans la page web.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.