本文整理汇总了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)
示例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()
示例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]
示例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"
示例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"
示例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: