修改部分路径

This commit is contained in:
ClovertaTheTrilobita 2025-02-06 21:28:01 +08:00
parent ff560a392e
commit ef812ebba1
7 changed files with 26 additions and 17 deletions

View file

@ -43,6 +43,7 @@ class MajorArcana(Model):
await cls.bulk_create(Major_arcana_initial_data)
arcana = await cls.all()
tarots = random.choice(arcana)
print(tarots.image)
# 正位
if ints == 0:
return await MajorArcanaLog.insertTarotLog(tarots, user_id, tarots_img_path+tarots.image,"正位")

View file

@ -7,6 +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
chrome_options = Options()
chrome_options.add_argument("--headless")
@ -121,7 +122,7 @@ def video_download(file_url, cid):
# 检查请求是否成功
if response.status_code == 200:
# 将视频保存到本地文件
with open(f'./src/videos/file/{cid}.mp4', 'wb') as file:
with open(VIDEO_PATH / f'{cid}.mp4', 'wb') as file:
for chunk in response.iter_content(chunk_size=1024):
if chunk:
file.write(chunk)
@ -131,7 +132,7 @@ def video_download(file_url, cid):
def delete_video(cid):
# 指定要删除的文件路径
file_path = f"src/videos/file/{cid}.mp4"
file_path = VIDEO_PATH / f"{cid}.mp4"
# 检查文件是否存在
if os.path.exists(file_path):

View file

@ -17,7 +17,7 @@ ju_he_image_list= "https://api.superbed.cn/timeline" # 聚合图床获取上传
"""
AI
"""
admin_password= "123456"#默认注册管理员密码
admin_password= "123456" # 默认注册管理员密码
# 图灵机器人相关配置
v3url= "https://api.vveai.com/v1/chat/completions"
v3key= "<KEY>"

View file

@ -16,21 +16,23 @@ rua_png = path+'/rua/'
# 图片路径
IMAGE_PATH = Path() / "resources" / "image"
IMAGE_PATH = Path() / "src" / "resources" / "image"
# 语音路径
RECORD_PATH = Path() / "resources" / "record"
RECORD_PATH = Path() / "src" / "resources" / "record"
# 文本路径
TEXT_PATH = Path() / "resources" / "text"
TEXT_PATH = Path() / "src" / "resources" / "text"
# 日志路径
LOG_PATH = Path() / "log"
LOG_PATH = Path() / "src" / "log"
# 字体路径
FONT_PATH = Path() / "resources" / "font"
FONT_PATH = Path() / "src" / "resources" / "font"
# 数据路径
DATA_PATH = Path() / "data"
DATA_PATH = Path() / "src" / "data"
# 临时数据路径
TEMP_PATH = Path() / "resources" / "temp"
TEMP_PATH = Path() / "src" / "resources" / "temp"
# 网页模板路径
TEMPLATE_PATH = Path() / "resources" / "template"
TEMPLATE_PATH = Path() / "src" / "resources" / "template"
# 视频路径
VIDEO_PATH = Path() / "src" / "resources" / "videos"
# IMAGE_PATH.mkdir(parents=True, exist_ok=True)

View file

@ -1,11 +1,14 @@
# https://api.bilibili.com/x/web-interface/search/type?keyword=av28465342&search_type=video&page=1
import time
from pathlib import Path
import nonebot.adapters.qq.exception
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
bili_vid = on_command("B站搜索",rule=to_me(), priority=10, block=True)
@bili_vid.handle()
@ -67,10 +70,10 @@ async def get_video_file(message: MessageEvent):
cid = pages[0]['cid']
video_url = biliVideos.get_video_file_url(keyword[0], cid)
# biliVideos.video_download(video_url, cid)
# biliVideos.transcode_video(f"{cid}.mp4",f"{cid}-o.mp4")
# 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(f"./src/clover_videos/file/{cid}.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))
@ -100,9 +103,10 @@ async def get_video_file(message: MessageEvent):
cid = pages[page_num - 1]['cid']
video_url = biliVideos.get_video_file_url(keyword[0], cid)
# biliVideos.video_download(video_url, cid)
# biliVideos.transcode_video(VIDEO_PATH / f"{cid}.mp4", VIDEO_PATH / f"{cid}-o.mp4")
try:
# await bili_bv_search.send(Message(MessageSegment.file_video(Path(f"./src/clover_videos/file/{cid}.mp4"))))
# await bili_bv_search.send(Message(MessageSegment.file_video(Path(VIDEO_PATH / f"{cid}.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")) +

View file

@ -3,6 +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
cf_query = on_command("cf", rule=to_me(), priority=10, block=True)
@cf_query.handle()
@ -24,7 +25,7 @@ async def get_cf_rounds():
if matches["phase"] == "FINISHED":
break
cf_image_path = './src/resources/clover_image/codeforces/cfContestQR.png'
cf_image_path = IMAGE_PATH / "codeforces" / "cfContestQR.png"
msg = Message([
MessageSegment.file_image(Path(cf_image_path)),
MessageSegment.text(all_matches),

View file

@ -4,7 +4,7 @@ from nonebot.rule import to_me
from nonebot.plugin import on_command
from nonebot.adapters.qq import Message, MessageEvent, MessageSegment,exception
from src.clover_image.get_image import get_image_names
from src.clover_sqlite.models.fortune import QrFortune,QrFortuneLog
from src.clover_sqlite.models.fortune import QrFortune, QrFortuneLog
from src.clover_sqlite.models.tarot import MajorArcana
import time
@ -54,4 +54,4 @@ async def get_tarot(message: MessageEvent):
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))
await tarot.finish("您的塔罗被未来人抢走啦,请重试。这绝对不是咱的错,绝对不是!")
await tarot.finish("您的塔罗被未来人抢走啦,请重试。这绝对不是咱的错,绝对不是!")