Last active
June 27, 2022 00:41
-
-
Save higgins/4d8accd5a3b80c1ed026ee2bdce61039 to your computer and use it in GitHub Desktop.
Extend your DuoLingo daily streak or your `git push` gets rejected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python3.9 | |
# NOTE: | |
# Install the unofficial DuoLingo SDK -- https://github.com/KartikTalwar/Duolingo | |
# | |
# 1. pip install duolingo-api | |
# 2. Update username and password below | |
# 3. Copy this file to .git/hooks/pre-push | |
# | |
# You may have to update reference to python3.9 above | |
import sys | |
import duolingo | |
username = "" | |
password = "" | |
print("\033[95mLogging into DuoLingo...\033[0m") | |
lingo = duolingo.Duolingo(username, password) | |
print("\033[95mChecking DuoLingo streak info...\033[0m") | |
streak = lingo.get_streak_info() | |
if streak['streak_extended_today']: | |
print("\033[92mDuoLingo streak extended today!\033[0m") | |
else: | |
sys.exit("\033[91mDuoLingo streak NOT extended today! Rejecting push\033[0m") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This can be refactored to use a cached JWT for successive login attempts. See this issue though: KartikTalwar/Duolingo#119