Skip to content

Conversation

@yashodhank
Copy link

Summary

  • Make -s/--sessionid optional by adding --browser and --login flags for automatic session acquisition
  • --browser extracts Instagram sessionid cookie from Chrome/Firefox via browser_cookie3
  • --login provides interactive username/password login with AES-GCM+RSA encrypted password and 2FA support
  • Sessions are cached in ~/.toutatis/session and reused automatically on subsequent runs
  • Added extras_require in setup.py for optional browser_cookie3 and pycryptodome dependencies

Test plan

  • toutatis --help shows new --browser and --login flags
  • toutatis -u test --login prompts for credentials
  • toutatis -u test --browser chrome attempts cookie extraction
  • After first successful run with -s, subsequent toutatis -u test works without -s (uses cached session)
  • Graceful error messages when optional deps are not installed

- Use requests.Session for connection/cookie reuse across all API calls
- Update User-Agent to modern Instagram Android string (was broken "iphone_ua" literal)
- Add standard headers (X-IG-App-ID, X-IG-Device-ID, X-IG-Connection-Type)
- Add delay between sequential API requests to avoid rate limiting
- Pass session ID to advanced_lookup() (was unauthenticated)
- Fix searchType default parameter bug ("username" or "id" → "username")
- Add retry with exponential backoff on 429 responses
- Fix bare except clause, add 401 handling, catch KeyError/TypeError

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
root and others added 3 commits February 3, 2026 05:28
…r support

Increase MAX_RETRIES to 5, fix exponential backoff formula to use
RETRY_BASE_DELAY * 2^attempt (~2-32s), add random jitter to avoid
synchronized retries, and respect Retry-After header from Instagram.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use deterministic device ID (uuid5) derived from session ID to prevent IP/device mismatch blocks
- Eliminate redundant users/{id}/info API call by reusing web_profile_info data (3→2 calls)
- Increase pre-request delay for advanced_lookup to 3-5s with jitter to reduce rate limiting
- Add session validation with clear error message for blocked sessions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix control flow in getInfo(): ID lookup block was incorrectly unindented
- Fix misleading "Rate limit" error on JSON parse/key errors in getUserId()
- Add null-safe .get() access for all output fields in main()
- Add 401/403/429 handling in advanced_lookup()
- Remove unused session parameter from _request_with_retry()
- Fix always-truthy str() wrapping on phone number falsy checks
- Fix unsafe nested key access for profile picture URL

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant