video: use video title for filename

This commit is contained in:
knoflook 2022-02-03 16:09:05 +01:00
parent a4f22b95b7
commit 77b8c9e0af
Signed by untrusted user: knoflook
GPG Key ID: D6A1D0E8FC4FEF1C

View File

@ -97,6 +97,11 @@ def update_post(post_directory, video_metadata, host):
# compat for when there is no timestamp yet..
create_post(post_directory, video_metadata, host)
def sanitize_name(name):
sanitized = "".join([c if c.isalnum() or c == " " else "-" for c in name])
if len(sanitized) > 40:
return sanitized[:40]
return sanitized
def main():
v = peertube.VideoApi(client)
@ -114,7 +119,7 @@ def main():
existing_posts = os.listdir(output_dir)
for video_metadata in videos:
post_dir = os.path.join(output_dir, video_metadata["uuid"])
post_dir = os.path.join(output_dir, sanitize_name(video_metadata["name"]) + "-" + video_metadata["uuid"])
if (
video_metadata["uuid"] not in existing_posts