-
Notifications
You must be signed in to change notification settings - Fork 7
Writing your configuration file
Your configuration file is used to store your login details, a list of your courses, as well as other preferences.
While welearn_bot
can function without a a configuration file (you will be prompted for essential details during runtime),
having a configuration file saves a lot of effort, and enables you to automate the program.
On *nix systems like linux and macos, you should create a ~/.welearnrc
file. On Windows, create a welearn.ini
file in your user's
home directory, typically C:\User\USERNAME\
. Henceforth, we'll refer to this file as our config file.
Your config file will contain various settings or keys, which you set values to. These are grouped into sections based on the purpose of the key. Following are the various sections you can have in your config file.
This section contains two keys, both optional. It should be formatted like this.
[auth]
username = YOUR_USERNAME
password = YOUR_PASSWORD
Only save your username and password in a config file if you are on your personal computer, and nobody else has access to your config file! In case one or more of these keys are missing, you will be prompted for them when you run the script.
This section contains a list of courses you are enrolled in.
[courses]
MA1101
PH2202
CH3303
This is done so that the script doesn't have to query the server every time to get the courses you are enrolled in.
If you supply the keyword ALL
as a command line argument while running the script, for instance
welearn_bot files ALL
the word ALL
acts as shorthand for all the courses under the [courses]
section.
This means that you can choose to leave out certain courses which you don't want use this shorthand for.
You can still query them by name of course, the command
welearn_bot files XY1203
is valid as long as you are enrolled in the XY1203
course, regardless of whether it is specified under the [courses]
section.
The most typical use case for the ALL
keyword is for showing and pulling from all your due assignments.
welearn_bot -d assignments ALL
This may be shortened to
welearn_bot -d a ALL
This section contains options regarding the organization of your downloaded files. All keys are optional, and are overriden by analogous options if supplied by the command line. This has the format
[files]
pathprefix = ~/path/to/your/common/folder
ignore = mp4, mkv, avi
The pathprefix
key lets you specify the directory under which all your course folders are to be located. This will be the case no matter
where you run the script from. Note that in the absence of this key (as well as the --pathprefix
option), the default behaviour is
to use the directory the script is called from. Supposing that the pathprefix
points to a directory named WeLearn
, your directory
structure after pulling a few files may look like this.
WeLearn
├── MA1101
│ └── ... ... .pdf
├── PH2202
│ └── ... .pdf
└── CH3303
├── ... .pdf
├── ... ... .pdf
└── ... .pdf
The ignore
key stores a list of comma separated file extensions which you want the script to ignore while downloading.
This may be useful if you don't want to download large files such as video or audio files.
This section contains keys needed to connect with Google Calendar. Google Calendar integration is completely optional, so you
can skip this section if you wish. Follow the instructions
on obtaining a client_id
and client_secret
, and fill in this section as follows.
[gcal]
client_id = xxxxxxxxxxxxxxx.apps.googleusercontent.com
client_secret = xxxxxxxxxxxxxxxxx
If you want your events to be saved to a calendar other than your primary one, go to Google Calendar, open your chosen calendar's
settings, scroll down to "Integrate calendar" and copy the "Calendar ID". Add the following key under the [gcal]
section.
calendar_id = c_xxxxxxxxxxxxxxxxxxxxxxxxxx@group.calendar.google.com