rehmatworks / gplaydl

Command Line Google Play APK downloader. Download APK files to your PC directly from Google Play Store.
MIT License
352 stars 55 forks source link

RequestError: Error retrieving information from server. DF-DFERH-01 #27

Open vadimszzz opened 3 years ago

vadimszzz commented 3 years ago

import re
import io

import click
from gpapidl.googleplay import GooglePlayAPI
from dotenv import dotenv_values

dictfilter = lambda fun, _dict: dict(filter(lambda x: fun(x[1]) if fun else x[1], _dict.items()))
dictfilterkey = lambda fun, _dict: dict(filter(lambda x: fun(x[0]) if fun else x[0], _dict.items()))
dictmap = lambda fun, _dict: dict(map(lambda x: (x[0], fun(x[1])), _dict.items()))
dictmapkey = lambda fun, _dict: dict(map(lambda x: (fun(x[0]), x[1]), _dict.items()))

def sizeof_fmt(num):
    num = float(num)
    for x in ['bytes','KB','MB','GB','TB']:
        if num < 1024.0:
            return "%3.1f%s" % (num, x)
        num /= 1024.0

def download_package(packagename_or_url, output=None, country="us"):
    """ download a package from the Google Play Store """

    # Parse arguments
    if re.fullmatch(r"([A-Za-z]{1}[A-Za-z\d_]*\.)+[A-Za-z][A-Za-z\d_]*", packagename_or_url):
        packagename = packagename_or_url
    elif re.match(r".*\?id=([A-Za-z]{1}[A-Za-z\d_]*\.)+[A-Za-z][A-Za-z\d_]*", packagename_or_url):
        packagename = re.match(r".*\?id=(([A-Za-z]{1}[A-Za-z\d_]*\.)+[A-Za-z][A-Za-z\d_]*)", packagename_or_url)[1]
    else:
        exit("Wrong APPID or URL.")
    if country not in COUNTRY_CODES.keys():
        exit("Wrong country code.")

    # Read config from .env
    config = dictmap(lambda v: v or None, dotenv_values(".env"))
    proxies_config = dictfilterkey(lambda k: k in ["HTTP_PROXY", "HTTPS_PROXY"], dictfilter(None, config))
    proxies_config = dictmapkey(lambda k: k.lower(), proxies_config)

    # Connect to Google Play Store
    api = GooglePlayAPI(locale=config['LOCALE'], device_codename="shamu", proxies_config=proxies_config)
    api.login(config['GOOGLE_LOGIN'], config['GOOGLE_PASSWORD'], config['GOOGLE_AUTH_TOKEN'])

    # Get the version code and the offer type from the app details
    m = api.details(packagename)
    vc = m["details"]["appDetails"]["versionCode"]
    ot = m["offer"][0]["offerType"]

    if output == None:
        output = f"{packagename}_{vc}.apk"

    # Download
    print("Downloading to file %s with size %s..." % (output, sizeof_fmt(m["details"]["appDetails"]["installationSize"])))
    data = api.download(output, vc, ot)
    io.open(output, "wb").write(data)
    print("Done")
x@192-168-10-195 ******* % python -m ******* gp download com.smartprojects.MemoryLocker
Downloading to file com.smartprojects.MemoryLocker_35.apk with size 2.7MB...
[!] RequestError: Error retrieving information from server. DF-DFERH-01
x@192-168-10-195 ******* % python -m ******* gp download com.smartprojects.MemoryLocker --trace
Downloading to file com.smartprojects.MemoryLocker_35.apk with size 2.7MB...
Traceback (most recent call last):
  File "/Users/x/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/x/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/x/Downloads/Projects/*******/*******/__main__.py", line 35, in <module>
    cli()
  File "/Users/x/Downloads/Projects/*******/*******/__main__.py", line 23, in cli
    cli_commands()
  File "/Users/x/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/Users/x/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/Users/x/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/x/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/x/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/x/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/Users/x/Downloads/Projects/*******/*******/cli/gp.py", line 207, in download
    download_package(**kwargs)
  File "/Users/x/Downloads/Projects/*******/*******/cli/gp.py", line 114, in download_package
    data = api.download(output, vc, ot)
  File "/Users/x/.pyenv/versions/3.9.0/lib/python3.9/site-packages/gpapidl/googleplay.py", line 625, in download
    raise RequestError(response.commands.displayErrorMessage)
gpapidl.googleplay.RequestError: 'Error retrieving information from server. DF-DFERH-01'
vadimszzz commented 3 years ago

The same issue https://github.com/matlink/gplaycli/issues/271

vadimszzz commented 2 years ago

I have an alternate tool that works:

googleplay -a com.smartprojects.MemoryLocker -v 35

https://github.com/89z/googleplay

Thx, I know that you develop this nice tool. But I need a python library. I already found one that's working, it was hard because github is a big dumpster.

adtimizer commented 2 years ago

@vadimszzz are you facing issues with the library since yesterday? Did you find another tool? you mentioned you found something that's working