RotorJackets / Goggle_Buzz

Discord bot for use on the Rotor Jackets Discord server.
https://rotorjackets.tech/
3 stars 1 forks source link

Velocidrone Integration #9

Closed Ian-Boraks closed 1 year ago

Tdogb commented 1 year ago

`#!/bin/bash

Official? 0 = yes, 1 = no

official="0"

Race Mode, 3 = single lap, 6 = 3 lap

race_mode="6"

Online Track ID

trackID="888"

Sim Version (ALL does not work)

version="1.16"

Friendly track name

track_name="vrl8_race2"

Save location

saveto="/var/www/html/www.reddingfpv.com/vrl/$track_name-$(date +%F).json"

wget https://www.velocidrone.com/leaderboard_as_json2/$official/$race_mode/$trackID/$version -O $saveto`

Tdogb commented 1 year ago

Example URL: https://www.velocidrone.com/leaderboard_as_json2/0/6/888/1.16

Ian-Boraks commented 1 year ago

Hmmmm . . . That would def work. We could also probably implement this in python with requests. This would allow us to run update commands to grab new data with the bot.

We could also parse the HTML (if needed) with beautiful-soup like I did in https://github.com/Ian-Boraks/BestBuy-Stock-Checker-Test-Python

Ian-Boraks commented 1 year ago
import requests

def get_leaderboard(url: str) -> dict:
    """Gets the leaderboard from the given URL"""
    response = requests.get(url)
    if response.status_code != 200:
        raise Exception("Failed to get leaderboard")
    return json.loads(response.text)

if __name__ == "__main__":
    # Test the function
    url = "https://www.velocidrone.com/leaderboard_as_json2/0/6/888/1.16"
    print(get_leaderboard(url))
Ian-Boraks commented 1 year ago

https://github.com/RotorJackets/Goggle_Buzz/tree/Velocidrone