ruff format
All checks were successful
Garfbot CI/CD Deployment / Deploy (push) Successful in 15s

This commit is contained in:
2026-06-26 19:24:36 -05:00
parent 284e4f92fe
commit dbbfbd638f
6 changed files with 176 additions and 75 deletions

View File

@@ -42,18 +42,19 @@ weather = WeatherAPI()
URL_PATTERNS = [
r'https?://(?:www\.)?youtube\.com/watch\?[^\s]*',
r'https?://youtu\.be/[^\s]*',
r'https?://(?:open\.)?spotify\.com/[^\s]*',
r"https?://(?:www\.)?youtube\.com/watch\?[^\s]*",
r"https?://youtu\.be/[^\s]*",
r"https?://(?:open\.)?spotify\.com/[^\s]*",
]
def clean_url(url):
try:
parsed = urlparse(url)
if 'youtube.com' in parsed.hostname:
if "youtube.com" in parsed.hostname:
params = parse_qs(parsed.query)
video_id = params.get('v', [None])[0]
video_id = params.get("v", [None])[0]
if not video_id:
return None
# timestamp = params.get('t', [None])[0]
@@ -61,15 +62,15 @@ def clean_url(url):
# return f"https://www.youtube.com/watch?v={video_id}&t={timestamp}"
return f"https://www.youtube.com/watch?v={video_id}"
if 'youtu.be' in parsed.hostname:
if "youtu.be" in parsed.hostname:
return f"https://youtu.be{parsed.path}"
if 'spotify.com' in parsed.hostname:
if "spotify.com" in parsed.hostname:
return f"https://open.spotify.com{parsed.path}"
except Exception:
return None
@garfbot.event
async def on_ready():