C0D3D3V / Moodle-DL

Moodle-DL downloads course content fast from Moodle (eg. lecture pdfs)
GNU General Public License v3.0
428 stars 63 forks source link

version.php not found #105

Closed fulcus closed 3 years ago

fulcus commented 3 years ago

I have logged in using sso with moodle-dl --init --sso and everything worked as expected. Then if I launch moodle-dl it throws this error:

The following error occurred during execution:
The Moodle System rejected the Request. Details: moodle_exception (Errorcode: missingversionfile, Message: Coding error: version.php file is missing for the component mod_tutorialbooking)

MoodleDownloader.log

2021-09-14 10:39:39  INFO  {main}  --- moodle-dl started ---------------------
2021-09-14 10:39:39  ERROR  {main}  Error while trying to load the Configuration! No config found! Exiting...
2021-09-14 11:01:24  INFO  {main}  --- moodle-dl started ---------------------
2021-09-14 11:01:25  ERROR  {main}  Traceback (most recent call last):
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/main.py", line 246, in run_main
    changed_courses = moodle.fetch_state()
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/moodle_connector/moodle_service.py", line 233, in fetch_state
    userid, version = first_contact_handler.fetch_userid_and_version()
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/moodle_connector/first_contact_handler.py", line 20, in fetch_userid_and_version
    result = self.request_helper.post_REST('core_webservice_get_site_info')
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/moodle_connector/request_helper.py", line 135, in post_REST
    json_result = self._initial_parse(response)
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/moodle_connector/request_helper.py", line 281, in _initial_parse
    raise RequestRejectedError(
moodle_dl.moodle_connector.request_helper.RequestRejectedError: The Moodle System rejected the Request. Details: moodle_exception (Errorcode: missingversionfile, Message: Coding error: version.php file is missing for the component mod_tutorialbooking)

2021-09-14 11:04:08  INFO  {main}  --- moodle-dl started ---------------------
2021-09-14 11:04:09  ERROR  {main}  Traceback (most recent call last):
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/main.py", line 246, in run_main
    changed_courses = moodle.fetch_state()
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/moodle_connector/moodle_service.py", line 233, in fetch_state
    userid, version = first_contact_handler.fetch_userid_and_version()
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/moodle_connector/first_contact_handler.py", line 20, in fetch_userid_and_version
    result = self.request_helper.post_REST('core_webservice_get_site_info')
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/moodle_connector/request_helper.py", line 135, in post_REST
    json_result = self._initial_parse(response)
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/moodle_connector/request_helper.py", line 281, in _initial_parse
    raise RequestRejectedError(
moodle_dl.moodle_connector.request_helper.RequestRejectedError: The Moodle System rejected the Request. Details: moodle_exception (Errorcode: missingversionfile, Message: Coding error: version.php file is missing for the component mod_tutorialbooking)

2021-09-14 11:04:49  INFO  {main}  --- moodle-dl started ---------------------
2021-09-14 11:04:49  DEBUG  {main}  moodle-dl version: 2.1.2.6
2021-09-14 11:04:49  DEBUG  {main}  python version: 3.8.10
2021-09-14 11:04:49  DEBUG  {main}  Is ffmpeg available: True
2021-09-14 11:04:49  DEBUG  {main}  Loading config...
2021-09-14 11:04:49  DEBUG  {state_recorder}  Database Version: 4
2021-09-14 11:04:49  DEBUG  {main}  Checking for changes for the configured Moodle-Account....
2021-09-14 11:04:49  DEBUG  {moodle_service}  Fetching current Moodle State...
2021-09-14 11:04:49  ERROR  {main}  Traceback (most recent call last):
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/main.py", line 246, in run_main
    changed_courses = moodle.fetch_state()
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/moodle_connector/moodle_service.py", line 233, in fetch_state
    userid, version = first_contact_handler.fetch_userid_and_version()
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/moodle_connector/first_contact_handler.py", line 20, in fetch_userid_and_version
    result = self.request_helper.post_REST('core_webservice_get_site_info')
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/moodle_connector/request_helper.py", line 135, in post_REST
    json_result = self._initial_parse(response)
  File "/home/fulco/.local/lib/python3.8/site-packages/moodle_dl/moodle_connector/request_helper.py", line 281, in _initial_parse
    raise RequestRejectedError(
moodle_dl.moodle_connector.request_helper.RequestRejectedError: The Moodle System rejected the Request. Details: moodle_exception (Errorcode: missingversionfile, Message: Coding error: version.php file is missing for the component mod_tutorialbooking)

2021-09-14 11:04:49  DEBUG  {mail_service}  Mail-Notifications not configured, skipping.
2021-09-14 11:04:49  DEBUG  {telegram_service}  Telegram-Notifications not configured, skipping.
2021-09-14 11:04:49  DEBUG  {xmpp_service}  XMPP-Notifications not configured, skipping.
2021-09-14 11:04:49  DEBUG  {main}  Exception-Handling completed. Exiting...

Technical details

Ubuntu 20.04

C0D3D3V commented 3 years ago

looks like a issue with your moodle instance. Does the moodle app work with your instance? Can you send me the url of the instance? In theory we could skip the core_webservice_get_site_info call, so I can handle the error and skip the retrieval of the userid (but then you have to set the userid in the config manual).

fulcus commented 3 years ago

https://webeep.polimi.it/

Yes that would be awesome!!

C0D3D3V commented 3 years ago

I created an account at your university, but unfortunately I still can't log in at the moodle app (in the browser I can log in, but to test it, the app needs to work). Therefore I can not test it myself. But I will try to implement this in the next days and test it on my own moodle. I will let you know when it is ready.

fulcus commented 3 years ago

Thanks a lot! If you need any help with testing or anything else hmu on telegram @fulcus

fulcus commented 3 years ago

Hi, do you have any update on this issue? A bunch of people from my uni contacted me about it. If you need a hand just lmk.

C0D3D3V commented 3 years ago

I am very sorry that I could not work on it in the last days. I was on vacation (In Austria much hiking <3). And am just in the middle of moving. On Wednesday I will tackle it :)

C0D3D3V commented 3 years ago

Eh, I tackled the issue this morning. I haven't managed to log in to your Moodle in the Moodle App yet. But I found out that on your Moodle it is enabled to view the tokens in the settings under "Security Keys" (https://webeep.polimi.it/user/managetoken.php?sesskey=...). I set the token in the settings of my Moodle downloader ("token": "7a90a25bdfxxxxx57899669d39",). And I have had no problems downloading the courses I am enrolled in.

I therefore assume that the bug in your Moodle has been corrected, and core_webservice_get_site_info no longer throws errors. Please check if it works for you now. I will still try to implement a manual workaround.

C0D3D3V commented 3 years ago

You can now set the version number and the user id manually. I have also already done a writeup: https://github.com/C0D3D3V/Moodle-Downloader-2/wiki/Set-user-id-and-Moodle-version-number-manually

It will be included in the next release, but you can also test it by downloading the branch manually.

fulcus commented 3 years ago

I confirm that it works. Thanks a lot!!