Download idgen.py from hdcli/copyrightgpt-v1: direct link, hf CLI and curl.
- Browser
- Download file 275 Bytes
-
https://huggingface.co/datasets/hdcli/copyrightgpt-v1/resolve/main/idgen.py
- Command line
-
hf download hf://datasets/hdcli/copyrightgpt-v1/idgen.py
-
curl -L -o idgen.py https://huggingface.co/datasets/hdcli/copyrightgpt-v1/resolve/main/idgen.py
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] | |