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

Cannot download any app #132

Open
cstayyab opened this issue Aug 5, 2020 · 4 comments · Fixed by matt668/googleplay-api#1 · May be fixed by #138
Open

Cannot download any app #132

cstayyab opened this issue Aug 5, 2020 · 4 comments · Fixed by matt668/googleplay-api#1 · May be fixed by #138

Comments

@cstayyab
Copy link

cstayyab commented Aug 5, 2020

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
Copy link
Contributor

gurnec commented Aug 10, 2020

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

The culprit appears to be here:

self.log(packageName)

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:

  • Download a free app I've downloaded before: succeeds
  • Download a free app I've never downloaded before: succeeds
  • Download a paid app I've already paid for: succeeds
  • Download a paid app I haven't paid for: fails as expected with gpapi.googleplay.RequestError: 'App not purchased'

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
Copy link

OJFord commented Nov 29, 2020

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

@cstayyab
Copy link
Author

cstayyab commented Dec 8, 2020

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

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

cstayyab added a commit to cstayyab/googleplay-api that referenced this issue Dec 8, 2020
@cstayyab cstayyab linked a pull request Dec 8, 2020 that will close this issue
@OJFord
Copy link

OJFord commented Jan 28, 2021

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

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 a pull request may close this issue.

3 participants