{"record":{"id":"52f649c4d79655cb","repo":"NanmiCoder/MediaCrawler","slug":"unable-to-parse-video-id-from-url-url","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/bilibili/help.py","lineNumber":104,"sourceCode":"            - https://www.bilibili.com/video/BV1d54y1g7db\n            - BV1d54y1g7db (directly pass BV number)\n    Returns:\n        VideoUrlInfo: Object containing video ID\n    \"\"\"\n    # If the input is already a BV number, return directly\n    if url.startswith(\"BV\"):\n        return VideoUrlInfo(video_id=url)\n\n    # Use regex to extract BV number\n    # Match /video/BV... or /video/av... format\n    bv_pattern = r'/video/(BV[a-zA-Z0-9]+)'\n    match = re.search(bv_pattern, url)\n\n    if match:\n        video_id = match.group(1)\n        return VideoUrlInfo(video_id=video_id)\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 Bilibili creator space URL\n    Args:\n        url: Bilibili creator space link\n            - https://space.bilibili.com/434377496?spm_id_from=333.1007.0.0\n            - https://space.bilibili.com/20813884\n            - 434377496 (directly pass UID)\n    Returns:\n        CreatorUrlInfo: Object containing creator ID\n    \"\"\"\n    # If the input is already a numeric ID, return directly\n    if url.isdigit():\n        return CreatorUrlInfo(creator_id=url)\n\n    # Use regex to extract UID","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/media_platform/bilibili/help.py#L86-L122","documentation":"ValueError from parse_video_info_from_url (media_platform/bilibili/help.py) when a video URL matches neither the bare 'BV...' prefix form nor the /video/BV<alphanumeric> regex. Bilibili video IDs are BV-series strings, so URLs of any other shape (av-number URLs, short links b23.tv, plain digits) are unsupported by this parser.","triggerScenarios":"Passing 'https://www.bilibili.com/video/av1701' (av form, no BV); a b23.tv short link that needs expansion first; an empty string or a URL whose /video/ segment uses lowercase 'bv'; a 'BV' ID longer/different in charset than [a-zA-Z0-9].","commonSituations":"User-supplied URLs from shares/clipboard that use short links or legacy av format; data pipelines feeding historical av IDs; trailing whitespace breaking the startswith('BV') check.","solutions":["Use the canonical URL form https://www.bilibili.com/video/BVxxxxxxxx or pass the bare BV id.","Expand b23.tv short links first (follow redirects) and retry with the resolved URL.","Convert av IDs to BV form before parsing if your source only has av numbers.","Strip whitespace and validate the shape before calling."],"exampleFix":"# before\nparse_video_info_from_url('https://b23.tv/abc123')\n\n# after\nresolved = await expand_short_link('https://b23.tv/abc123')  # -> https://www.bilibili.com/video/BV1dwuKzmE26/...\nparse_video_info_from_url(resolved)","handlingStrategy":"validation","validationCode":"import re\nBV_RE = re.compile(r'^(BV[a-zA-Z0-9]+)$|/video/(BV[a-zA-Z0-9]+)')\ndef looks_like_bilibili_video(u: str) -> bool:\n    return bool(BV_RE.search(u.strip()))","typeGuard":"def is_parseable_bili_video(url: str) -> bool:\n    url = url.strip()\n    return url.startswith('BV') or bool(re.search(r'/video/BV[a-zA-Z0-9]+', url))","tryCatchPattern":"try:\n    info = parse_video_info_from_url(url)\nexcept ValueError:\n    logger.warning(f'skipping unparseable bilibili url: {url}')\n    continue  # batch crawl: skip, don't abort","preventionTips":["Expand b23.tv short links before parsing","Convert av ids to BV ids upstream","Skip-and-log unparseable URLs in batch jobs instead of failing the run"],"tags":["bilibili","url-parsing","valueerror","validation"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}