fix: detect platform on video create, remove hardcoded twitter default

This commit is contained in:
mini
2026-02-19 00:14:50 +08:00
parent 8e31c4b954
commit 62a51305c3
3 changed files with 16 additions and 4 deletions

View File

@@ -55,6 +55,17 @@ def _is_pornhub_url(url: str) -> bool:
return bool(PORNHUB_URL_RE.match(url))
def detect_platform(url: str) -> str:
"""Detect platform from URL."""
if _is_twitter_url(url):
return "twitter"
if _is_youtube_url(url):
return "youtube"
if _is_pornhub_url(url):
return "pornhub"
return "unknown"
def _is_twitter_url(url: str) -> bool:
return bool(TWITTER_URL_RE.match(url))
@@ -556,5 +567,5 @@ def download_video(url: str, format_id: str = "best", progress_callback=None) ->
"filename": os.path.basename(filename),
"file_path": filename,
"file_size": file_size,
"platform": "twitter",
"platform": detect_platform(url),
}