import os
from pathlib import Path
import shutil


def cache_file():
    cache_file = Path("cache_file")
    if cache_file.is_dir() == False:
        os.makedirs(cache_file)
        print('缓存目录不存在新建成功')
    else:
        shutil.rmtree(cache_file)
        print('缓存目录存在,删除缓存目录')
        os.makedirs(cache_file)
        print('删除后_新建缓存目录')

cache_file()

def Video_cache_file(Video_id):
    '''判断视频id文件是否存在,如果不存在则新建,并且新建子文件夹image
        如果文件夹存在,则删除文件夹,并且重新新建视频id文件夹,并且新建image子文件夹'''
    Video_id_file = Path("cache_file/"+Video_id)
    if Video_id_file.is_dir() == False:
        os.makedirs(Video_id_file)
        Video_id_file = Path("cache_file/" + Video_id + '/image')
        os.makedirs(Video_id_file)
    else:
        shutil.rmtree(Video_id_file)
        os.makedirs(Video_id_file)
        Video_id_file = Path("cache_file/" + Video_id + '/image')
        os.makedirs(Video_id_file)


Video_cache_file('976729037862800348')

Logo

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。

更多推荐