forked from ruangrupa/konfluks
cal, vid: slugify instead of sanitize_name
This commit is contained in:
parent
40bf9416b8
commit
34d84dcde2
@ -3,6 +3,7 @@ import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlparse
|
||||
from slugify import slugify
|
||||
|
||||
import arrow
|
||||
import jinja2
|
||||
@ -111,12 +112,6 @@ def localize_time(date):
|
||||
)
|
||||
return localized_begins
|
||||
|
||||
def sanitize_name(name):
|
||||
sanitized = "".join([c if c.isalnum() or c == " " else "-" for c in name])
|
||||
if len(sanitized) > 20:
|
||||
return sanitized[:20]
|
||||
return sanitized
|
||||
|
||||
def create_event_post(post_dir, event):
|
||||
"""
|
||||
Create HUGO post based on calendar event metadata
|
||||
@ -193,7 +188,7 @@ def update_event_post(post_dir, event):
|
||||
|
||||
def main():
|
||||
for event in list(cal.events):
|
||||
post_name = sanitize_name(event.name) + "-" + event.uid
|
||||
post_name = slugify(event.name) + "-" + event.uid
|
||||
post_dir = os.path.join(output_dir, post_name)
|
||||
|
||||
if post_name not in existing_posts:
|
||||
|
@ -4,6 +4,7 @@ import json
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from slugify import slugify
|
||||
|
||||
import arrow
|
||||
import jinja2
|
||||
@ -97,12 +98,6 @@ 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)
|
||||
|
||||
@ -119,7 +114,7 @@ def main():
|
||||
existing_posts = os.listdir(output_dir)
|
||||
|
||||
for video_metadata in videos:
|
||||
post_name = sanitize_name(video_metadata["name"]) + "-" + video_metadata["uuid"]
|
||||
post_name = slugify(video_metadata["name"]) + "-" + video_metadata["uuid"]
|
||||
post_dir = os.path.join(output_dir, post_name)
|
||||
|
||||
if (
|
||||
|
Loading…
Reference in New Issue
Block a user