Exemple #1
0
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)
Exemple #2
0
def run(packagename):

    if (len(sys.argv) == 3):
        filename = sys.argv[2]
    else:
        filename = packagename + ".apk"


# Connect
    api = GooglePlayAPI(config.ANDROID_ID)

    api.login(config.GOOGLE_LOGIN, config.GOOGLE_PASSWORD, config.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"
Exemple #3
0
def getPermissions(packageName, multiple=False):

    api = GooglePlayAPI(config.ANDROID_ID)
    api.login(config.GOOGLE_LOGIN, config.GOOGLE_PASSWORD, config.AUTH_TOKEN)
    result = {}
    # Only one app
    if (not multiple):
        response = api.details(packageName)
        permissions = []
        values = response.docV2.details.appDetails.permission._values
        permissions = [x.encode('utf-8') for x in values]
        name = response.docV2.title
        result["name"] = name.encode("utf8")
        result["permissions"] = permissions
        logo = response.docV2.image._values[0]
        image = logo.imageUrl.encode("utf8")
        result["logo"] = image
        return result

    else:  # More than one app, not tested or used
        response = api.bulkDetails(packageName)
        for entry in response.entry:
            if (not not entry.ListFields()):  # if the entry is not empty
                result[
                    entry.doc.docid] = entry.doc.details.appDetails.permission
        return result
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()
Exemple #5
0
def getPackagePermission(packagenames,androidId):
	api = GooglePlayAPI(androidId)
	'''
		Prajit Das: Cycling through the different androidIds we have 
		to ensure that we are not blocked by Google
		The following statement was the original code
	'''
	#api = GooglePlayAPI(ANDROID_ID)
	api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
	
	# Only one app
	if (len(packagenames) == 1):
		response = api.details(packagenames[0])
		permissionList = []
		#print "\n".join(i.encode('utf8') for i in response.docV2.details.appDetails.permission)
		for permission in response.docV2.details.appDetails.permission:
			permissionList.append(permission.encode('utf8'))
		for permission in permissionList: print permission
		return permissionList
	
	else: # More than one app
		permissionListDict = {}
		response = api.bulkDetails(packagenames)
		for entry in response.entry:
			if (not not entry.ListFields()): # if the entry is not empty
				permissionList = []
#				 print entry.doc.docid + ":"
#				 print "\n".join("	"+i.encode('utf8') for i in entry.doc.details.appDetails.permission)
				for permission in entry.doc.details.appDetails.permission:
					permissionList.append(permission.encode('utf8'))
				for permission in permissionList: print permission

				permissionListDict[entry.doc.docid] = permissionList
				return permissionListDict
Exemple #6
0
def main():
    search_term = sys.argv[1]
    '''
    apps will be a list of dicts describing each returned app:
    {'app_name':<app name>,'app_id':<app id>,'app_creator':<creator>,'app_permissions':[list]}
    '''
    apps = []
    nb_res = 100 # apps to retrieve. API allows for max of 100.
    offset = 0 
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
    try:
        message = api.search(search_term, nb_res, offset)
    except:
        print "Error: something went wrong. Google may be throttling or rejecting the request."
        sys.exit(1)

    doc = message.doc[0]
    for c in doc.child:
        permissions = []
        details = api.details(c.docid)
        for line in details.docV2.details.appDetails.permission:
            permissions.append(line)
        apps.append({'app_name':c.title,'app_id':c.docid,'app_creator':c.creator,'app_permissions':permissions})

    '''
    We are interested in the set of all possible permissions that start with 'ANDROID.'
    '''
    permissions = Set([])
    for app in apps:
        for permission in app["app_permissions"]:
            if  permission.upper()[0:8] == "ANDROID.":
                permissions.add(permission.upper())

    '''
    Create ARFF output for Weka
    '''
    dataset = open(search_term + ".arff",'w')
    dataset.write("@relation Appdata\n")
    dataset.write("@attribute index NUMERIC\n")
    dataset.write("@attribute app_name STRING\n")
    for att in permissions:
        dataset.write("@attribute "+ att + " {0,1}\n")
    dataset.write("@data\n")
    i = 0 # index for cross-referencing
    for app in apps:
        print("{} {}").format(str(i), str(app)) # index
        perm_str = str(i) + ',' + app['app_id'] + ','
        app_perm_upper = []
        for app_permission in app['app_permissions']:
            app_perm_upper.append(app_permission.upper())
        for permission in permissions:
            if permission in app_perm_upper:
                perm_str = perm_str + '1,'
            else:
                perm_str = perm_str + '0,'
        dataset.write(perm_str[:-1])
        dataset.write("\n")
        i += 1
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]
Exemple #8
0
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"
Exemple #9
0
import requests
import sys
from pprint import pprint

from config import *
from googleplay import GooglePlayAPI
from helpers import sizeof_fmt, print_header_line, print_result_line
from google.protobuf import text_format
from requests.packages.urllib3.exceptions import InsecureRequestWarning

if (len(sys.argv) < 2):
     print "\nUsage: %s appPackageName." % sys.argv[0]
     print "Retrieves the details (i.e. description, URL to screenshots etc) of a specific app.\n"
     sys.exit(0)

# Dealing with user's parameter
appname = sys.argv[1]

# Ignore unverified HTTPS request warning.
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

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

#invoking api method to get the app details.
detailsResponse = api.details(appname)
print text_format.MessageToString(detailsResponse)


Exemple #10
0
from google.protobuf import text_format

from config import *
from googleplay import GooglePlayAPI

if (len(sys.argv) < 2):
    print "Usage: %s packagename1 [packagename2 [...]]" % sys.argv[0]
    print "Display permissions required to install the specified app(s)."
    sys.exit(0)

packagenames = sys.argv[1:]

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

# Only one app
if (len(packagenames) == 1):
    response = api.details(packagenames[0])
    print "\n".join(
        i.encode('utf8') for i in response.docV2.details.appDetails.permission)

else:  # More than one app
    response = api.bulkDetails(packagenames)

    for entry in response.entry:
        if (not not entry.ListFields()):  # if the entry is not empty
            print entry.doc.docid + ":"
            print "\n".join("    " + i.encode('utf8')
                            for i in entry.doc.details.appDetails.permission)
            print
Exemple #11
0
class GoogleAnalysis(object):
    """docstring for GoogleAnalysis."""
    def __init__(self):
        super(GoogleAnalysis, self).__init__()
        self.api = GooglePlayAPI(ANDROID_ID)
        self.api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    def category_list(self):
        response = self.api.browse()
        return list(
            map(
                lambda c: SEPARATOR.join(
                    i.encode('utf8')
                    for i in [urlparse.parse_qs(c.dataUrl)['browse?cat'][0]]),
                response.category))

    def read_files(self, cate):
        with open(dirname(__file__) + '/resource_list/' + cate + '.txt',
                  'r') as f:
            for line in f.readlines():
                filename = line.strip()
                print Color.Green + '[!] Start:  ' + Color.NoCo + filename
                self.details(filename)

    def details(self, packageName):
        message = self.api.details(packageName).docV2
        result = {
            "docid": message.docid,
            "title": message.title,
            "creator": message.creator,
            "descriptionHtml": message.descriptionHtml,
            "offer": {
                "currencyCode": message.offer[0].currencyCode,
                "formattedAmount": message.offer[0].formattedAmount
            },
            "details": {
                "appDetails": {
                    "developerName": message.details.appDetails.developerName,
                    "versionCode": message.details.appDetails.versionCode,
                    "versionString": message.details.appDetails.versionString,
                    "contentRating": message.details.appDetails.contentRating,
                    "installationSize":
                    message.details.appDetails.installationSize,
                    # "permission": message.details.appDetails.permission,
                    "numDownloads": message.details.appDetails.numDownloads,
                    "packageName": message.details.appDetails.packageName,
                    "uploadDate": message.details.appDetails.uploadDate,
                }
            },
            "aggregateRating": {
                "starRating": message.aggregateRating.starRating,
                "ratingsCount": message.aggregateRating.ratingsCount,
                "oneStarRatings": message.aggregateRating.oneStarRatings,
                "twoStarRatings": message.aggregateRating.twoStarRatings,
                "threeStarRatings": message.aggregateRating.threeStarRatings,
                "fourStarRatings": message.aggregateRating.fourStarRatings,
                "fiveStarRatings": message.aggregateRating.fiveStarRatings,
                "commentCount": message.aggregateRating.commentCount
            }
        }

        doc = message
        vc = doc.details.appDetails.versionCode
        ot = doc.offer[0].offerType
        self.download(packageName, vc, ot)

        with open(
                dirname(abspath(__file__)) + '/detail_reports/' + packageName,
                'w') as f:
            json.dump(result,
                      f,
                      sort_keys=True,
                      indent=4,
                      separators=(',', ': '))
            f.close()
        # print json.dumps(result, sort_keys=True, indent=4, separators=(',', ': '))

    def download(self, packageName, vc, ot):
        data = self.api.download(packageName, vc, ot)

        with open(
                dirname(abspath(__file__)) + '/apk_files/' + packageName +
                '.apk', 'w') as f:
            f.write(data)
            print "Done"
            f.close()

    def test(self):
        lists = list('!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c')
        for i in lists:
            try:
                print self.api.list('ART_AND_DESIGN', 'apps_topselling_free',
                                    '1', 'CA' + i)
            except:
                print i
Exemple #12
0
def retrieveCategoryPackageNames(request):

    nb_res = None
    offset = None
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)


    packageNamesList = []
    #print_header_line()

    # continue requesting until receive ALL apps by category. use to make histogram.
    while True:
        try:
            message = api.search(request, nb_res, offset)
        except:
            break

        if message.doc:
            doc = message.doc[0]

            for c in doc.child:
                packageNamesList.append(c.docid)
            offset = len(packageNamesList)
        else:
            break

    dic = {}
    final_results = {}

    # Only one app returned TODO update this
    if (len(packageNamesList) == 1):
        response = api.details(packageNamesList[0])
        print "\n".join(i.encode('utf8') for i in response.docV2.details.appDetails.permission)

    # More than one app
    else:
        response = api.bulkDetails(packageNamesList)

        for entry in response.entry:
            hasCustom = False
            if (entry.ListFields()):
                iconUrl = ""
                for x in entry.doc.image:
                    if x.imageType == 4:
                        iconUrl = x.imageUrl
                final_results[entry.doc.docid] = {'package': entry.doc.docid, 'title':entry.doc.title, 
                                          'creator':entry.doc.creator, 
                                          'price':{'amount':entry.doc.offer[0].formattedAmount, 'currency':entry.doc.offer[0].currencyCode}, 
                                          'icon':iconUrl,
                                          'permissions':[perm for perm in entry.doc.details.appDetails.permission],
                                          'rating':{'stars':entry.doc.aggregateRating.starRating, 'count':entry.doc.aggregateRating.ratingsCount},
                                          'shareUrl': entry.doc.shareUrl 
                                          }
                for permission in entry.doc.details.appDetails.permission:
                    # apps can have custom permissions that don't start with android.permission.PERM_NAME_HERE
                    # are they safe? Will warn users about custom permissions.
                    perm = permission.split(".")
                    if (permission != "com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" and permission != "com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" and (len(perm) !=3 or perm[0] != "android" or perm[1] != "permission")):
                        hasCustom = True
                        continue # don't want to count custom permissions in the histogram dictionary since they will all of them will be unusual
                    #perm = perm[-2] + "." + perm[-1]
                    if permission in dic:
                        dic[permission] += 1;
                    else:
                        dic[permission] = 1;
                final_results[entry.doc.docid]['custom'] = hasCustom
    #print dic

    DANGEROUS_PERMS = ["android.permission.ACCESS_COARSE_LOCATION",
                       "android.permission.ACCESS_FINE_LOCATION",
                       "android.permission.ACCESS_MOCK_LOCATION",
                       "android.permission.AUTHENTICATE_ACCOUNTS",
                       "android.permission.BLUETOOTH",
                       "android.permission.BLUETOOTH_ADMIN",
                       "android.permission.CALL_PHONE",
                       "android.permission.CAMERA",
                       "android.permission.CHANGE_CONFIGURATION",
                       "android.permission.CHANGE_NETWORK_STATE",
                       "android.permission.CHANGE_WIFI_MULTICAST_STATE",
                       "android.permission.CHANGE_WIFI_STATE",
                       "android.permission.CLEAR_APP_CACHE",
                       "android.permission.DUMP",
                       "android.permission.GET_TASKS",
                       "android.permission.INTERNET",
                       "android.permission.MANAGE_ACCOUNTS",
                       "android.permission.MODIFY_AUDIO_SETTINGS",
                       "android.permission.MODIFY_PHONE_STATE",
                       "android.permission.MOUNT_FORMAT_FILESYSTEMS",
                       "android.permission.MOUNT_UNMOUNT_FILESYSTEMS",
                       "android.permission.PERSISTENT_ACTIVITY",
                       "android.permission.PROCESS_OUTGOING_CALLS",
                       "android.permission.READ_CALENDAR",
                       "android.permission.READ_CONTACTS",
                       "android.permission.READ_LOGS",
                       "android.permission.READ_OWNER_DATA",
                       "android.permission.READ_PHONE_STATE",
                       "android.permission.READ_SMS",
                       "android.permission.READ_USER_DICTIONARY",
                       "android.permission.RECEIVE_MMS",
                       "android.permission.RECEIVE_SMS",
                       "android.permission.RECEIVE_WAP_PUSH",
                       "android.permission.RECORD_AUDIO",
                       "android.permission.REORDER_TASKS",
                       "android.permission.SEND_SMS",
                       "android.permission.SET_ALWAYS_FINISH",
                       "android.permission.SET_ANIMATION_SCALE",
                       "android.permission.SET_DEBUG_APP",
                       "android.permission.SET_PROCESS_LIMIT",
                       "android.permission.SET_TIME_ZONE",
                       "android.permission.SIGNAL_PERSISTENT_PROCESSES",
                       "android.permission.SUBSCRIBED_FEEDS_WRITE",
                       "android.permission.SYSTEM_ALERT_WINDOW",
                       "android.permission.USE_CREDENTIALS",
                       "android.permission.WAKE_LOCK",
                       "android.permission.WRITE_APN_SETTINGS",
                       "android.permission.WRITE_CALENDAR",
                       "android.permission.WRITE_CONTACTS",
                       "android.permission.WRITE_EXTERNAL_STORAGE",
                       "android.permission.WRITE_OWNER_DATA",
                       "android.permission.WRITE_SETTINGS",
                       "android.permission.WRITE_SMS",
                       "android.permission.WRITE_SYNC_SETTINGS",
                       "com.android.browser.permission.READ_HISTORY_BOOKMARKS",
                       "com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"]
    #go through final_results and add field for unusual permissions
    for docid in final_results: 
        final_results[docid]['unusual'] = False
        final_results[docid]['dangerous'] = False
        for permission in final_results[docid]['permissions']:
            perm = permission.split(".")
            if (permission != "com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" and permission != "com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" and (len(perm) !=3 or perm[0] != "android" or perm[1] != "permission")):
                continue
            elif dic[permission] < 0.05*offset:
                final_results[docid]['unusual'] = True
                if 'unusual_perms' in final_results[docid]:
                    final_results[docid]['unusual_perms'].append(permission)
                else:
                    final_results[docid]['unusual_perms'] = [permission]
                if permission in DANGEROUS_PERMS:
                    final_results[docid]['dangerous'] = True
                    if 'dangerous_permissions' in final_results[docid]:
                        final_results[docid]['dangerous_permissions'].append(permission)
                    else:
                        final_results[docid]['dangerous_permissions'] = [permission]

    final = json.dumps({"app": final_results.values()})
    print final
    return None
Exemple #13
0
    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)
if m == False:
    print 'error in api.details'
    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):
Exemple #14
0
import urlparse
import code
from pprint import pprint
from google.protobuf import text_format

from config import *
from googleplay import GooglePlayAPI
import os
import requests

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

package_name = "com.tellm.android.app"

r = api.details(package_name)
version = r.docV2.details.appDetails.versionString
date = r.docV2.details.appDetails.uploadDate
version_code = r.docV2.details.appDetails.versionCode
file_size = r.docV2.details.appDetails.installationSize

print "current version is ", version, "published on ", date
f_name = "/root/jodeldecompile/apks/com.tellm.android.app-%s.apk" % version

if os.path.isfile(f_name) and os.path.getsize(f_name) == file_size:
    print "already downloaded"
else:
    print "downloading apk to %s" % f_name

    data = api.download(package_name, version_code)
    with open(f_name, "wb") as f:
from pprint import pprint
from google.protobuf import text_format

from __init__ import *
from googleplay import GooglePlayAPI

if (len(sys.argv) < 2):
    print "Usage: %s packagename1 [packagename2 [...]]" % sys.argv[0]
    print "Display permissions required to install the specified app(s)."
    sys.exit(0)

packagenames = sys.argv[1:]

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

# Only one app
if (len(packagenames) == 1):
    response = api.details(packagenames[0])
    print "\n".join(i.encode('utf8') for i in response.docV2.details.appDetails.permission)

else: # More than one app
    response = api.bulkDetails(packagenames)

    for entry in response.entry:
        if (not not entry.ListFields()): # if the entry is not empty
            print entry.doc.docid + ":"
            print "\n".join("    "+i.encode('utf8') for i in entry.doc.details.appDetails.permission)
            print

Exemple #16
0
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("3eded73a231f2845")
api.login("*****@*****.**", "gruegrue", 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"
Exemple #17
0
#!/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, print_header_line, print_result_line, print_result_json

if (len(sys.argv) < 2):
    print "Usage: %s packageName(;packageName)" % sys.argv[0]
    print "Details for an applications."
    sys.exit(0)

packageNames = sys.argv[1].split(";")

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

for packageName in packageNames:
    try:
        message = api.details(packageName)
    except:
        continue

    # print if nothing wrong
    print_result_json(message.docV2)
   
elif (len(sys.argv) >= 3):
    print "Wrong input, there may be a tab character!"
    sys.exit(0)


# Check request content   
print "packageName:",packageName


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

#for i in range(MAX_RESULTS/NB_RESULTS):
    
response = api.details(packageName)
#j = response.getResponse
c = response.docV2

CATEGORY = c.details.appDetails.appCategory
print "anh yeu em"
print c
            #print j.docid.encode('utf8')
            #write_result_line(j,saveFile)
print "Em khong yeu anh"
print_details_line(c)
l = [           
               
                c.docid, # unicode type
                c.title, # unicode type
                c.details.appDetails.appCategory, # class type
Exemple #19
0
def download_apk_via_url(apk):
    GOOGLE_LOGIN = "******"
    GOOGLE_PASSWORD = "******"
    AUTH_TOKEN = "aAX_7XGsaT4B5hIDvtdh8oM-R7B5iidTCgHxXOKQXXFDFdmdzPcXKslTr6SX0YpiDMIORA."
    f = 0
    head, sep, tail = apk.partition('&')
    apk = head
    msg = ""
    if "." in apk:
        if (apk.startswith('http')):
            if "play.google.com/store/apps/details?id=" in apk:
                print "Link:" + apk
                link, packagename = apk.split("=")
            else:
                message = "Wrong URL!"
                return message
        else:
            packagename = apk
    else:
        message = "Invalid Package Name"
        return message

    if (len(sys.argv) == 3):
        filename = sys.argv[2]
    else:
        filename = packagename + ".apk"
    print("Package Name: " + packagename)
    # Connect
    requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
    try:
        # 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
        size = sizeof_fmt(doc.details.appDetails.installationSize)
        l = len(size)
        ext = size[(l - 2):l]
        size = size[:-2]
        if ext == "MB":
            f = float(size)
        if ext == "GB":
            f = float(size) * 1024
        if f > float(200):
            message = "App Size is Greater than 200MB. Please Enter a Different URL or Package Name"
            return message

        # Download
        print "Downloading %s..." % sizeof_fmt(
            doc.details.appDetails.installationSize),
        data, msg = api.download(packagename, vc, ot)
        DIR = settings.BASE_DIR
        ANAL_DIR = os.path.join(DIR)
        fullpath = ANAL_DIR + '/uploads/' + packagename + ".apk"
        open(fullpath, "wb").write(data)
        print "APK Downloaded!"
        return fullpath

    except Exception as e:
        print "Not able to fetch the apk: {}".format(e)
        if "Google Play purchases are not supported in your country" in msg:
            message = """App region isn't supported by the platform."""
        elif "does not support this purchase." in msg:
            message = """The platform doesn't support paid app download."""
        else:
            message = "Sorry! We are not able to fetch the APK at this moment. Please upload the APK."
        return message