예제 #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(credentials, lang="en_US"):
    """
    checkPlayStore(androidId):
    """
    logging.debug('Logging in to Play Store with: ' + credentials.androidId)
    playstore = GooglePlayAPI(credentials.androidId,lang)
    if playstore.login(credentials.email,credentials.password,credentials.authSubToken):
        for apkid in Global.report.dAllApks.keys():
            wait = credentials.delay+random.randint(0, credentials.delay)
            logging.info('Pausing {0} before searching for: {1}, waiting {2} seconds'.format(playstore.androidId,apkid,wait))
            time.sleep(wait)
            avi = getApkInfo(playstore, apkid, credentials.delay)
            if avi:
                if Global.report.isThisApkNeeded(avi):
                    logging.debug('Update {0} {1}-{2}'.format(avi.name,avi.ver,avi.vercode))
                    downloadApk(avi, delay)
                else:
                    logging.debug('Skip {0} {1}-{2}'.format(avi.name,avi.ver,avi.vercode))
            #else:
                #logging.debug('No Play Store result for {0}'.format(apkid))
            # END: if avi
        # END: for apkid in Global.report.dAllApks.keys()
    else:
        logging.error('Play Store login failed for {0}'.format(credentials.androidId))
예제 #3
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)
예제 #4
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)
예제 #5
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
예제 #6
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())
예제 #7
0
import sys
import urlparse
from pprint import pprint
from google.protobuf import text_format

from googleplayapi.config import *
from googleplayapi.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
예제 #8
0
    print "subcategory: You can get a list of all subcategories available, by supplying a valid category"
    sys.exit(0)

cat = sys.argv[1]
ctr = None
nb_results = None
offset = None

if len(sys.argv) >= 3:
    ctr = sys.argv[2]
if len(sys.argv) >= 4:
    nb_results = sys.argv[3]
if len(sys.argv) == 5:
    offset = sys.argv[4]

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
try:
    message = api.list(cat, ctr, nb_results, offset)
except:
    print "Error: HTTP 500 - one of the provided parameters is invalid"

if ctr is None:
    print SEPARATOR.join(["Subcategory ID", "Name"])
    for doc in message.doc:
        print SEPARATOR.join([doc.docid.encode("utf8"), doc.title.encode("utf8")])
else:
    print_header_line()
    doc = message.doc[0]
    for c in doc.child:
        print_result_line(c)
예제 #9
0
if (len(sys.argv) < 2):
    print "Usage: %s request [nb_results] [offset]" % sys.argv[0]
    print "Search for an app."
    print "If request contains a space, don't forget to surround it with \"\""
    sys.exit(0)

request = sys.argv[1]
nb_res = None
offset = None

if (len(sys.argv) >= 3):
    nb_res = int(sys.argv[2])

if (len(sys.argv) >= 4):
    offset = int(sys.argv[3])

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

try:
    message = api.search(request, nb_res, offset)
except:
    print "Error: something went wrong. Maybe the nb_res you specified was too big?"
    sys.exit(1)

print_header_line()
doc = message.doc[0]
for c in doc.child:
    print_result_line(c)

예제 #10
0
#!/usr/bin/python

import sys
import urlparse
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)
response = api.browse()

print SEPARATOR.join(["ID", "Name"])
for c in response.category:
  print SEPARATOR.join(i.encode('utf8') for i in [urlparse.parse_qs(c.dataUrl)['cat'][0], c.name])

예제 #11
0
    print "subcategory: You can get a list of all subcategories available, by supplying a valid category"
    sys.exit(0)

cat = sys.argv[1]
ctr = None
nb_results = None
offset = None

if (len(sys.argv) >= 3):
    ctr = sys.argv[2]
if (len(sys.argv) >= 4):
    nb_results = sys.argv[3]
if (len(sys.argv) == 5):
    offset = sys.argv[4]

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
try:
    message = api.list(cat, ctr, nb_results, offset)
except:
    print "Error: HTTP 500 - one of the provided parameters is invalid"

if (ctr is None):
    print SEPARATOR.join(["Subcategory ID", "Name"])
    for doc in message.doc:
        print SEPARATOR.join(
            [doc.docid.encode('utf8'),
             doc.title.encode('utf8')])
else:
    print_header_line()
    doc = message.doc[0]
예제 #12
0
import sys
import urlparse
from pprint import pprint
from google.protobuf import text_format

from googleplayapi.config import *
from googleplayapi.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')