From 6265362447d850e48b4c7d0c8c70cef661742184 Mon Sep 17 00:00:00 2001 From: Marvin Scham Date: Fri, 8 Sep 2023 18:25:20 +0200 Subject: [PATCH] Updated instructions and demo compose file --- README.md | 74 ++++++++++++++++++++++---------------- example.docker-compose.yml | 8 ++--- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 3c1ba18..f3a42a9 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,47 @@
- + ![Duolingo Logo](duolingo.png) - +

Duolingo API Dockerized

-Duolingo API Dockerized is a Python-based Docker image which allows you to set up a basic JSON API to get cached data about your Duolingo Account. - +Serves your Duolingo progress info as JSON. + Based on [KartikTalwar/Duolingo](https://github.com/KartikTalwar/Duolingo), utilizing modifications from [lidiaCirrone/pw-duolingo-data](https://github.com/lidiaCirrone/pw-duolingo-data).
- + ## Example Setup See `example.docker-compose.yml`. You'll need to provide your own `docker-compose.yml`, which you can base on this example file. In case you'd like to run this behind a nginx reverse proxy, you can use `nginx.conf` as a reference. - version: '3.2' +```yml +version: '3.2' + +# e.g. swag reverse proxy network +networks: + yourNetwork: + external: true - # e.g. swag reverse proxy network +services: + duolingo-data: + image: ghcr.io/marvinscham/duolingo-api-dockerized:latest + container_name: duolingo-data + restart: unless-stopped + environment: + - TIMEZONE=Europe/Berlin + - DUO_USERNAME=yourUsername + - DUO_JWT=yourJWT + - SERVER_URL=https://duo.your-domain.com + - XP_SUMMARY_DAYS=30 + - UPDATE_INTERVAL=15 + - MAX_RETRIES=3 + # ports: + # - 80:7000 networks: - yourNetwork: - external: true - - services: - duolingo-data: - build: . - container_name: duolingo-data - restart: unless-stopped - environment: - - TIMEZONE=Europe/Berlin - - DUO_USERNAME=yourUsername - - DUO_PASSWORD=yourPassword - - SERVER_URL=https://your-domain.com - - XP_SUMMARY_DAYS=30 - - UPDATE_INTERVAL=15 - - MAX_RETRIES=3 - # ports: - # - 80:7000 - networks: - - yourNetwork + - yourNetwork +``` ## Environment Variables @@ -48,13 +50,13 @@ In case you'd like to run this behind a nginx reverse proxy, you can use `nginx. - Default: `Europe/Berlin` - `DUO_USERNAME` - Required for login -- `DUO_PASSWORD` - - Required for login +- `DUO_JWT` + - Login token (**Not your password!** Info on obtaining this is in the following segment) - `SERVER_URL` - Used for connectivity self check - - Example: `https://your-domain.com` → no trailing slash! + - Example: `https://your-domain.com` → without trailing slash! - `XP_SUMMARY_DAYS` - - Number of past days to get data from. Might stop working properly if > 300 + - Number of past days to get data from. _Might stop working properly if > 300_ - Default: `30` - `UPDATE_INTERVAL` - Time in minutes to request fresh data from Duolingo @@ -62,3 +64,13 @@ In case you'd like to run this behind a nginx reverse proxy, you can use `nginx. - `MAX_RETRIES` - How often the app should retry in case of some connection error (retry interval 60 seconds) - Default: `3` + +## Grabbing your JWT + +Login on [Duolingo](duolingo.com) and run the following JavaScript in your browser console. The returned string is your JWT. + +```js +document.cookie.match(new RegExp('(^| )jwt_token=([^;]+)'))[0].slice(11); +``` + +The token currently does not expire but will break if you change your Duolingo password. diff --git a/example.docker-compose.yml b/example.docker-compose.yml index ed8eb1a..b7475b8 100644 --- a/example.docker-compose.yml +++ b/example.docker-compose.yml @@ -7,18 +7,18 @@ networks: services: duolingo-data: - build: . + image: ghcr.io/marvinscham/duolingo-api-dockerized:latest container_name: duolingo-data restart: unless-stopped environment: - TIMEZONE=Europe/Berlin - DUO_USERNAME=yourUsername - - DUO_PASSWORD=yourPassword - - SERVER_URL=https://your-domain.com + - DUO_JWT=yourJWT + - SERVER_URL=https://duo.your-domain.com - XP_SUMMARY_DAYS=30 - UPDATE_INTERVAL=15 - MAX_RETRIES=3 # ports: # - 80:7000 networks: - - yourNetwork \ No newline at end of file + - yourNetwork