mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-04-01 22:04:51 +00:00
修复路径丢失问题
This commit is contained in:
parent
9e0360a0a2
commit
de02fb3597
3 changed files with 10 additions and 9 deletions
|
|
@ -7,7 +7,7 @@ import hashlib
|
|||
import urllib.parse
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
from src.configs.path_config import VIDEO_PATH
|
||||
from src.configs.path_config import video_path
|
||||
|
||||
chrome_options = Options()
|
||||
chrome_options.add_argument("--headless")
|
||||
|
|
@ -118,12 +118,13 @@ def get_video_file_url(bvid, cid):
|
|||
return file_url
|
||||
|
||||
def video_download(file_url, cid):
|
||||
response = requests.get(file_url, headers=headers)
|
||||
response = requests.get(file_url, headers=headers,stream=True)
|
||||
|
||||
# 检查请求是否成功
|
||||
if response.status_code == 200:
|
||||
# 将视频保存到本地文件
|
||||
with open(VIDEO_PATH / f'{cid}.mp4', 'wb') as file:
|
||||
for chunk in response.iter_content(chunk_size=1024):
|
||||
with open(video_path + f'/{cid}.mp4', 'wb') as file:
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
if chunk:
|
||||
file.write(chunk)
|
||||
print("视频下载完成")
|
||||
|
|
@ -132,7 +133,7 @@ def video_download(file_url, cid):
|
|||
|
||||
def delete_video(cid):
|
||||
# 指定要删除的文件路径
|
||||
file_path = VIDEO_PATH / f"{cid}.mp4"
|
||||
file_path = video_path + f"/{cid}.mp4"
|
||||
|
||||
# 检查文件是否存在
|
||||
if os.path.exists(file_path):
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from nonebot import on_command
|
|||
from nonebot.rule import to_me
|
||||
from nonebot.adapters.qq import MessageSegment,MessageEvent, Message
|
||||
import src.clover_videos.billibili.biliVideos as biliVideos
|
||||
from src.configs.path_config import VIDEO_PATH
|
||||
from src.configs.path_config import video_path
|
||||
|
||||
bili_vid = on_command("B站搜索",rule=to_me(), priority=10, block=True)
|
||||
@bili_vid.handle()
|
||||
|
|
@ -73,7 +73,7 @@ async def get_video_file(message: MessageEvent):
|
|||
# biliVideos.transcode_video(f"./src/resources/videos/{cid}.mp4",f"./src/resources/videos/{cid}-o.mp4")
|
||||
|
||||
try:
|
||||
# await bili_bv_search.send(Message(MessageSegment.file_video(Path(VIDEO_PATH / f"{cid}-o.mp4"))))
|
||||
# await bili_bv_search.send(Message(MessageSegment.file_video(Path(video_path + f"/{cid}-o.mp4"))))
|
||||
await bili_bv_search.send(MessageSegment.video(video_url))
|
||||
except nonebot.adapters.qq.exception.ActionFailed as e:
|
||||
print("\033[32m" + str(time.strftime("%m-%d %H:%M:%S")) +"\033[0m [" + "\033[31;1mFAILED\033[0m" + "]" + "\033[31;1m nonebot.adapters.qq.exception.ActionFailed \033[0m" + str(e))
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from nonebot.plugin import on_command
|
|||
from nonebot.rule import to_me
|
||||
from nonebot.adapters.qq import Message, MessageEvent, MessageSegment
|
||||
from pathlib import Path
|
||||
from src.configs.path_config import IMAGE_PATH
|
||||
from src.configs.path_config import path
|
||||
|
||||
cf_query = on_command("cf", rule=to_me(), priority=10, block=True)
|
||||
@cf_query.handle()
|
||||
|
|
@ -25,7 +25,7 @@ async def get_cf_rounds():
|
|||
if matches["phase"] == "FINISHED":
|
||||
break
|
||||
|
||||
cf_image_path = IMAGE_PATH / "codeforces" / "cfContestQR.png"
|
||||
cf_image_path = path + "/image/codeforces/cfContestQR.png"
|
||||
msg = Message([
|
||||
MessageSegment.file_image(Path(cf_image_path)),
|
||||
MessageSegment.text(all_matches),
|
||||
|
|
|
|||
Loading…
Reference in a new issue