2024-08-22 22:50:18 +08:00
|
|
|
|
import os
|
2024-07-11 18:26:21 +08:00
|
|
|
|
import random
|
2024-08-08 20:50:18 +08:00
|
|
|
|
import datetime
|
2024-08-24 17:44:52 +08:00
|
|
|
|
from pathlib import Path
|
|
|
|
|
from .config import config
|
2024-08-22 22:50:18 +08:00
|
|
|
|
|
2024-08-15 18:22:29 +08:00
|
|
|
|
|
2024-08-22 22:50:18 +08:00
|
|
|
|
def choose_random_bgimage() -> str:
|
|
|
|
|
"""
|
|
|
|
|
从背景图片文件夹中随机选择一张图片,返回图片的uri地址
|
|
|
|
|
"""
|
2024-08-24 17:44:52 +08:00
|
|
|
|
bgpath = Path(config.acgnshow_bgimage_path)
|
|
|
|
|
randomfile = random.choice(os.listdir(bgpath))
|
|
|
|
|
randomurl = (bgpath / randomfile).as_uri()
|
2024-08-08 20:50:18 +08:00
|
|
|
|
return randomurl
|
2024-08-15 18:22:29 +08:00
|
|
|
|
|
|
|
|
|
|
2024-08-22 22:50:18 +08:00
|
|
|
|
def convert_timestamp(timestamp) -> str:
|
|
|
|
|
"""
|
|
|
|
|
将时间戳转换为日期格式
|
|
|
|
|
"""
|
|
|
|
|
return datetime.datetime.fromtimestamp(timestamp).strftime("%Y-%m-%d %H:%M:%S")
|