studio / ingestion /classifiers.py
Ava2lon's picture
Upload 170 files
345855e verified
Raw
History Blame Contribute Delete
562 Bytes
import os
from urllib.parse import urlparse
def classify_source(source: str):
if not source:
raise Exception("Empty source")
if os.path.exists(source):
return "local"
if source.endswith(".mp4"):
return "direct"
domain = urlparse(source).netloc.lower()
if "youtube" in domain or "youtu.be" in domain:
return "youtube"
if "tiktok" in domain:
return "tiktok"
if "instagram" in domain:
return "instagram"
if "facebook" in domain:
return "facebook"
return "unknown"