예제 #1
0
    def checkPlayStore(self, credentials, lang="en_US"):
        """
        checkPlayStore(androidId):
        """
        filenames = []
        logging.debug('Logging in to Play Store with: ' + credentials.androidId)
        playstore = GooglePlayAPI(credentials.androidId, lang)
        if playstore.login(authSubToken=credentials.authSubToken):
            logging.info('{0} searches Play in {1} seconds'.format(credentials.androidId, credentials.delay))
            time.sleep(credentials.delay)

            if 'com.android.vending' in self.report.getAllApkIds():
                for storeApk in self.report.dAllApks['com.android.vending']:
                    logging.debug('{0} VendingAPK: vername={1}, vercode={2}'.format(credentials.androidId, storeApk.ver, storeApk.vercode))
                    playvercode = playstore.playUpdate(storeApk.ver, str(storeApk.vercode))
                    if playvercode:
                        logging.debug('{0} Play Store update {1}'.format(credentials.androidId, playvercode))
                        avi = ApkVersionInfo(name        ='com.android.vending',
                                             vercode     =playvercode,
                                             download_src=playstore,
                                             crawler_name=self.__class__.__name__
                                             )
                        filenames.append(self.downloadApk(avi, credentials.delay + random.randint(0, credentials.delay), agentvername=storeApk.ver, agentvercode=str(storeApk.vercode)))
                        logging.info('{0} pauses {1} seconds before continuing'.format(credentials.androidId, credentials.delay))
                        time.sleep(credentials.delay)
            else:
                logging.debug('{0} vending apk not in report'.format(credentials.androidId))
 
            for sdk in [19, 21, 22, 23, 24]:
                logging.debug('{0} - {1}'.format(sdk, self.report.getAllApkIds(playstoreCaps=True)))
                res = playstore.bulkDetails(self.report.getAllApkIds(playstoreCaps=True), sdk)
                if res and res.status_code == http.client.OK and res.body:
                    for app in res.body.entry:
                        if app.doc and app.doc.docid:
                            avi = ApkVersionInfo(name        =app.doc.docid,
                                                 vercode     =app.doc.details.appDetails.versionCode,
                                                 download_src=playstore,
                                                 crawler_name=self.__class__.__name__
                                                 )
                            if self.report.isThisApkNeeded(avi):
                                logging.debug('{0} Update {1}-{2} (Uploaddate {3})'.format(playstore.androidId, avi.name, avi.vercode, app.doc.details.appDetails.uploadDate))
                                filenames.append(self.downloadApk(avi, credentials.delay + random.randint(0, credentials.delay)))
                            else:
                                logging.debug('{0} Skip {1}-{2} (Uploaddate {3})'.format(playstore.androidId, avi.name, avi.vercode, app.doc.details.appDetails.uploadDate))
                        else:
                            logging.debug('{0} Empty search entry'.format(playstore.androidId))
                            continue
                else:
                    logging.error('{0} Error querying Play Store, status {1}: {2}'.format(playstore.androidId, sdk, res.status_code))
                    return None  # Not found, return empty
            # END: for sdk
        else:
            logging.error('Play Store login failed for {0}'.format(credentials.androidId))
        # END: if playstore.login()
        return filenames
예제 #2
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(androidId=ANDROID_ID, email=GOOGLE_LOGIN, password=GOOGLE_PASSWORD, authSubToken=AUTH_TOKEN)

# login if necessary
if not AUTH_TOKEN:
    # api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
    api.login()

# 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)
예제 #3
0
def getToken(androidId, email, password, lang="en_US"):
    '''
    getToken(): Retrieve a Play Store authToken
    '''
    logging.info('{0} requests authToken'.format(androidId))
    return GooglePlayAPI(androidId, lang).login(email, password)
예제 #4
0
#!/usr/bin/python

BANNER = """
Google Play Unofficial API Interactive Shell
Successfully logged in using your Google account. The variable 'api' holds the API object.
Feel free to use help(api).
"""

import sys
import urlparse
import code
from pprint import pprint
from google.protobuf import text_format

from googleplayapi.config import *
from googleplayapi.googleplay import GooglePlayAPI

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
code.interact(BANNER, local=locals())