🐛 修复 api 接口变动
This commit is contained in:
parent
8187411481
commit
00f6e995a8
@ -19,3 +19,14 @@ def now_time() -> str:
|
||||
# UTC+8
|
||||
ts = ts + timedelta(hours=8)
|
||||
return ts.strftime("%Y/%m/%d %H:%M:%S")
|
||||
|
||||
|
||||
def strp_time(data: str) -> datetime:
|
||||
# data = "2021-07-17T09:14:05Z"
|
||||
if data:
|
||||
ts = datetime.strptime(data, date_format)
|
||||
else:
|
||||
return datetime.now()
|
||||
# UTC+8
|
||||
ts = ts + timedelta(hours=8)
|
||||
return ts
|
||||
|
@ -31,12 +31,17 @@ async def update_data() -> None:
|
||||
if exists(f"data{sep}modules.json"):
|
||||
copyfile(f"data{sep}modules.json", f"data{sep}old_modules.json")
|
||||
async with AsyncClient(timeout=10.0, headers=headers, follow_redirects=True) as client:
|
||||
data = await client.get("https://raw.githubusercontent.com/Xposed-Modules-Repo/modules/gh-pages/modules.json")
|
||||
data = await client.get("https://modules.lsposed.org/modules.json")
|
||||
modules_data = data.json()
|
||||
with open(f"data{sep}modules.json", "w", encoding="utf-8") as f:
|
||||
f.write(data.text)
|
||||
data = data.json()
|
||||
old_modules = new_modules
|
||||
new_modules = [Module(i) for i in data]
|
||||
new_modules = []
|
||||
for i in modules_data:
|
||||
try:
|
||||
new_modules.append(Module(i))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
new_modules_index.clear()
|
||||
for i in new_modules:
|
||||
new_modules_index[i.name] = i
|
||||
@ -56,7 +61,7 @@ async def download(url: str, name: str, pack_name: str) -> (str, str):
|
||||
async with AsyncClient(timeout=10.0, headers=headers, follow_redirects=True) as client:
|
||||
content = await client.get(url)
|
||||
if content.status_code == 404:
|
||||
content = (await client.get(f"https://raw.githubusercontent.com/Xposed-Modules-Repo/modules/gh-pages/module/{pack_name}.json")).json()
|
||||
content = (await client.get(f"https://modules.lsposed.org/module/{pack_name}.json")).json()
|
||||
data = Module(content)
|
||||
url = None
|
||||
if data.releases and data.releases[0].releaseAssets:
|
||||
|
@ -1,5 +1,6 @@
|
||||
from datetime import datetime
|
||||
from typing import List
|
||||
from defs.format_time import strf_time
|
||||
from defs.format_time import strf_time, strp_time
|
||||
|
||||
|
||||
class Assets:
|
||||
@ -14,6 +15,7 @@ class Release:
|
||||
self.url: str = data["url"]
|
||||
self.description: str = data["description"]
|
||||
self.publishedAt: str = strf_time(data["publishedAt"])
|
||||
self.publishedAtTime: datetime = strp_time(data["publishedAt"])
|
||||
self.tagName: str = data["tagName"]
|
||||
self.isPrerelease: bool = data["isPrerelease"]
|
||||
assets = []
|
||||
@ -40,10 +42,13 @@ class Module:
|
||||
else:
|
||||
text.append(i["login"])
|
||||
self.collaborators: List[str] = text
|
||||
self.latestRelease: str = data["latestRelease"]
|
||||
self.latestRelease: str = data.get("latestRelease")
|
||||
releases = []
|
||||
if data["releases"]:
|
||||
releases.extend(Release(i) for i in data["releases"])
|
||||
if data.get("betaReleases"):
|
||||
releases.extend(Release(i) for i in data["betaReleases"])
|
||||
releases.sort(key=lambda x: x.publishedAtTime, reverse=True)
|
||||
self.releases: List[Release] = releases
|
||||
self.updatedAt: str = releases[0].publishedAt if releases else strf_time(data["updatedAt"])
|
||||
self.summary: str = data["summary"] or ""
|
||||
|
@ -1,5 +1,5 @@
|
||||
Pyrogram>=2.0.40
|
||||
Tgcrypto>=1.2.3
|
||||
Pyrogram>=2.0.59
|
||||
Tgcrypto>=1.2.4
|
||||
httpx>=0.22.0
|
||||
apscheduler>=3.8.1
|
||||
sqlitedict>=2.0.0
|
||||
|
Loading…
Reference in New Issue
Block a user