FEAT: Enhance URL handling in Item class to support YouTube video IDs
This commit is contained in:
parent
551daf6b70
commit
ff9e173e18
1 changed files with 7 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
import logging
|
||||
import re
|
||||
import time
|
||||
import uuid
|
||||
from dataclasses import dataclass, field
|
||||
|
|
@ -115,6 +116,12 @@ class Item:
|
|||
msg = "url param is required."
|
||||
raise ValueError(msg)
|
||||
|
||||
url = url.strip()
|
||||
|
||||
# If it's only a YouTube video ID, convert to a full URL.
|
||||
if len(url) >= 11 and re.fullmatch(r"[A-Za-z0-9_-]{11}", url):
|
||||
url = f"https://www.youtube.com/watch?v={url}"
|
||||
|
||||
data: dict[str, str] = {"url": url}
|
||||
|
||||
preset: str | None = item.get("preset")
|
||||
|
|
|
|||
Loading…
Reference in a new issue