{"record":{"id":"7a73fe99ab63369b","repo":"NanmiCoder/MediaCrawler","slug":"unable-to-parse-video-id-from-url-url-7a73fe","errorCode":null,"errorMessage":"Unable to parse video ID from URL: {url}","messagePattern":"Unable to parse video ID from URL: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"media_platform/kuaishou/help.py","lineNumber":112,"sourceCode":"    2. Pure video ID: \"3x3zxz4mjrsc8ke\"\n\n    Args:\n        url: Kuaishou video link or video ID\n    Returns:\n        VideoUrlInfo: Object containing video ID\n    \"\"\"\n    # If it doesn't contain http and doesn't contain kuaishou.com, consider it as pure ID\n    if not url.startswith(\"http\") and \"kuaishou.com\" not in url:\n        return VideoUrlInfo(video_id=url, url_type=\"normal\")\n\n    # Extract ID from standard video URL: /short-video/video_ID\n    video_pattern = r'/short-video/([a-zA-Z0-9_-]+)'\n    match = re.search(video_pattern, url)\n    if match:\n        video_id = match.group(1)\n        return VideoUrlInfo(video_id=video_id, url_type=\"normal\")\n\n    raise ValueError(f\"Unable to parse video ID from URL: {url}\")\n\n\ndef parse_creator_info_from_url(url: str) -> CreatorUrlInfo:\n    \"\"\"\n    Parse creator ID from Kuaishou creator homepage URL\n    Supports the following formats:\n    1. Creator homepage: \"https://www.kuaishou.com/profile/3x84qugg4ch9zhs\"\n    2. Pure ID: \"3x4sm73aye7jq7i\"\n\n    Args:\n        url: Kuaishou creator homepage link or user_id\n    Returns:\n        CreatorUrlInfo: Object containing creator ID\n    \"\"\"\n    # If it doesn't contain http and doesn't contain kuaishou.com, consider it as pure ID\n    if not url.startswith(\"http\") and \"kuaishou.com\" not in url:\n        return CreatorUrlInfo(user_id=url)\n","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/media_platform/kuaishou/help.py#L94-L130","documentation":"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.","triggerScenarios":"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.","commonSituations":"Pasting the mobile app's share link; crawling mixed pages where only some are short-video permalinks; upstream URL format drift.","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."],"exampleFix":"# before\nparse_video_info_from_url('https://v.kuaishou.com/abc123')\n\n# after\nresolved = await expand_short_link('https://v.kuaishou.com/abc123')  # -> https://www.kuaishou.com/short-video/3x3zxz4mjrsc8ke\nparse_video_info_from_url(resolved)","handlingStrategy":"validation","validationCode":"import re\nKS_RE = re.compile(r'/short-video/[A-Za-z0-9_-]+')\ndef has_kuaishou_video_id(u: str) -> bool:\n    return bool(KS_RE.search(u)) or (not u.startswith('http') and 'kuaishou.com' not in u)","typeGuard":"def is_parseable_ks_video(url: str) -> bool:\n    return bool(re.search(r'/short-video/[A-Za-z0-9_-]+', url)) or (not url.startswith('http') and 'kuaishou.com' not in url)","tryCatchPattern":"try:\n    info = parse_video_info_from_url(url)\nexcept ValueError:\n    logger.warning(f'skipping unparseable kuaishou url: {url}')\n    continue","preventionTips":["Expand v.kuaishou.com short links first","Pass bare ids like '3xf8enb8dbj6uig' when available","Pre-filter to /short-video/ URLs in batch crawls"],"tags":["kuaishou","url-parsing","valueerror","short-link"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}