soimort/you-get · error · Exception

No url

Error message

No url

What it means

YoukuExtractor.get_vid_from_url dereferences self.url to regex out the video id from four known URL shapes; if self.url is None/empty (caller constructed the extractor with only a vid, or nothing at all) it raises Exception('No url') as a precondition guard before any pattern matching.

Source

Thrown at src/you_get/extractors/youku.py:131

        # at least a little more recoverable from HTTP 403
        if cls.dispatcher_url in url:
            return url
        elif 'k.youku.com' in url:
            return url
        else:
            url_seg_list = list(urllib.parse.urlsplit(url))
            url_seg_list[1] = cls.dispatcher_url
            return urllib.parse.urlunsplit(url_seg_list)

    def get_vid_from_url(self):
        # It's unreliable. check #1633
        b64p = r'([a-zA-Z0-9=]+)'
        p_list = [r'youku\.com/v_show/id_'+b64p,
                  r'player\.youku\.com/player\.php/sid/'+b64p+r'/v\.swf',
                  r'loader\.swf\?VideoIDS='+b64p,
                  r'player\.youku\.com/embed/'+b64p]
        if not self.url:
            raise Exception('No url')
        for p in p_list:
            hit = re.search(p, self.url)
            if hit is not None:
                self.vid = hit.group(1)
                return

    def get_vid_from_page(self):
        if not self.url:
            raise Exception('No url')
        self.page = get_content(self.url)
        hit = re.search(r'videoId2:"([A-Za-z0-9=]+)"', self.page)
        if hit is not None:
            self.vid = hit.group(1)

    def prepare(self, **kwargs):
        assert self.url or self.vid

        if self.url and not self.vid:

View on GitHub (pinned to 049548f3f3)

Solutions

  1. Pass the URL when constructing: YoukuExtractor('https://v.youku.com/v_show/id_X.html')
  2. Or set extractor.url before calling get_vid_from_url
  3. Skip the call entirely when you already have self.vid — mirror prepare()'s 'if self.url and not self.vid' condition
  4. Wrap extraction in prepare(), which handles the url-or-vid precondition itself

Example fix

# before
extractor = YoukuExtractor()
extractor.get_vid_from_url()  # Exception: No url

# after
extractor = YoukuExtractor('https://v.youku.com/v_show/id_XNTQwMzg4OTA0.html')
extractor.prepare()  # resolves vid from url internally
Defensive patterns

Strategy: type-guard

Validate before calling

def youku_has_url(extractor):
    return bool(getattr(extractor, 'url', None))

Type guard

def can_resolve_from_url(extractor) -> bool:
    return bool(extractor.url) and extractor.vid is None

Try / catch

try:
    extractor.get_vid_from_url()
except Exception as e:
    if str(e) == 'No url':
        raise RuntimeError('construct YoukuExtractor with a URL, or set .url first') from e
    raise

Prevention

When it happens

Trigger: Instantiating YoukuExtractor() and calling get_vid_from_url() without passing a URL (e.g. vid supplied separately or neither), or calling it manually after url was never set; prepare() itself guards with assert self.url or self.vid, so reaching this raise means an internal/manual call path.

Common situations: Programmatic use of the extractor class where the caller sets .vid but a stale code path still calls get_vid_from_url; subclass overrides skipping initialization; library misuse calling private methods directly.


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