当前位置: 首页>>代码示例>>Python>>正文


Python GooglePlayAPI.download方法代码示例

本文整理汇总了Python中googleplay.GooglePlayAPI.download方法的典型用法代码示例。如果您正苦于以下问题:Python GooglePlayAPI.download方法的具体用法?Python GooglePlayAPI.download怎么用?Python GooglePlayAPI.download使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在googleplay.GooglePlayAPI的用法示例。


在下文中一共展示了GooglePlayAPI.download方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: download

# 需要导入模块: from googleplay import GooglePlayAPI [as 别名]
# 或者: from googleplay.GooglePlayAPI import download [as 别名]
def download():
    package = args.package
    filename = package + ".apk"

    # Connect
    api = GooglePlayAPI(args.device, lang='en_US')
    api.login(args.email, args.password, None)

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

    # Download
    if args.target_arch:
        str_target_arch = '-%s' % args.target_arch
    else:
        str_target_arch = ''
    filename = '%s%s-%s.apk' % (get_datetime(), str_target_arch, package)
    dir_out = args.dir_out
    if dir_out:
        filename = dir_out + '/' + filename

    data = api.download(package, vc, ot)
    open(filename, "wb").write(data)
开发者ID:Sgtransporterall,项目名称:share,代码行数:28,代码来源:apk.py

示例2: Downloader

# 需要导入模块: from googleplay import GooglePlayAPI [as 别名]
# 或者: from googleplay.GooglePlayAPI import download [as 别名]
class Downloader():

    def __init__(self):
        self.api = GooglePlayAPI(ANDROID_ID)
        self.api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    def download(self, pkg, filename):
        doc = self.api.details(pkg).docV2
        vc = doc.details.appDetails.versionCode

        data = self.api.download(pkg, vc)
        with open(filename, 'wb') as apk:
            apk.write(data)

    def downloadall(self, dbname, outdir, maxsize=None):
        mkdir(outdir)
        with sqlite3.connect(dbname, timeout=10) as db:
            with closing(db.cursor()) as cur:
                cur.execute(create)
                for pkg, size in cur.execute(select).fetchall():
                    print 'Processing %s (%s) ...' % (pkg, size)
                    if not sizeallowed(size, maxsize):
                        print Fore.YELLOW + '  [SKIP: too big (%s)]' % size
                        continue
                    path = os.path.join(outdir, pkg + '.apk')
                    try:
                        self.download(pkg, path)
                    except Exception as e:
                        print Fore.RED + '  [ERROR: %s]' % e.message
                    else:
                        print Fore.GREEN + '  [OK: downloaded to %s]' % path
                        cur.execute(insert, (pkg, path))
                        db.commit()
开发者ID:enricobacis,项目名称:playscraper,代码行数:35,代码来源:downloader.py

示例3: scrape

# 需要导入模块: from googleplay import GooglePlayAPI [as 别名]
# 或者: from googleplay.GooglePlayAPI import download [as 别名]
def scrape(id, package):

    packagename = package
    res = urllib2.urlopen("https://play.google.com/store/apps/details?id=%s&hl=en" % packagename)
    html = res.read()

    path = "assets/%d/" % id
    if not os.path.exists(path):
        os.makedirs(path)

    name = html.split('itemprop="name"')[1].split("</div>")[0].split("<div>")[1]
    desc = html.split('<div class="show-more-content text-body" itemprop="description">')[1].split(
        '<div class="show-more-end">'
    )[0]
    rating = html.split("Rated ")[1].split(" stars")[0]
    category = html.split('<span itemprop="genre">')[1].split("</span>")[0]

    stuff = []
    for line in html.split("</div>"):
        if "full-screenshot" in line:
            url = line.split('src="')[1][:-3]
            stuff.append(url)

    x = 0
    for img in stuff[1:]:
        print img
        urllib.urlretrieve(img, "%s%d.webp" % (path, x))
        x += 1

    filename = path + packagename + ".apk"

    # Connect
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

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

    # Download
    print "Downloading %s..." % sizeof_fmt(doc.details.appDetails.installationSize),
    data = api.download(packagename, vc, ot)
    open(filename, "wb").write(data)
    print "Done"
    ap = apk.APK(filename)
    badging = os.popen("/home/thomas/dev/android-odroid/out/host/linux-x86/bin/aapt dump badging %s" % filename).read()
    for line in badging.split("\n"):
        if "launchable-activity" in line:
            activity = line.split("'")[1]

    return [name, desc, rating, package, activity, category]
开发者ID:tliu,项目名称:mnectar_discovery_backend,代码行数:55,代码来源:scrape.py

示例4: download_apk

# 需要导入模块: from googleplay import GooglePlayAPI [as 别名]
# 或者: from googleplay.GooglePlayAPI import download [as 别名]
def download_apk(packagename, filename):
    # Connect
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

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

    # Download
    print "Downloading %s..." % sizeof_fmt(doc.details.appDetails.installationSize),
    data = api.download(packagename, vc, ot)
    open(filename, "wb").write(data)
    print "Done"
开发者ID:MingIsCoding,项目名称:CMPE281_SVR,代码行数:18,代码来源:download.py

示例5: exit

# 需要导入模块: from googleplay import GooglePlayAPI [as 别名]
# 或者: from googleplay.GooglePlayAPI import download [as 别名]
    exit(1)

doc = m.docV2
vc = doc.details.appDetails.versionCode

# Set the version code
if (len(sys.argv) == 3):
    vc = int(sys.argv[2])
else:
    vc = doc.details.appDetails.versionCode

# Genarate the filename with version code
if (len(sys.argv) == 4):
    filename = sys.argv[3] + ".vc" + str(vc) + ".apk"
else:
    filename = packagename + ".vc" + str(vc) + ".apk"

ot = doc.offer[0].offerType

# Download
print "versionCode:%d Downloading %s..." % (vc,
        sizeof_fmt(doc.details.appDetails.installationSize),)
data = api.download(packagename, vc, ot)
if data == False:
    print 'error in api.download'
    sys.exit(1)

open(filename, "wb").write(data)
print "Done"

开发者ID:magiauk,项目名称:googleplay-api,代码行数:31,代码来源:download.py

示例6: sizeof_fmt

# 需要导入模块: from googleplay import GooglePlayAPI [as 别名]
# 或者: from googleplay.GooglePlayAPI import download [as 别名]
    # print i.details.appDetails.packageName
    # APK version
    result['version'] = i.details.appDetails.versionCode
    # print i.details.appDetails.versionCode
    # APK size
    result['size'] = sizeof_fmt(i.details.appDetails.installationSize)
    # print sizeof_fmt(i.details.appDetails.installationSize)
    # Upload date
    result['upload_date'] = datetime.strptime(unicode(i.details.appDetails.uploadDate).encode('utf8'),
                                              locale_timestring[LANG]).strftime('%Y-%m-%d')
    # print datetime.strptime(unicode(i.details.appDetails.uploadDate).encode('utf8'),
    #                         "%Y\345\271\264%m\346\234\210%d\346\227\245").strftime('%Y-%m-%d')

    # Download APK
    result['apkdata'] = api.download(i.details.appDetails.packageName,
                                     i.details.appDetails.versionCode,
                                     i.offer[0].offerType)
    result.update(File(result['apkdata']).result)

    rank += 1
    try:
        DB().insert_apk(result)
    except KeyError:
        logging.warn("Maybe the apk already exists: {}".format(result['pgname']))
        # continue
        raise
    except:
        logging.error("DB insert error: {}".format(result['pgname']))
        raise
"""
if ctr is None:
开发者ID:sidra-asa,项目名称:gplay-apk-analysis,代码行数:33,代码来源:list.py


注:本文中的googleplay.GooglePlayAPI.download方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。