fix: detect platform on video create, remove hardcoded twitter default
This commit is contained in:
@@ -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),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user