Fix the bug that mistakenly created a directory instead of a file
This commit is contained in:
@@ -84,6 +84,9 @@ def save_video(video_url: str, save_dir: str = "") -> str:
|
|||||||
if not save_dir:
|
if not save_dir:
|
||||||
save_dir = utils.storage_dir("cache_videos")
|
save_dir = utils.storage_dir("cache_videos")
|
||||||
|
|
||||||
|
if not os.path.exists(save_dir):
|
||||||
|
os.makedirs(save_dir)
|
||||||
|
|
||||||
url_without_query = video_url.split("?")[0]
|
url_without_query = video_url.split("?")[0]
|
||||||
url_hash = utils.md5(url_without_query)
|
url_hash = utils.md5(url_without_query)
|
||||||
video_id = f"vid-{url_hash}"
|
video_id = f"vid-{url_hash}"
|
||||||
|
|||||||
@@ -70,8 +70,6 @@ def storage_dir(sub_dir: str = ""):
|
|||||||
d = os.path.join(root_dir(), "storage")
|
d = os.path.join(root_dir(), "storage")
|
||||||
if sub_dir:
|
if sub_dir:
|
||||||
d = os.path.join(d, sub_dir)
|
d = os.path.join(d, sub_dir)
|
||||||
if not os.path.exists(d):
|
|
||||||
os.makedirs(d)
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user