def getApps(api,category,subcategory,number,offset): ret = [] try: message = api.list(category, subcategory, number, offset) except: print "Error: HTTP 500 - one of the provided parameters is invalid" if (subcategory 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: try: print_result_line(c) package = c.docid name = c.title length = c.details.appDetails.installationSize if length>1024*1024*Size: print 'too large, skip' continue folder = DOWNLOAD_PATH + category if not os.path.exists(folder): os.mkdir(folder) filename = folder + '/' + name + '.apk' if not os.path.isfile(filename): downloadApps(api,package,filename) ret.append(package) except Exception as e: print e traceback.print_exc() continue return ret
def getApps(api, category, subcategory, number, offset): ret = [] try: message = api.list(category, subcategory, number, offset) except: print "Error: HTTP 500 - one of the provided parameters is invalid" if (subcategory 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: try: print_result_line(c) package = c.docid name = c.title length = c.details.appDetails.installationSize if length > 1024 * 1024 * 50: print 'too large, skip' continue folder = DOWNLOAD_PATH + category if not os.path.exists(folder): os.mkdir(folder) filename = folder + '/' + name + '.apk' if not os.path.isfile(filename): downloadApps(api, package, filename) ret.append(package) except: continue return ret
if (len(sys.argv) >= 4): nb_results = sys.argv[3] if (len(sys.argv) == 5): offset = sys.argv[4] # read config from config.py config = GooglePlayAPI.read_config() # connect to GooglePlayStore api = GooglePlayAPI(config['ANDROID_ID']) api.login(config['GOOGLE_LOGIN'], config['GOOGLE_PASSWORD'], config['AUTH_TOKEN']) try: message = api.list(cat, ctr, nb_results, offset) except: print("Error: HTTP 500 - one of the provided parameters is invalid") sys.exit(1) if (ctr is None): print("Subcategory ID", "Name", sep=config['SEPARATOR']) for doc in message.doc: print(helpers.str_compat(doc.docid), helpers.str_compat(doc.title), sep=config['SEPARATOR']) else: helpers.print_header_line() doc = message.doc[0] for c in doc.child: helpers.print_result_line(c)
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() print message doc = message.doc[0] for c in doc.child: print_result_line(c)
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] # read config from config.py config = GooglePlayAPI.read_config() # connect to GooglePlayStore api = GooglePlayAPI(config['ANDROID_ID']) api.login(config['GOOGLE_LOGIN'], config['GOOGLE_PASSWORD'], config['AUTH_TOKEN']) try: message = api.list(cat, ctr, nb_results, offset) except: print("Error: HTTP 500 - one of the provided parameters is invalid") sys.exit(1) if (ctr is None): print("Subcategory ID", "Name", sep=config['SEPARATOR']) for doc in message.doc: print(helpers.str_compat(doc.docid), helpers.str_compat(doc.title), sep=config['SEPARATOR']) else: helpers.print_header_line() doc = message.doc[0] for c in doc.child: helpers.print_result_line(c)
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)