예제 #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
    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']:
                    try:
                        if storeApk.extraname and storeApk.extraname.endswith('leanback'):
                            devicename = 'fugu'
                        else:
                            devicename = 'sailfish'
                        logging.debug('{0} VendingAPK: vername={1}, vercode={2}, devicename={3}'.format(credentials.androidId, storeApk.ver, storeApk.vercode, devicename))
                        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), devicename=devicename))
                            logging.info('{0} pauses {1} seconds before continuing'.format(credentials.androidId, credentials.delay))
                            time.sleep(credentials.delay)
                    except:
                        logging.exception('!!! playstore.playUpdate({0}, {1}) exception ...'.format(storeApk.ver, storeApk.vercode))
                    # END: try
                # END: for storeApk
            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