mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
fix get_video()
目前测试了下,至少-401的情况少了很多
This commit is contained in:
parent
1174b5cc7f
commit
32e8136f71
@ -1,8 +1,9 @@
|
|||||||
from utils.image_utils import BuildImage
|
from utils.image_utils import BuildImage
|
||||||
from configs.path_config import IMAGE_PATH
|
from configs.path_config import IMAGE_PATH
|
||||||
from utils.http_utils import AsyncHttpx
|
from utils.http_utils import AsyncHttpx, get_user_agent
|
||||||
# from bilibili_api import user
|
# from bilibili_api import user
|
||||||
from bilireq.user import get_user_info
|
from bilireq.user import get_user_info
|
||||||
|
from httpx import AsyncClient
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
|
||||||
@ -85,8 +86,7 @@ async def get_meta(media_id: int, auth=None, reqtype="both", **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
async def get_videos(
|
async def get_videos(
|
||||||
uid: int, tid: int = 0, pn: int = 1, keyword: str = "", order: str = "pubdate",
|
uid: int, tid: int = 0, pn: int = 1, keyword: str = "", order: str = "pubdate"
|
||||||
*, auth=None, reqtype="both", **kwargs
|
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
获取用户投该视频信息
|
获取用户投该视频信息
|
||||||
@ -99,17 +99,34 @@ async def get_videos(
|
|||||||
:param keyword: 搜索关键词
|
:param keyword: 搜索关键词
|
||||||
:param order: 排序方式,可以为 “pubdate(上传日期从新到旧), stow(收藏从多到少), click(播放量从多到少)”
|
:param order: 排序方式,可以为 “pubdate(上传日期从新到旧), stow(收藏从多到少), click(播放量从多到少)”
|
||||||
"""
|
"""
|
||||||
from bilireq.utils import get
|
from bilireq.utils import ResponseCodeError
|
||||||
|
|
||||||
url = f"{BASE_URL}/x/space/arc/search"
|
url = f"{BASE_URL}/x/space/arc/search"
|
||||||
|
headers = get_user_agent()
|
||||||
|
headers["Referer"] = f"https://space.bilibili.com/{uid}/video"
|
||||||
|
async with AsyncClient() as client:
|
||||||
|
r = await client.head(
|
||||||
|
"https://space.bilibili.com",
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
params = {
|
params = {
|
||||||
"mid": uid,
|
"mid": uid,
|
||||||
"ps": 30,
|
"ps": 30,
|
||||||
"tid": tid,
|
"tid": tid,
|
||||||
"pn": pn,
|
"pn": pn,
|
||||||
"keyword": keyword,
|
"keyword": keyword,
|
||||||
"order": order
|
"order": order,
|
||||||
}
|
}
|
||||||
return await get(url, params=params, auth=auth, reqtype=reqtype, **kwargs)
|
raw_json = (
|
||||||
|
await client.get(url, params=params, headers=headers, cookies=r.cookies)
|
||||||
|
).json()
|
||||||
|
if raw_json["code"] != 0:
|
||||||
|
raise ResponseCodeError(
|
||||||
|
code=raw_json["code"],
|
||||||
|
msg=raw_json["message"],
|
||||||
|
data=raw_json.get("data", None),
|
||||||
|
)
|
||||||
|
return raw_json["data"]
|
||||||
|
|
||||||
async def get_user_card(mid, photo: bool = False, auth=None, reqtype="both", **kwargs):
|
async def get_user_card(mid, photo: bool = False, auth=None, reqtype="both", **kwargs):
|
||||||
from bilireq.utils import get
|
from bilireq.utils import get
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user