Skip to main content

A command line client for WeLearn, in the IISER Kolkata domain

Project description

Welearn-bot

This is a bot which lets you interact with WeLearn from the command line. It can

  • Download all files/resources from your courses and organize them in designated folders.
  • Show your assignments, filter due assignments.
  • Add your assignments to Google Calendar.

Go to our project wiki to learn more about configuring and using the script. Developers may be interested in the article on using the Moodle Web Service module, which shows you how to use the accompanying moodlews.service module to write your own script for interacting with WeLearn, or indeed any other Moodle service.

Demo

asciicast

Installation

This script runs on python3. To install it on your system, run

pip install --upgrade welearn-bot-iiserkol

The --upgrade flag ensures that you get the latest version.

If you are on Windows and are new to python, please go through this quick guide.

Running from source

Clone this repo or download the source code, and navigate to that directory. To install dependencies, run

pip install -r requirements.txt

You can now navigate to the src directory and run python welearn_bot [options ...].

Configuration

On *nix systems (linux, macos), create a ~/.welearnrc file; on Windows, create a welearn.ini in your C:/Users/USERNAME/ folder. Inside, fill in your details in the following format.

[auth]
username = AzureDiamond
password = hunter2

[courses]
MA1101
PH2202
CH3303
LS4404
ES5505

You may omit any or all of your [auth] credentials, in which case you will be prompted each time you run the program.

There are many more configuration options to explore, such as the [files] and [gcal] sections - for a detailed breakdown, please consult our wiki page on writing your configuration file.

Google calendar integration

Integration with Google Calendar is completely optional. This feature allows you to save your assignment dates directly to Google Calendar, when you use the --gcalendar option. You can also choose which calendar within your Google Calendar account to push events to.

You will have to authenticate using OAuth2.0 and add some lines to your configuration file. Please follow the steps in the Google Calendar integration article. At the end, your configuration file will have a section of the following form.

[gcal]
client_id = xxxxxxxxxxxxxxx.apps.googleusercontent.com
client_secret = xxxxxxxxxxxxxxxxx
calendar_id = c_xxxxxxxxxxxxxxxxxxxxxxxxxx@group.calendar.google.com

Usage

Run welearn_bot -h to get the following help message.

usage: welearn_bot [-h] [-v] [-d] [-c] [-i [IGNORETYPES ...]] [-f] [-p PATHPREFIX] action [courses ...]

A command line client for interacting with WeLearn.

positional arguments:
  action                choose from
                            files       - downloads files/resources
                            assignments - lists assignments, downloads attachments
                            urls        - lists urls
                            courses     - lists enrolled courses
                            whoami      - shows the user's name and exits
                        Abbreviations such as any one of 'f', 'a', 'u', 'c', 'w' are supported.
  courses               IDs of the courses to download files from. The word ALL selects everything
                        from the [courses] section in .welearnrc or welearn.ini

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -d, --dueassignments  show only due assignments with the 'assignments' action
  -c, --gcalendar       add due assignments to Google Calendar with the 'assignments' action
  -i [IGNORETYPES ...], --ignoretypes [IGNORETYPES ...]
                        ignores the specified extensions when downloading, overrides .welearnrc
  -f, --forcedownload   force download files even if already downloaded/ignored
  -p PATHPREFIX, --pathprefix PATHPREFIX
                        save the downloads to a custom path, overrides .welearnrc

See our article on using command line options for a detailed breakdown.

Examples

Testing your setup

If your .welearnrc or welearn.ini file is set up correctly, the following command should simply display your name.

welearn_bot whoami

To get a list of courses you are enrolled in, run

welearn_bot courses

Basic commands

To pull all files from the courses MA1101 and CH3303, run

welearn_bot files MA1101 CH3303

You can use the shorthand f for files, so the following is an equivalent command.

welearn_bot f MA1101 CH3303

To show assignments and download their attachments from the course MA1101, run

welearn_bot assignments MA1101

To list due assignments (due date in the future) from all courses, run

welearn_bot -d assignments ALL

Make sure that the -d flag comes first!

To list all urls from the CH3303 course, run

welearn_bot urls CH3303

Calendar integration

To list due assignments from all courses, and add them to your calendar, run

welearn_bot -dc assignments ALL

Ignoring filetypes

To download all resources from the course CH3303, ignoring pdf files, run

welearn_bot -i pdf -- files CH3303

Note the use of -- which is essential for separating the IGNORETYPES from the courses. The following format may be preferred.

welearn_bot files CH3303 -i pdf

To override the .welearnrc ignore settings and allow all extensions, but still respect past downloads, run

welearn_bot -i -- files CH3303

Force downloads and pathprefix

To force download all resources from the course PH2202, even if already downloaded and present or set to be ignored, and put all the course directories in the ~/notes folder, run

welearn_bot files PH2202 -fp ~/notes 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

welearn-bot-iiserkol-1.2.2.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

welearn_bot_iiserkol-1.2.2-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file welearn-bot-iiserkol-1.2.2.tar.gz.

File metadata

  • Download URL: welearn-bot-iiserkol-1.2.2.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for welearn-bot-iiserkol-1.2.2.tar.gz
Algorithm Hash digest
SHA256 af3680763925d9b697467718fecf97713aa1df9cb3d9f0b8e192c3a52c5f07f6
MD5 ef9ad26ec42b4332c28c7f89fd1c1b4b
BLAKE2b-256 437a09d81bab8b95c3f6ad6d1389ebd2eed5e86565f7a224c313a333a004694d

See more details on using hashes here.

File details

Details for the file welearn_bot_iiserkol-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: welearn_bot_iiserkol-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for welearn_bot_iiserkol-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 64e101d095b68bcd0267fb24d58455c84a478ff401c641d1c43a6813775dc770
MD5 136971e8cf2dbedf7b5b2739a5b2b882
BLAKE2b-256 f0f2e3b7efa351fdea52819771d9905bfade220f8421edea74ddf7a6e1788c42

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page