feat: Add automatic short link resolution for b23.tv
- Use requests library to follow redirects and resolve b23.tv short links - Automatically extract BV ID from resolved URL - Support both short links and full URLs seamlessly
This commit is contained in:
@@ -64,7 +64,14 @@ class LinkParser:
|
|||||||
"""
|
"""
|
||||||
# Check if it's a known short link pattern
|
# Check if it's a known short link pattern
|
||||||
if self.shortlink_resolver.is_bilibili_short_link(url):
|
if self.shortlink_resolver.is_bilibili_short_link(url):
|
||||||
return url
|
# Try to resolve using requests (follows redirects)
|
||||||
|
try:
|
||||||
|
import requests
|
||||||
|
response = requests.head(url, allow_redirects=True, timeout=10)
|
||||||
|
return response.url
|
||||||
|
except Exception:
|
||||||
|
# Fallback: return original URL
|
||||||
|
return url
|
||||||
|
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user