forked from egirault/googleplay-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdownload.py
executable file
·41 lines (31 loc) · 974 Bytes
/
download.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
# Do not remove
GOOGLE_LOGIN = GOOGLE_PASSWORD = AUTH_TOKEN = None
import sys
from pprint import pprint
from config import *
from googleplay import GooglePlayAPI
from helpers import sizeof_fmt
if (len(sys.argv) < 2):
print "Usage: %s packagename [filename]"
print "Download an app."
print "If filename is not present, will write to packagename.apk."
sys.exit(0)
packagename = sys.argv[1]
if (len(sys.argv) == 3):
filename = sys.argv[2]
else:
filename = 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"