copyrightgpt-v1 / idgen.py
hdcli's picture
sync project
10bc78d verified
Raw History Blame Contribute Delete
275 Bytes
import os
import base64
def new_video_id(length: int = 11) -> str:
"""Generate a YouTube-style random id, e.g. 'dQw4w9WgXcQ'."""
raw = os.urandom(length)
b64 = base64.urlsafe_b64encode(raw).decode("ascii")
b64 = b64.replace("=", "")
return b64[:length]