Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Automatically fetch latest tgtg version on startup #257

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

unixfox
Copy link
Contributor

@unixfox unixfox commented Jan 2, 2025

This new code change reduces the likeliness of getting 403 errors messages by always sending the latest tgtg app version. It is now known that datadome, the protection of tgtg, will return a 403 if the app version is too old (#251).

I found a simple way to get the latest version using the Google play page. The code is based on this finding: https://stackoverflow.com/a/73331850

It's actually pretty simple:

  1. Fetch the Google play page for TGTG
  2. Discard everything in the HTML source code except text that match /<script nonce=\"\S+\">AF_initDataCallback\((.*?)\);/g.
  3. Find all the version number (X.X.X) using this regex: /(\d+\.\d+\.\d+)/g and put all the versions found in an array.
  4. Filter the array by only getting the highest version number. Solution found in https://stackoverflow.com/a/58027214

This should be fail proof for quite some time because this doesn't rely on a specific JSON ID like the stackoverflow code linked above. And if the code doesn't work in the future, then the program will always fallback to the fixed version number set in the 6th line (tgtgVersion).

Fixes #245

@unixfox unixfox force-pushed the auto-get-latest-tgtg-version branch from a13e366 to dcd7e28 Compare January 2, 2025 21:57
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.

HTTPError: Response code 403
1 participant