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

Missing 'uploadDate' field data triggers a KeyError which causes searches to fail. #264

Open
natmey opened this issue Jul 15, 2020 · 1 comment
Labels

Comments

@natmey
Copy link

natmey commented Jul 15, 2020

  • Operating System: Debian GNU/Linux bullseye/sid \n \l
  • Python version when running gplaycli: Python 3.8.4
  • GPlayCli version via gplaycli -v: 3.29 [Python3.8.4]
  • The authentication method: own credentials
  • The way you installed gplaycli: apt
$ apt policy gplaycli
gplaycli:
  Installed: 3.29+dfsg-2
  Candidate: 3.29+dfsg-2
  Version table:
 *** 3.29+dfsg-2 500
        500 https://mirrors.wikimedia.org/debian sid/main amd64 Packages
        100 /var/lib/dpkg/status

The uploadDate field does not seem to be required, or at least it is not reliably transferred back with the rest of the app data. If the information is missing it triggers an error (KeyError: 'uploadDate') while assembling the search results. This causes the search to fail despite already having received the results.

Here is an example of a failing search:

$ gplaycli -s "Signal"
Traceback (most recent call last):
  File "/usr/bin/gplaycli", line 11, in <module>
    load_entry_point('gplaycli==3.29', 'console_scripts', 'gplaycli')()
  File "/usr/lib/python3/dist-packages/gplaycli/gplaycli.py", line 658, in main
    cli.search(args.search, not args.paid)
  File "/usr/lib/python3/dist-packages/gplaycli/hooks.py", line 11, in check_connection
    return function(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/gplaycli/gplaycli.py", line 374, in search
    details['uploadDate'],
KeyError: 'uploadDate'

This is fixed with a ternary check. I have patched it locally, and can once again successfully search.

This patch that shows the simple chage:

--- gplaycli.py.orig	2020-07-15 13:46:29.392977997 -0400
+++ gplaycli.py	2020-07-15 13:53:51.545281696 -0400
@@ -371,7 +371,7 @@ class GPlaycli:
 							  util.sizeof_fmt(int(details['installationSize']))
 							  if int(details['installationSize']) > 0 else 'N/A',
 							  details['numDownloads'],
-							  details['uploadDate'],
+							  details['uploadDate'] if ('uploadDate' in details) else 'N/A',
 							  app['docid'],
 							  details['versionCode'],
 							  "%.2f" % app["aggregateRating"]["starRating"]

I can come back and make a real pull request when I have some time (after the project that required me to figure this out is finished). I wanted to make sure this was documented for others, and give someone the opportunity to patch their own instance, or put together a real commit, before I have time to get to it.

@matlink
Copy link
Owner

matlink commented Jun 28, 2021

I should probably to this for every field. Thank for finding and patching it.

@matlink matlink added the bug label Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants