Azide e2a97a9e56
适配小刻食堂平台 (#379)
* 🐛 插入新的Schedulable时应传入use_batch参数

*  适配ceobecanteen平台

Co-authored-by: phidiaLam <2957035701@qq.com>

*   明日方舟公告与官网采用截图分享 (#480)

*  明日方舟公告与官网采用截图分享

* 💄 auto fix by pre-commit hooks

* 🐛 修复缺少的导入,优化逻辑

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Azide <rukuy@qq.com>

* 🐛 优化截图图片效果

* 🐛 修复错误将转发内图片视作头图的问题

* 🍱 使用正式 Bison Logo

* 💄 auto fix by pre-commit hooks

* 🐛 请求小刻API时不在headers里添加过多字段

* 🐛 get_comb_id方法删除无用的targets参数

* 💡 get_comb_id方法更新注释

* 🔥 移除发送部分的更改

*  在命名中明确表示cond_func意图

* ♻️ 拆分get_comb_id功能

* ♻️ 调整缓存逻辑

*  使用uri在theme中调用platform截图

* ♻️ 重构截图逻辑

*  添加模糊匹配提示

*  适配新版Site

* 💄 auto fix by pre-commit hooks

* 🐛 去掉不必要的排序

* 🐛 修正不应出现的驼峰变量名

* ♻️ 按review意见修改

* ♻️ 调整截图函数逻辑

* 🔊 调低日志等级

* ✏️ 修复一些拼写和格式

---------

Co-authored-by: phidiaLam <2957035701@qq.com>
Co-authored-by: 洛梧藤 <67498817+phidiaLam@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-13 01:06:42 +08:00

128 lines
2.7 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from typing import Literal, TypeVar, NamedTuple
from pydantic import BaseModel
class CeobeTextPic(NamedTuple):
text: str
pics: list[bytes | str]
class CeobeTarget(BaseModel):
"""账户结构"""
avatar: str
"""数据源头像"""
datasource: str
"""数据源类型"""
db_unique_key: str
"""数据源相关唯一id"""
nickname: str
"""数据源昵称"""
platform: str
"""平台代码"""
unique_id: str
"""数据源唯一标识(用于前后端交互标识)"""
jump_url: str | None = None
"""跳转urlnull就是没办法跳转"""
class DataSourceResponse(BaseModel):
code: int
message: str
data: list[CeobeTarget]
class CeobeImage(BaseModel):
origin_url: str
"""原图"""
compress_url: str | None = None
"""压缩图为null就是没有原图对应压缩图"""
class CeobeDefaultCookie(BaseModel):
text: str
images: list[CeobeImage] | None
class CeobeRetweeted(BaseModel):
author_name: str
author_avatar: str
text: str
images: list[CeobeImage] | None = None
class CeobeItem(BaseModel):
id: str
"""单条id"""
url: str
"""跳转链接"""
type: str | None = None
"""类型"""
is_long_text: bool | None = None
"""是否长文"""
is_retweeted: bool = False
"""是否转发"""
retweeted: CeobeRetweeted | None = None
"""展示类型,公告类型的数据源有这个字段"""
display_type: int | None = None
class Config:
extra = "allow"
class CeobeSource(BaseModel):
data: str
"""数据源id"""
type: str
"""数据源类型"""
class CeobeTimestamp(BaseModel):
fetcher: int
"""蹲饼时间,毫秒"""
platform_precision: Literal["none", "day", "hour", "minute", "second", "ms"]
"""平台时间精度不足的长度补0"""
platform: int | None = None
"""平台时间戳,毫秒"""
class CeobeCookie(BaseModel):
datasource: str
"""数据源名字"""
icon: str
"""数据源头像"""
timestamp: CeobeTimestamp
"""时间戳"""
default_cookie: CeobeDefaultCookie
"""原始饼"""
item: CeobeItem
"""数据源信息,有平台的特殊字段"""
source: CeobeSource
"""数据源"""
class CeobeData(BaseModel):
cookies: list[CeobeCookie]
next_page_id: str | None = None
class CookiesResponse(BaseModel):
code: int
message: str
data: CeobeData
class CombIdResponse(BaseModel):
code: int
message: str
data: dict[Literal["datasource_comb_id"], str]
class CookieIdResponse(BaseModel):
cookie_id: str
update_cookie_id: str
ResponseModel = TypeVar("ResponseModel", bound=CookiesResponse | CombIdResponse | CookieIdResponse | DataSourceResponse)