NoMore201 / googleplay-api

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

Cannot download any app #132

Open cstayyab opened 4 years ago

cstayyab commented 4 years ago

When given command to download APK (e.g. com.facebook.katana)

server.download("com.facebook.katana")

Following error from generated protobuf python file is shown:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Development\googleplay-api\gpapi\googleplay.py", line 607, in download
    self.log(packageName)
  File "D:\Development\googleplay-api\gpapi\googleplay.py", line 634, in log
    response = googleplay_pb2.ResponseWrapper.FromString(response.content)
  File "c:\users\cstayyab\appdata\roaming\python\python38\site-packages\google\protobuf\internal\python_message.py", line 801, in FromString
    message.MergeFromString(s)
  File "c:\users\cstayyab\appdata\roaming\python\python38\site-packages\google\protobuf\internal\python_message.py", line 1137, in MergeFromString
    raise message_mod.DecodeError('Unexpected end-group tag.')
google.protobuf.message.DecodeError: Unexpected end-group tag.
gurnec commented 4 years ago

For me anyways, this issue only affects free apps. Downloads of paid apps continue to work.

The culprit appears to be here:

https://github.com/NoMore201/googleplay-api/blob/664c399f8196e1eb7d2fcda4af34e5dc1fca0f20/gpapi/googleplay.py#L616

The commit history says:

This function is needed by the purchase API to insert app into user's
library. Without this, new apps won't be downloaded

This no longer appears to be the case. After removing this line, I ran four tests, all of which acted as expected:

Inside the log() function, a request is made to the LOG_URL. Currently the response always has (for me anyways) an HTTP 400 status code, along with html content containing:

400. That's an error.

The server cannot process the request because it is malformed. It should not be retried. That's all we know.

An attempt is made to treat the html content as a protobuf, which generates that exception.

@cstayyab If you remove the line mentioned above, does it work for you?

I think it would be safe to just remove the log() function entirely... but I don't know if it might break things for others.

OJFord commented 3 years ago

Ha..! Nice find @gurnec, that does fix it for me too.

cstayyab commented 3 years ago

@cstayyab If you remove the line mentioned above, does it work for you?

Yes, it works. Thanks. Can someone generate a PR for this?

OJFord commented 3 years ago

Gentle ping @NoMore201 - would be great to have this fixed without needing manual edits / installing forks. Cheers 🙂