C0D3D3V/Moodle-DL

Download fails on some courses

Aunib opened this issue · 1 comments

Description of the bug

When I try to download the courses of the moodle of my school, I get an error (moodle-dl --verbose --log-to-file)

2023-09-02 12:05:22  DEBUG  {main}  moodle-dl version: 2.3.2.0
2023-09-02 12:05:22  DEBUG  {main}  python version: 3.7.3
2023-09-02 12:05:22  DEBUG  {main}  Is ffmpeg available: True
2023-09-02 12:05:22  DEBUG  {main}  Checking for changes for the configured Moodle-Account....
2023-09-02 12:05:22  DEBUG  {database}  Database Version: 5
2023-09-02 12:05:22  DEBUG  {selector_events}  Using selector: EpollSelector
2023-09-02 12:05:22  DEBUG  {moodle_service}  Fetching current Moodle state...
2023-09-02 12:05:22  INFO  {moodle_service}  Downloading account information
2023-09-02 12:05:22  DEBUG  {connectionpool}  Starting new HTTPS connection (1): moodle.censored.org:443
2023-09-02 12:05:23  DEBUG  {connectionpool}  https://moodle.censored.org:443 "POST /webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_webservice_get_site_info HTTP/1.1" 200 None
2023-09-02 12:05:23  DEBUG  {moodle_service}  Detected moodle version: 2022112804
2023-09-02 12:05:23  DEBUG  {cookie_handler}  Testing cookies using this URL: https://moodle.censored.org/
2023-09-02 12:05:23  DEBUG  {connectionpool}  Starting new HTTPS connection (1): moodle.censored.org:443
2023-09-02 12:05:23  DEBUG  {connectionpool}  https://moodle.censored.org:443 "GET / HTTP/1.1" 303 1519
2023-09-02 12:05:23  DEBUG  {connectionpool}  https://moodle.censored.org:443 "GET /my/ HTTP/1.1" 200 25066
2023-09-02 12:05:23  DEBUG  {cookie_handler}  Cookies are still valid
2023-09-02 12:05:23  DEBUG  {connectionpool}  Starting new HTTPS connection (1): moodle.censored.org:443
2023-09-02 12:05:23  DEBUG  {connectionpool}  https://moodle.censored.org:443 "POST /webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_enrol_get_users_courses HTTP/1.1" 200 None
2023-09-02 12:05:23  INFO  {common}  Loaded all assignments
2023-09-02 12:05:23  INFO  {common}  Loaded all lessons
2023-09-02 12:05:23  INFO  {common}  Loaded all quizzes
2023-09-02 12:05:23  INFO  {common}  Loaded all databases
2023-09-02 12:05:23  INFO  {common}  Loaded all pages
2023-09-02 12:05:23  INFO  {common}  Loaded all workshops
2023-09-02 12:05:23  INFO  {common}  Loaded all folders
2023-09-02 12:05:23  DEBUG  {forum}  Loaded forum page 0 of "Ankündigungen"
2023-09-02 12:05:23  INFO  {utils}  [1/1] Loaded forum 507747 in course 4769 "Ankündigungen"
2023-09-02 12:05:23  INFO  {common}  Loaded all forums
2023-09-02 12:05:23  DEBUG  {request_helper}  Details about the failed request:
URL: https://moodle.censored.org/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_course_get_contents
Body: {'moodlewssettingfilter': 'true', 'moodlewssettingfileurl': 'true', 'courseid': 4769, 'wsfunction': 'core_course_get_contents', 'wstoken': 'censored'}
2023-09-02 12:05:23  DEBUG  {mail_service}  Mail-Notifications not configured, skipping.
2023-09-02 12:05:23  INFO  {telegram_service}  Sending Notification via Telegram...
2023-09-02 12:05:23  DEBUG  {connectionpool}  Starting new HTTPS connection (1): api.telegram.org:443
2023-09-02 12:05:24  DEBUG  {connectionpool}  https://api.telegram.org:443 "POST /CENSORED/sendMessage HTTP/1.1" 200 467
2023-09-02 12:05:24  DEBUG  {xmpp_service}  XMPP-Notifications not configured, skipping.
2023-09-02 12:05:24  ERROR  {main}  Traceback (most recent call last):
  File "/home/moodle-dl/.local/lib/python3.7/site-packages/moodle_dl/main.py", line 536, in main
    choose_task(config, opts)
  File "/home/moodle-dl/.local/lib/python3.7/site-packages/moodle_dl/main.py", line 68, in choose_task
    run_main(config, opts)
  File "/home/moodle-dl/.local/lib/python3.7/site-packages/moodle_dl/main.py", line 136, in run_main
    raise base_err
  File "/home/moodle-dl/.local/lib/python3.7/site-packages/moodle_dl/main.py", line 95, in run_main
    changed_courses = asyncio.run(moodle.fetch_state(database))
  File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/home/moodle-dl/.local/lib/python3.7/site-packages/moodle_dl/moodle/moodle_service.py", line 117, in fetch_state
    course_cores = await core_handler.async_load_course_cores(courses)
  File "/home/moodle-dl/.local/lib/python3.7/site-packages/moodle_dl/moodle/core_handler.py", line 157, in async_load_course_cores
    cores = await asyncio.gather(*async_features)
  File "/home/moodle-dl/.local/lib/python3.7/site-packages/moodle_dl/utils.py", line 64, in run_with_final_message
    result = await load_function(entry)
  File "/home/moodle-dl/.local/lib/python3.7/site-packages/moodle_dl/moodle/core_handler.py", line 166, in async_load_course_core
    return await self.client.async_post('core_course_get_contents', data)
  File "/home/moodle-dl/.local/lib/python3.7/site-packages/moodle_dl/moodle/request_helper.py", line 141, in async_post
    self.check_json_for_moodle_error(resp_json, url, data)
  File "/home/moodle-dl/.local/lib/python3.7/site-packages/moodle_dl/moodle/request_helper.py", line 328, in check_json_for_moodle_error
    + f" Message: {resp_json.get('message', '')})"
moodle_dl.moodle.request_helper.RequestRejectedError: The Moodle System rejected the Request. Details: moodle_exception (Error code: cannotgetcoursecontents, Message: Kursinhalte können nicht geladen werden.)

2023-09-02 12:05:24  DEBUG  {main}  Exception-Handling completed. Exiting...

My school updated moodle over the summer holidays, I don't know the old version.
This is a minimal example with only one small course. The error occurs only when trying to download some courses, but not others. I could not identify which feature of the course breaks the downloader.
If you need any more information, I would be happy to provide it.

Expected behavior

moodle-dl downloads the course contents and exits without error

Technical details

Debian Linux 10 "Buster"
on a Raspberry Pi 4 (arm64)
moodle-dl version 2.3.2.0
moodle version 4.1.5