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')