NoMore201 / googleplay-api

Google Play Unofficial Python API
Other
413 stars 208 forks source link

Play Store Rate-limits Requests #43

Open peterstory opened 6 years ago

peterstory commented 6 years ago

As described in my PR (https://github.com/NoMore201/googleplay-api/pull/41), the current implementation of the code doesn't handle Google's rate-limiting gracefully.

However, there is also the question of why I'm encountering rate-limiting in the first place. I've created this issue to track my investigations into that problem.

peterstory commented 6 years ago

My best guess at the moment is that this while loop is causing a large number of requests to be issued, which is causing Google to rate-limit me:

https://github.com/NoMore201/googleplay-api/blob/6f5565bdefb8cc9852240e04d9e3ea603bccfc73/gpapi/googleplay.py#L316

peterstory commented 6 years ago

@matlink and @NoMore201: I've made two changes.

27d9cb4 is a fix for a genuine bug I discovered, where an infinite loop of requests could be generated.

7af8359 is an implementation of exponential backoff for when Google responds with 400 and 429 response codes (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429).

Should I create separate pull requests, or a single pull request for both?

archon810 commented 6 years ago

@NoMore201 Any updates? Without this raise RequestError, the code throws up when the token expires, like so:

[27-Mar-2018 18:27:57 UTC] Traceback (most recent call last):
  File "gplaycli.py", line 761, in <module>
    main()
  File "gplaycli.py", line 752, in main
    cli.download(args.packages_to_download)
  File "hooks.py", line 8, in check_connection
    self.connect()
  File "gplaycli.py", line 457, in connect
    gsfId=gsfid)
  File "gpapi/googleplay.py", line 205, in login
    self.search('firefox', 1, None)
  File "gpapi/googleplay.py", line 317, in search
    data = self.executeRequestApi2(currentPath)
  File "gpapi/googleplay.py", line 273, in executeRequestApi2
    headers = self.getDefaultHeaders()
  File "gpapi/googleplay.py", line 101, in getDefaultHeaders
    "User-Agent": self.deviceBuilder.getUserAgent()}
  File "gpapi/config.py", line 94, in getUserAgent
    supported_abis=self.device.get('platforms').replace(',', ';'))
RuntimeWarning: Unexpected end-group tag: Not all data was converted