Skip to content

Repository files navigation

learnit-backup

Back up your ITU LearnIT (Moodle) courses — course materials and your own submissions and feedback — using the session cookie from a browser where you're already logged in. Built so graduating students can archive everything before they lose access.

ITU LearnIT only supports SSO and disables Moodle's mobile / web-service API, so token-based tools like moodle-dl don't work. Reusing your logged-in session cookie is the practical route, which is exactly what these scripts do: they authenticate as you and download through the normal web endpoints.

  • learnit_backup.py — files, resources, pages, forums, and your submissions/feedback.
  • learnit_videos.py — the Kaltura lecture recordings (a separate, browser-driven step).

Heads up: this only reaches courses you're currently enrolled in — what your LearnIT "My courses" page shows. If ITU unenrolled you from old courses after grading, that content isn't reachable by anyone anymore.


What gets saved

For every enrolled course, under backup/<shortname> - <full name>/:

Path Contents
course.html The raw course front page
index.json Structured list of every section and activity
Files/ Resources and folder contents (all uploaded files: PDFs, slides, code, …)
Pages/ Page activities rendered to HTML
Submissions/<assignment>/ submission.html (status, grade, online text, feedback) + submitted/ and feedback/ files
Forums/<forum>/ Every discussion thread as HTML, plus attachments
Videos/ Lecture recordings as MP4 (from learnit_videos.py)
links.txt Activities that are just links or aren't downloadable (external URLs, quizzes, surveys)

A top-level backup/manifest.json summarises everything.

Saved HTML is styled for offline reading: each course folder gets a _assets/learnit.css (the LearnIT theme) that the saved pages link to, so course.html, forum threads, pages, and submissions look like the real site when opened from disk — no server needed.


Setup

pip install -r requirements.txt

Get your cookie

  1. Log in to https://learnit.itu.dk in your browser.
  2. Open DevTools (F12) → Network tab.
  3. Refresh the page, click any learnit.itu.dk request.
  4. Under Request Headers, find Cookie: and copy its entire value.
  5. Paste it into a file named cookie.txt next to the scripts. (There's a cookie.txt.example to copy from. cookie.txt is gitignored.)

The cookie expires after a while. If a script says it can't log in, grab a fresh one.

🔒 Your cookie is a live credential for your account. Keep cookie.txt private and never commit or share it. The .gitignore already excludes it.


Back up files, submissions & forums

python learnit_backup.py              # back up everything
python learnit_backup.py --list       # just list your courses, download nothing
python learnit_backup.py --course 3022795   # one course (repeatable)
python learnit_backup.py --out D:/itu-backup
python learnit_backup.py --delay 0.5  # be gentler on the server

Re-running is safe and resumable: files that already exist are skipped, so you can stop and restart, or run again later to pick up new material.


Back up lecture videos

Video activities (Kaltura, kalvidres) aren't pluginfile.php content — they're streamed through a signed LTI iframe, so the main script can't reach them. learnit_videos.py drives a headless logged-in browser (Playwright) to each player, captures the HLS stream, and saves it to MP4 with ffmpeg.

One-time extra setup:

pip install playwright
playwright install chromium      # ~150 MB browser download
# and make sure ffmpeg is installed and on your PATH

Then:

python learnit_videos.py            # all courses that have videos
python learnit_videos.py --list     # list videos, download nothing
python learnit_videos.py --course 3023658   # only these courses (repeatable)
python learnit_videos.py --out D:/itu-backup

Videos land in <out>/<course>/Videos/, numbered in course order, and the run is resumable just like the file backup.

Lecture recordings are large — a full set can be many GB — and this is slower than the file backup. Point --out at a drive with room. If the cookie expires mid-run, grab a fresh one and re-run; finished files are skipped.


How it works

  • Authenticates by sending your session cookie, then reads the per-session sesskey from a logged-in page.
  • Lists courses via Moodle's AJAX endpoint (core_course_get_enrolled_courses_by_timeline_classification).
  • Parses each course page for activities and handles each type (resource, folder, page, assign, forum, url), downloading the underlying pluginfile.php content.
  • For videos, captures the Kaltura HLS manifest the player requests and muxes it with ffmpeg.

Nothing is sent anywhere except to learnit.itu.dk and ITU's Kaltura host.


Notes & disclaimer

This tool only downloads content you already have access to, for your own personal archival. It doesn't bypass any access control — it just automates saving what you can already see while logged in. Be reasonable with it (the default delays are polite), keep your cookie private, and respect ITU's terms of use. Provided as-is under the MIT license, with no affiliation with or endorsement by the IT University of Copenhagen.

Contributions welcome — if a course uses an activity type that isn't handled yet, open an issue or PR.

About

Back up your ITU LearnIT (Moodle) courses, submissions and lecture videos via a logged-in session cookie

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages