Skip to content

Moodle LMS Scraper This script automates the process of logging into the LMS (Moodle-based) and downloading all available course materials (PDFs, PPTs, etc.) from a specified course page.

Notifications You must be signed in to change notification settings

Deeptanshuu/mydy-lms-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyDy LMS Helper

This script automates the process of logging into the Moodle LMS (Moodle-based) and downloading all available course materials (PDFs, PPTs, etc.) from your enrolled courses.

Proof

Screenshot 2025-09-19 000702 Screenshot 2025-09-19 000803 Screenshot 2025-09-19 000822

Setup

1. Clone or Download

Place scraper.py and this README.md in a folder of your choice.

2. Install Dependencies

Create a virtual environment (optional but recommended):

python -m venv venv
venv\Scripts\activate  # On Windows
# or
source venv/bin/activate  # On Linux/Mac

Install required packages:

pip install -r requirements.txt

Or install manually:

pip install requests beautifulsoup4 python-dotenv tqdm

3. Configure Environment Variables

Create a .env file in the same directory as scraper.py with the following content:

MYDY_USERNAME="your_lms_email@dypatil.edu"
MYDY_PASSWORD="your_lms_password"

Important: Do not use USERNAME as the variable name on Windows - it's reserved by the system!

4. Run the Script

python scraper.py

The script will:

  1. Log you into the LMS
  2. Fetch your available courses
  3. Display an interactive menu to select courses
  4. Download all materials from selected courses with progress tracking

How It Works

Authentication Process

The script handles Moodle's two-step login:

  1. Submits username to get redirected to Moodle login
  2. Submits password to complete authentication
  3. Maintains session for subsequent requests

Course Discovery

  • Scans dashboard for enrolled courses
  • Includes both current and previous semester courses
  • Displays courses sorted by course ID (newest first)

File Detection & Download

The scraper identifies downloadable content from various Moodle activity types:

  • Resource modules: Direct file downloads
  • FlexPaper modules: Extracts PDF URLs from JavaScript
  • Presentation modules: PowerPoint and other presentation files
  • Object/Iframe content: Files embedded in various formats

Organization

  • Creates separate folders for each course
  • Uses sanitized course names for folder creation
  • Preserves original filenames with proper URL decoding

Usage Examples

Download All Courses

Select course to download (1-X): [number for "Download ALL courses"]

Download Specific Course

Select course to download (1-X): [specific course number]

Troubleshooting

Login Issues

  • "Login failed!": Double-check your .env file credentials
  • Username shows as Windows username: You're using USERNAME instead of MYDY_USERNAME
  • Timeout errors: The server might be slow; try running again

Download Issues

  • No files downloaded: Course might have no downloadable content or you might not be enrolled
  • Some activities failed: Normal - not all activities contain downloadable files
  • Connection errors: Check your internet connection and try again

File Issues

  • Duplicate files: The script automatically skips existing files of the same size
  • Invalid filenames: Script automatically sanitizes folder names for your OS
  • Permission errors: Make sure you have write access to the script directory

Security & Privacy

  • Credentials are stored in .env file and never hardcoded
  • Session cookies are temporary and only stored in memory
  • Always add .env to your .gitignore if using version control
  • The script respects rate limits to avoid overwhelming the server

Requirements

  • Python 3.10+
  • Internet connection
  • Valid LMS account
  • Access to courses you want to download

License

MIT License. Use at your own risk.

Disclaimer

This tool is for educational purposes only. Respect your institution's terms of service and use responsibly. Only download content you have legitimate access to.

About

Moodle LMS Scraper This script automates the process of logging into the LMS (Moodle-based) and downloading all available course materials (PDFs, PPTs, etc.) from a specified course page.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages