soimort/you-get · error · TypeError

URL does not conform to specifications, Support question onl

Error message

URL does not conform to specifications, Support question only. Example URL: https://www.zhihu.com/question/267782048

What it means

Entry guard of zhihu_download_playlist (src/you_get/extractors/zhihu.py:52). It requires a question-listing URL: the URL must contain 'question' and must NOT contain 'answer'. Anything else — an answer URL, a column URL, a non-question page — raises this TypeError telling the user only question URLs are supported.

Source

Thrown at src/you_get/extractors/zhihu.py:52

        # second Standard Definition
        # third Low Definition
        # finally continue
        data = play_list.get("hd", play_list.get("sd", play_list.get("ld", None)))
        if not data:
            log.w("Video id No play address:{}".format(video_id))
            continue
        print_info(site_info, title, data["format"], data["size"])
        if not info_only:
            ext = "_{}.{}".format(index, data["format"])
            if kwargs.get("zhihu_offset"):
                ext = "_{}".format(kwargs["zhihu_offset"]) + ext
            download_urls([data["play_url"]], title, ext, data["size"],
                          output_dir=output_dir, merge=merge, **kwargs)


def zhihu_download_playlist(url, output_dir='.', merge=True, info_only=False, **kwargs):
    if "question" not in url or "answer" in url:  # question page
        raise TypeError("URL does not conform to specifications, Support question only."
                        " Example URL: https://www.zhihu.com/question/267782048")
    url = url.split("?")[0]
    if url[-1] == "/":
        question_id = url.split("/")[-2]
    else:
        question_id = url.split("/")[-1]
    videos_url = r"https://www.zhihu.com/api/v4/questions/{}/answers".format(question_id)
    try:
        questions = json.loads(get_content(videos_url))
    except json.decoder.JSONDecodeError:
        raise TypeError("Check whether the problem URL exists.Example URL: https://www.zhihu.com/question/267782048")

    count = 0
    while 1:
        for data in questions["data"]:
            kwargs["zhihu_offset"] = count
            zhihu_download("https://www.zhihu.com/question/{}/answer/{}".format(question_id, data["id"]),
                           output_dir=output_dir, merge=merge, info_only=info_only, **kwargs)

View on GitHub (pinned to 049548f3f3)

Solutions

  1. Call zhihu_download_playlist only with a question URL: https://www.zhihu.com/question/267782048.
  2. For a single answer use zhihu_download('https://www.zhihu.com/question/<qid>/answer/<aid>'); for a column use the zhuanlan URL with zhihu_download.
  3. Route URLs before calling: check for '/answer/' to pick zhihu_download, bare '/question/' to pick the playlist function.
  4. Catch TypeError to give end users a clear message instead of a traceback.

Example fix

# before
zhihu_download_playlist('https://www.zhihu.com/question/267782048/answer/490720324')  # TypeError

# after
zhihu_download_playlist('https://www.zhihu.com/question/267782048')
Defensive patterns

Strategy: validation

Validate before calling

import re

def is_question_listing_url(url):
    return bool(re.search(r'^https?://www\.zhihu\.com/question/\d+/?(\?|$)', url)) and 'answer' not in url

Type guard

null

Try / catch

try:
    zhihu_download_playlist(url)
except TypeError as e:
    if 'Support question only' in str(e):
        print('use a bare question URL, e.g. https://www.zhihu.com/question/267782048')
    else:
        raise

Prevention

When it happens

Trigger: Calling zhihu_download_playlist with an answer permalink (…/question/267782048/answer/490720324 — rejected because 'answer' in url), or with any URL lacking 'question' (e.g. https://zhuanlan.zhihu.com/p/51669862), triggering the `or` branch of `if 'question' not in url or 'answer' in url`.

Common situations: Confusing the two entry points: users call the playlist function on a single answer, or call it on a column; wrappers that route every zhihu URL to the playlist function because the extractor's __all__ exports both zhihu_download and zhihu_download_playlist.

Related errors


AI-assisted analysis of soimort/you-get@049548f3f3 (2026-08-15). Data as JSON: /api/errors/3e0b05815effa587. Report an issue: GitHub.