NanmiCoder/MediaCrawler · error · ValueError
Unable to parse video ID from URL: {url}
Error message
Unable to parse video ID from URL: {url} What it means
ValueError from parse_video_info_from_url (media_platform/kuaishou/help.py) when the input is neither a bare id (no http prefix and no kuaishou.com substring) nor a URL matching /short-video/[A-Za-z0-9_-]+. Kuaishou video permalinks live under /short-video/, so gallery, profile, or short-link (v.kuaishou.com) URLs without that segment fail.
Source
Thrown at media_platform/kuaishou/help.py:112
2. Pure video ID: "3x3zxz4mjrsc8ke"
Args:
url: Kuaishou video link or video ID
Returns:
VideoUrlInfo: Object containing video ID
"""
# If it doesn't contain http and doesn't contain kuaishou.com, consider it as pure ID
if not url.startswith("http") and "kuaishou.com" not in url:
return VideoUrlInfo(video_id=url, url_type="normal")
# Extract ID from standard video URL: /short-video/video_ID
video_pattern = r'/short-video/([a-zA-Z0-9_-]+)'
match = re.search(video_pattern, url)
if match:
video_id = match.group(1)
return VideoUrlInfo(video_id=video_id, url_type="normal")
raise ValueError(f"Unable to parse video ID from URL: {url}")
def parse_creator_info_from_url(url: str) -> CreatorUrlInfo:
"""
Parse creator ID from Kuaishou creator homepage URL
Supports the following formats:
1. Creator homepage: "https://www.kuaishou.com/profile/3x84qugg4ch9zhs"
2. Pure ID: "3x4sm73aye7jq7i"
Args:
url: Kuaishou creator homepage link or user_id
Returns:
CreatorUrlInfo: Object containing creator ID
"""
# If it doesn't contain http and doesn't contain kuaishou.com, consider it as pure ID
if not url.startswith("http") and "kuaishou.com" not in url:
return CreatorUrlInfo(user_id=url)
View on GitHub (pinned to d6f7c5bb90)
Solutions
- Pass the bare video id (e.g. '3xf8enb8dbj6uig') or the canonical https://www.kuaishou.com/short-video/<id> URL.
- Expand v.kuaishou.com short links to their final URL before parsing.
- In batch pipelines, pre-filter with the /short-video/ pattern and route other URLs elsewhere.
Example fix
# before
parse_video_info_from_url('https://v.kuaishou.com/abc123')
# after
resolved = await expand_short_link('https://v.kuaishou.com/abc123') # -> https://www.kuaishou.com/short-video/3x3zxz4mjrsc8ke
parse_video_info_from_url(resolved) Defensive patterns
Strategy: validation
Validate before calling
import re
KS_RE = re.compile(r'/short-video/[A-Za-z0-9_-]+')
def has_kuaishou_video_id(u: str) -> bool:
return bool(KS_RE.search(u)) or (not u.startswith('http') and 'kuaishou.com' not in u) Type guard
def is_parseable_ks_video(url: str) -> bool:
return bool(re.search(r'/short-video/[A-Za-z0-9_-]+', url)) or (not url.startswith('http') and 'kuaishou.com' not in url) Try / catch
try:
info = parse_video_info_from_url(url)
except ValueError:
logger.warning(f'skipping unparseable kuaishou url: {url}')
continue Prevention
- Expand v.kuaishou.com short links first
- Pass bare ids like '3xf8enb8dbj6uig' when available
- Pre-filter to /short-video/ URLs in batch crawls
When it happens
Trigger: Passing a 'https://v.kuaishou.com/xxx' share short link needing redirect expansion; a photo/gallery page URL; a www.kuaishou.com URL whose video path uses a different segment after a site redesign; an id string that happens to contain 'kuaishou.com' text.
Common situations: Pasting the mobile app's share link; crawling mixed pages where only some are short-video permalinks; upstream URL format drift.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Unable to parse video ID from URL: {url}
- Unable to parse creator ID from URL: {url}
- Unable to parse video ID from URL: {url}
- Unable to parse creator ID from URL: {url}
- Unable to parse creator ID from URL: {url}
AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15).
Data as JSON: /api/errors/7a73fe99ab63369b.
Report an issue: GitHub.