soimort/you-get · warning · Exception

You can download it with -l flag

Error message

You can download it with -l flag

What it means

Raised as plain Exception in icourses_download (src/you_get/extractors/icourses.py:21). The supplied icourses.cn URL is a course-static page (course_<id>.html), which lists many videos, so the single-download entrypoint refuses and tells the user to rerun with the playlist flag so icourses_playlist_download enumerates the videos.

Source

Thrown at src/you_get/extractors/icourses.py:21

from urllib import parse, error
import random
from time import sleep
import datetime
import hashlib
import base64
import logging
import re
from xml.dom.minidom import parseString

__all__ = ['icourses_download', 'icourses_playlist_download']


def icourses_download(url, output_dir='.', **kwargs):
    if 'showResDetail.action' in url:
        hit = re.search(r'id=(\d+)&courseId=(\d+)', url)
        url = 'http://www.icourses.cn/jpk/changeforVideo.action?resId={}&courseId={}'.format(hit.group(1), hit.group(2))
    if re.match(r'http://www.icourses.cn/coursestatic/course_(\d+).html', url):
        raise Exception('You can download it with -l flag')
    icourses_parser = ICousesExactor(url=url)
    icourses_parser.basic_extract()
    title = icourses_parser.title
    size = None
    for i in range(5):
        try:
            # use this url only for size
            size_url = icourses_parser.generate_url(0)
            _, type_, size = url_info(size_url, headers=fake_headers)
        except error.HTTPError:
            logging.warning('Failed to fetch the video file! Retrying...')
            sleep(random.Random().randint(2, 5))  # Prevent from blockage
        else:
            print_info(site_info, title, type_, size)
            break

    if size is None:
        raise Exception("Failed")

View on GitHub (pinned to 049548f3f3)

Solutions

  1. Rerun with the playlist flag: `you-get -l <course_url>` so icourses_playlist_download handles it.
  2. Or navigate the course page in a browser and pass the URL of one specific video resource to the single-video path.
  3. In scripts, pre-route URLs matching coursestatic/course_\d+.html to the playlist function.

Example fix

# before
icourses_download('http://www.icourses.cn/coursestatic/course_6606.html')
# Exception: You can download it with -l flag

# after
icourses_playlist_download('http://www.icourses.cn/coursestatic/course_6606.html')
Defensive patterns

Strategy: validation

Validate before calling

import re

def icourses_is_course_page(url):
    return re.match(r'http://www\.icourses\.cn/coursestatic/course_\d+\.html', url) is not None

# route accordingly
# if icourses_is_course_page(url): icourses_playlist_download(url) else icourses_download(url)

Try / catch

try:
    icourses_download(url, output_dir)
except Exception as e:
    if str(e) == 'You can download it with -l flag':
        icourses_playlist_download(url, output_dir)
    else:
        raise

Prevention

When it happens

Trigger: Calling icourses_download (directly or via `you-get` without -l) with a URL matching r'http://www.icourses.cn/coursestatic/course_\d+.html'. The function deliberately raises before doing any extraction.

Common situations: User copies a course homepage link instead of an individual video link; scripts routing all icourses URLs to the single-video function.

Related errors


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