{"record":{"id":"9ea4b50253e2da34","repo":"soimort/you-get","slug":"you-can-download-it-with-l-flag","errorCode":null,"errorMessage":"You can download it with -l flag","messagePattern":"You can download it with -l flag","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"src/you_get/extractors/icourses.py","lineNumber":21,"sourceCode":"from urllib import parse, error\nimport random\nfrom time import sleep\nimport datetime\nimport hashlib\nimport base64\nimport logging\nimport re\nfrom xml.dom.minidom import parseString\n\n__all__ = ['icourses_download', 'icourses_playlist_download']\n\n\ndef icourses_download(url, output_dir='.', **kwargs):\n    if 'showResDetail.action' in url:\n        hit = re.search(r'id=(\\d+)&courseId=(\\d+)', url)\n        url = 'http://www.icourses.cn/jpk/changeforVideo.action?resId={}&courseId={}'.format(hit.group(1), hit.group(2))\n    if re.match(r'http://www.icourses.cn/coursestatic/course_(\\d+).html', url):\n        raise Exception('You can download it with -l flag')\n    icourses_parser = ICousesExactor(url=url)\n    icourses_parser.basic_extract()\n    title = icourses_parser.title\n    size = None\n    for i in range(5):\n        try:\n            # use this url only for size\n            size_url = icourses_parser.generate_url(0)\n            _, type_, size = url_info(size_url, headers=fake_headers)\n        except error.HTTPError:\n            logging.warning('Failed to fetch the video file! Retrying...')\n            sleep(random.Random().randint(2, 5))  # Prevent from blockage\n        else:\n            print_info(site_info, title, type_, size)\n            break\n\n    if size is None:\n        raise Exception(\"Failed\")","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/soimort/you-get/blob/049548f3f3f35e67ba8d3181c71fdc71d11cf260/src/you_get/extractors/icourses.py#L3-L39","documentation":"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.","triggerScenarios":"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.","commonSituations":"User copies a course homepage link instead of an individual video link; scripts routing all icourses URLs to the single-video function.","solutions":["Rerun with the playlist flag: `you-get -l <course_url>` so icourses_playlist_download handles it.","Or navigate the course page in a browser and pass the URL of one specific video resource to the single-video path.","In scripts, pre-route URLs matching coursestatic/course_\\d+.html to the playlist function."],"exampleFix":"# before\nicourses_download('http://www.icourses.cn/coursestatic/course_6606.html')\n# Exception: You can download it with -l flag\n\n# after\nicourses_playlist_download('http://www.icourses.cn/coursestatic/course_6606.html')","handlingStrategy":"validation","validationCode":"import re\n\ndef icourses_is_course_page(url):\n    return re.match(r'http://www\\.icourses\\.cn/coursestatic/course_\\d+\\.html', url) is not None\n\n# route accordingly\n# if icourses_is_course_page(url): icourses_playlist_download(url) else icourses_download(url)","typeGuard":null,"tryCatchPattern":"try:\n    icourses_download(url, output_dir)\nexcept Exception as e:\n    if str(e) == 'You can download it with -l flag':\n        icourses_playlist_download(url, output_dir)\n    else:\n        raise","preventionTips":["Route coursestatic/course_*.html URLs to the playlist entrypoint up front."],"tags":["you-get","icourses","playlist","usage-error","extractor"],"backgroundTag":null,"analyzedSha":"049548f3f3f35e67ba8d3181c71fdc71d11cf260","analyzedAt":"2026-08-15T03:58:15.069Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}