yyrkoon94 / lovelace-idf-mobilite

Lovelace Card for IDF Mobilité (Bus, Métro, RER)
24 stars 6 forks source link

Feature/import automatically images from ratp #26

Closed wgrs33 closed 8 months ago

wgrs33 commented 8 months ago

The goal of the PR is to use a dedicated script which will be able to update all images used by this lovelace card.

  1. I grouped the files into categories which are related to line's transportmode reported in the JSON file. a. All PNG files are replaced with SVG as they can be easily scaled without any quality loss b. There are no more icons for buses (except the nightbuses and orly/roissybus); icons are generated based on the data provided in the JSON file c. CSS code has been updated to centerline the text and the images; there is still a need to update the flex option for the bus-destination and the inner classes, because the destination text can overlap with line number image
  2. If there is a replacement bus detected for a train line, there is anew option to show it in the RER card (show_replacement_bus); the icon is then changed to from train to bus icon and there is a warning sign before
  3. The import script can be executed automatically to update the files (ex. each month)

I need to check this evening the replacement_bus option with line L, but it should work correctly

wgrs33 commented 8 months ago

there is still a need to update the flex option for the bus-destination and the inner classes, because the destination text can overlap with line number image

Code corrected

wgrs33 commented 8 months ago

It seems that in the mean time the source page has been upgraded with CloudFlare which stops simple JS code (or any other) to download the files. I found a solution in Python and JS by using Selenium library, but I need to refactor the script's code. It will be necessary to have a PC with a Chrome web browser.

yyrkoon94 commented 8 months ago

Hi @wgrs33,

That the reason why I put the images in the card because the download not working every time and I had also some issue trying to do the same. For me it's too complicated to use your solution ( selenium and co) to only download 3/4 images. So I think the good idea is to remove icons for buses that are in the json files and keep the specific icons (Orly, ...).

wgrs33 commented 8 months ago

Hi @yyrkoon94,

Sorry for the misunderstanding, the idea of this script is to synchronize database and files offline in this repository, not in the card. To better clarify:

  1. Create new branch
  2. Launch script
  3. Push modifications
  4. Create PR and merge it
  5. Create new release

What do you think ?

yyrkoon94 commented 8 months ago

Oh ok, it's clearer like that ;) Looks good for me if the idea is to update files in the repository and create a new release.

wgrs33 commented 8 months ago

I'll open another PR, which will be cleaner