From 5c3c50a334ed52bf98b3101dc10d4bfdc132790d Mon Sep 17 00:00:00 2001 From: omg-xtao <100690902+omg-xtao@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:12:11 +0800 Subject: [PATCH] =?UTF-8?q?rate=20=E4=BF=AE=E5=A4=8D=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rate/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rate/main.py b/rate/main.py index 3c7616b7..aba28435 100644 --- a/rate/main.py +++ b/rate/main.py @@ -35,7 +35,7 @@ def __init__(self): "notice": "数据每日八点更新", "warning": "数据每日八点更新", } - self.host = "https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest" + self.host = "https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1" self.api = f"{self.host}/currencies.json" self.currencies = [] self.data = {} @@ -52,14 +52,14 @@ async def get_data(self): await log(f"Warning: plugin rate failed to refresh rates data. {e}") async def get_rate(self, from_: str, to_: str, nb: float): - endpoint = f"{self.host}/currencies/{from_.lower()}/{to_.lower()}.json" + endpoint = f"{self.host}/currencies/{from_.lower()}.json" try: req = await client.get(endpoint, follow_redirects=True) rate__data = req.json() return ( - f"`{from_} : {to_} = {nb} : {round(nb * rate__data[to_.lower()], 4)}`" + f"`{from_} : {to_} = {nb} : {round(nb * rate__data[from_.lower()][to_.lower()], 4)}`" f"\n\n" - f'{self.lang_rate["warning"]}' + f'{self.lang_rate["warning"]} - {rate__data["date"]}' ) except Exception as e: return str(e)