soimort/you-get · error · Exception
Unknown pattern
Error message
Unknown pattern
What it means
Fallback path in miaopai_download: when the URL has no ?fid= and no /p/230444 marker, the extractor fetches the page with mobile headers and looks for r'"page_url"\s*:\s*"([^"]+)"' in the HTML. If that JSON key is absent (redesign, JS-rendered content, bot wall), it raises Exception('Unknown pattern') — the extractor has no remaining strategy to locate the video.
Source
Thrown at src/you_get/extractors/miaopai.py:175
if re.match(r'^http[s]://(.+\.)?weibo\.com/(tv/)?show/(\d{4}:\w+)', url):
return miaopai_download_h5api(url, info_only=info_only, output_dir=output_dir, merge=merge, **kwargs)
if re.match(r'^http[s]://(.+\.)?weibo\.com/show\?fid=(\d{4}:\w+)', url):
return miaopai_download_h5api(url, info_only=info_only, output_dir=output_dir, merge=merge, **kwargs)
fid = match1(url, r'\?fid=(\d{4}:\w+)')
if fid is not None:
miaopai_download_by_fid(fid, output_dir, merge, info_only)
elif '/p/230444' in url:
fid = match1(url, r'/p/230444(\w+)')
miaopai_download_by_fid('1034:'+fid, output_dir, merge, info_only)
pass
else:
mobile_page = get_content(url, headers = fake_headers_mobile)
hit = re.search(r'"page_url"\s*:\s*"([^"]+)"', mobile_page)
if not hit:
raise Exception('Unknown pattern')
else:
escaped_url = hit.group(1)
miaopai_download(urllib.parse.unquote(escaped_url), output_dir=output_dir, merge=merge, info_only=info_only, **kwargs)
site_info = "miaopai"
download = miaopai_download
download_playlist = playlist_not_supported('miaopai')
View on GitHub (pinned to 049548f3f3)
Solutions
- Prefer the explicit fid form: append/extract ?fid= or use the /p/230444 URL form which take the earlier branches
- Inspect mobile_page content in a debugger to see what was actually returned (bot wall vs JS shell)
- Update the regex at src/you_get/extractors/miaopai.py:175 to the current embedded field name for the video URL
- Find the Weibo oid manually (browser devtools network tab) and call miaopai_download_by_fid directly
Example fix
# before
hit = re.search(r'"page_url"\s*:\s*"([^"]+)"', mobile_page)
if not hit:
raise Exception('Unknown pattern')
# after
hit = (re.search(r'"page_url"\s*:\s*"([^"]+)"', mobile_page)
or re.search(r'"video_url"\s*:\s*"([^"]+)"', mobile_page))
if not hit:
raise Exception('Unknown pattern') Defensive patterns
Strategy: try-catch
Validate before calling
import re
def miaopai_page_has_video_url(mobile_html):
return re.search(r'"page_url"\s*:\s*"([^"]+)"', mobile_html) is not None Try / catch
try:
miaopai_download(url, ...)
except Exception as e:
if str(e) == 'Unknown pattern':
print('page layout changed or bot wall; extract fid manually')
else:
raise Prevention
- Prefer ?fid= style URLs, which bypass HTML scraping entirely
- If scraping is required, verify the HTML actually embeds page_url before parsing
- Keep the extractor's regex in sync when Miaopai/Weibo changes its page JSON schema
When it happens
Trigger: Fetching a miaopai URL whose served HTML contains no "page_url" field: dynamic pages built by JavaScript after load, an error/expired page, or an interstitial requiring login; also URLs of a new share format that skip both fid patterns.
Common situations: Site moving to client-side rendering so get_content sees a JS shell; region blocks serving a different page; share links rotting after Miaopai's Weibo integration changes.
Related errors
AI-assisted analysis of soimort/you-get@049548f3f3 (2026-08-15).
Data as JSON: /api/errors/fca1070a1b841221.
Report an issue: GitHub.