File size: 562 Bytes
345855e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 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" |