diff --git a/lumbunglib/video.py b/lumbunglib/video.py index 4194467..327c4e7 100644 --- a/lumbunglib/video.py +++ b/lumbunglib/video.py @@ -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