Download ingest.py from hdcli/copyrightgpt-v1: direct link, hf CLI and curl.
- Browser
- Download file 998 Bytes
-
https://huggingface.co/datasets/hdcli/copyrightgpt-v1/resolve/main/ingest.py
- Command line
-
hf download hf://datasets/hdcli/copyrightgpt-v1/ingest.py
-
curl -L -o ingest.py https://huggingface.co/datasets/hdcli/copyrightgpt-v1/resolve/main/ingest.py
998 Bytes
| """Add a video to the dataset: fingerprint it and store it under an id.""" | |
| import os | |
| import storage | |
| from fingerprint import extract_fingerprint, video_duration_seconds | |
| from idgen import new_video_id | |
| def ingest_video(source_path: str, title: str | None = None, samples_per_second: float = 1.0, video_id: str | None = None) -> dict: | |
| """Ingest a video. Pass video_id to append a new patch to an existing | |
| entry instead of creating a new one.""" | |
| if not os.path.isfile(source_path): | |
| raise FileNotFoundError(source_path) | |
| fingerprint = extract_fingerprint(source_path, samples_per_second=samples_per_second) | |
| duration = video_duration_seconds(source_path) | |
| title = title or os.path.basename(source_path) | |
| video_id = video_id or new_video_id() | |
| meta = storage.add_video_patch( | |
| video_id=video_id, | |
| title=title, | |
| source_path=os.path.abspath(source_path), | |
| duration_seconds=duration, | |
| fingerprint=fingerprint, | |
| ) | |
| return meta | |