matlink / gplaycli

Google Play Downloader via Command line
Other
1.02k stars 178 forks source link

apk version determination broken, -av, --append-version (was: Inconsistent failure of apk download with KeyError) #280

Open ford--prefect opened 3 years ago

ford--prefect commented 3 years ago

I'm running gplaycli in download mode with a daily cron job, and inconsistently get failures of the following kind:

Traceback (most recent call last):
  File "/usr/bin/gplaycli", line 33, in <module>
    sys.exit(load_entry_point('gplaycli==3.29', 'console_scripts', 'gplaycli')())
  File "/usr/lib/python3.9/site-packages/gplaycli/gplaycli.py", line 659, in main
    cli.download(args.download)
  File "/usr/lib/python3.9/site-packages/gplaycli/hooks.py", line 11, in check_connection
    return function(self, *args, **kwargs)
  File "/usr/lib/python3.9/site-packages/gplaycli/gplaycli.py", line 257, in download
    filename = "%s-v.%s.apk" % (detail['docid'], detail['details']['appDetails']['versionString'])
KeyError: 'versionString'

This happens for all calls in one session, but not on all days. I guess, this is a problem with the playstore response, but maybe a check and graceful error or handling could be achieved?

emanuelb commented 3 years ago

Same happen here on all tries, running /home/appuser/.local/bin/gplaycli -av -p -y -v -d com.trusteewallet error:

[INFO] GPlayCli version 3.29 [Python3.9.5] 
[INFO] Configuration file is /home/appuser/.local/etc/gplaycli/gplaycli.conf
[INFO] Device is bacon
[INFO] Using cached token.
[INFO] Using auto retrieved token to connect to API
Traceback (most recent call last):
  File "/home/appuser/.local/bin/gplaycli", line 8, in <module>
    sys.exit(main())
  File "/home/appuser/.local/lib/python3.9/site-packages/gplaycli/gplaycli.py", line 659, in main
    cli.download(args.download)
  File "/home/appuser/.local/lib/python3.9/site-packages/gplaycli/hooks.py", line 11, in check_connection
    return function(self, *args, **kwargs)
  File "/home/appuser/.local/lib/python3.9/site-packages/gplaycli/gplaycli.py", line 257, in download
    filename = "%s-v.%s.apk" % (detail['docid'], detail['details']['appDetails']['versionString'])
KeyError: 'versionString'

or error:

/ $ /home/appuser/.local/bin/gplaycli -av -p -y -v -d com.trusteewallet
[INFO] GPlayCli version 3.29 [Python3.9.5] 
[INFO] Configuration file is /home/appuser/.local/etc/gplaycli/gplaycli.conf
[INFO] Device is bacon
[Errno 2] No such file or directory: '/home/appuser/.cache/gplaycli/token'
[INFO] Cache file does not exists or is corrupted
[INFO] Retrieving token ...
[INFO] Token URL is https://matlink.fr/token
[INFO] Email: gplaycli1@gmail.com
[INFO] Token: ya29.a0AfH6SMASh2qjvMwOtg45TuaWUYe1XNO49ApxOyOqJZoxT3jd7eWkLqWR6MEJXZdd__8BE7dU38dpyhb2Kchzk6V4eCQOlsQWMA5l6J83FyXb87t4oGIjKuKJlL1VEJ72X2D1-sk8K8Ja_aMVrUkw_SpbkJwUL8jcRJSJtqDWjXSXqncQ1FZgLQPZbla25TtVdZK7ObQuj6AgJyxGxIBy1YOknNGKMarkK-lrUKU3j2VN3wxB62UWzp7nocEXIGygWZDH7F3_bloj-5BvTJ9vsdN8f6wn1lMDWr3v-EQlkwZE_6F5Y4BRp2xEDp3XyIYx
[INFO] GsfId: 3123051ad8b7b3e0
[INFO] Using auto retrieved token to connect to API
Traceback (most recent call last):
  File "/home/appuser/.local/bin/gplaycli", line 33, in <module>
    sys.exit(load_entry_point('gplaycli==3.29', 'console_scripts', 'gplaycli')())
  File "/home/appuser/.local/lib/python3.9/site-packages/gplaycli/gplaycli.py", line 659, in main
    cli.download(args.download)
  File "/home/appuser/.local/lib/python3.9/site-packages/gplaycli/hooks.py", line 11, in check_connection
    return function(self, *args, **kwargs)
  File "/home/appuser/.local/lib/python3.9/site-packages/gplaycli/gplaycli.py", line 257, in download
    filename = "%s-v.%s.apk" % (detail['docid'], detail['details']['appDetails']['versionString'])
KeyError: 'versionString'

Enviroment can be reproduced as I run this tool from alpine container built by below ContainerFile:

build: podman build --pull --rm -t gplaycli -f ContainerFile run: podman run --rm --name gplaycli -ti gplaycli

FROM docker.io/alpine:edge

RUN set -ex; \
    apk update; \
    apk add --no-cache \
        rust \
        cargo \
        libffi-dev \
        python3-dev \
        libxslt-dev \
        libxml2-dev \
        openssl-dev \
        gcc \
        musl-dev \
        py3-pip; \
    adduser -D appuser;

USER appuser

RUN pip3 install -U gplaycli;
ford--prefect commented 3 years ago

Investigating this further reveals, that the version information is not returned (from google?) anymore, so determining the version number of the requested app fails. This renders the -av option broken. Leaving this option out brings me the well-known [DF-DFERH-01] error from #271

d78ui98 commented 3 years ago

@ford--prefect I wanted to know if there is any fix available or any workaround for this?

ford--prefect commented 3 years ago

@d78ui98 yes, don't use the -av flag