22 lines
644 B
Python
22 lines
644 B
Python
import time as time_
|
|
from typing import List
|
|
|
|
from ci import client, sqlite
|
|
from defs.model import New
|
|
|
|
|
|
async def get_news() -> List[New]:
|
|
time = sqlite.get("update_time", time_.time() - 600)
|
|
url = f"https://papi.jiemian.com/page/api/kuaixun/getLastest?cid=1325kb&end_time={time}&tagid=1325"
|
|
data = await client.get(url)
|
|
if data.status_code != 200:
|
|
return []
|
|
data = data.json()
|
|
data = [New(**i) for i in data.get("result", [])]
|
|
update_time = 0
|
|
for new in data:
|
|
if new.publish_time > update_time:
|
|
update_time = new.publish_time
|
|
sqlite["update_time"] = update_time
|
|
return data
|