NanmiCoder/MediaCrawler · error · ValueError
Unable to parse creator ID from URL: {url}
Error message
Unable to parse creator ID from URL: {url} What it means
ValueError from parse_creator_info_from_url (media_platform/bilibili/help.py) when the input is neither an all-digit string (pure UID) nor a URL matching space.bilibili.com/(\d+). Bilibili space IDs are numeric, so any non-digit slug, username-style URL, or malformed share link falls through to this raise.
Source
Thrown at media_platform/bilibili/help.py:131
- https://space.bilibili.com/20813884
- 434377496 (directly pass UID)
Returns:
CreatorUrlInfo: Object containing creator ID
"""
# If the input is already a numeric ID, return directly
if url.isdigit():
return CreatorUrlInfo(creator_id=url)
# Use regex to extract UID
# Match /space.bilibili.com/number format
uid_pattern = r'space\.bilibili\.com/(\d+)'
match = re.search(uid_pattern, url)
if match:
creator_id = match.group(1)
return CreatorUrlInfo(creator_id=creator_id)
raise ValueError(f"Unable to parse creator ID from URL: {url}")
if __name__ == '__main__':
# Test video URL parsing
video_url1 = "https://www.bilibili.com/video/BV1dwuKzmE26/?spm_id_from=333.1387.homepage.video_card.click"
video_url2 = "BV1d54y1g7db"
print("Video URL parsing test:")
print(f"URL1: {video_url1} -> {parse_video_info_from_url(video_url1)}")
print(f"URL2: {video_url2} -> {parse_video_info_from_url(video_url2)}")
# Test creator URL parsing
creator_url1 = "https://space.bilibili.com/434377496?spm_id_from=333.1007.0.0"
creator_url2 = "20813884"
print("\nCreator URL parsing test:")
print(f"URL1: {creator_url1} -> {parse_creator_info_from_url(creator_url1)}")
print(f"URL2: {creator_url2} -> {parse_creator_info_from_url(creator_url2)}")
View on GitHub (pinned to d6f7c5bb90)
Solutions
- Pass the numeric UID directly ('434377496') or the full space URL 'https://space.bilibili.com/434377496'.
- Pre-validate with a digit check or the space.bilibili.com regex before calling.
- Trim/normalize user input (strip whitespace) before parsing.
Example fix
# before
parse_creator_info_from_url(' 434377496\n')
# after
parse_creator_info_from_url('434377496') Defensive patterns
Strategy: validation
Validate before calling
import re
SPACE_RE = re.compile(r'space\.bilibili\.com/(\d+)')
def extract_bili_uid(u: str) -> str | None:
u = u.strip()
if u.isdigit():
return u
m = SPACE_RE.search(u)
return m.group(1) if m else None Type guard
def is_parseable_bili_creator(u: str) -> bool:
u = u.strip()
return u.isdigit() or bool(re.search(r'space\.bilibili\.com/\d+', u)) Try / catch
try:
info = parse_creator_info_from_url(url.strip())
except ValueError:
logger.warning(f'not a numeric bilibili space id/url: {url}') Prevention
- Bilibili creator ids are numeric — validate digits before calling
- Strip whitespace from user-pasted input
- Don't feed usernames or vanity names; only UIDs and space.bilibili.com/<uid> URLs
When it happens
Trigger: Passing a space URL with a non-numeric path (rare vanity/legacy forms); an empty or whitespace-only string failing url.isdigit(); a URL like 'https://space.bilibili.com/' with no ID; query-only strings where the digits sit in a param instead of the path.
Common situations: Copy-pasting creator links that got truncated at the digits; feeding a username or display name instead of the numeric UID; leading/trailing spaces or a '\n' smuggled in from CSV input.
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 creator ID from URL: {url}
- Wrong time range, please check your start and end argument,
- [BilibiliLogin.begin] Invalid Login Type Currently only supp
AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15).
Data as JSON: /api/errors/8f50cdac67fb9daa.
Report an issue: GitHub.