Skip to content

Instantly share code, notes, and snippets.

@higgins
Last active June 27, 2022 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save higgins/4d8accd5a3b80c1ed026ee2bdce61039 to your computer and use it in GitHub Desktop.
Save higgins/4d8accd5a3b80c1ed026ee2bdce61039 to your computer and use it in GitHub Desktop.
Extend your DuoLingo daily streak or your `git push` gets rejected
#!/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")
@higgins
Copy link
Author

higgins commented Jun 27, 2022

This can be refactored to use a cached JWT for successive login attempts. See this issue though: KartikTalwar/Duolingo#119

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment