def _login(self): ''' user android_id, user name and password or AUTH_TOKEN to login ''' self._configTest() api = GooglePlayAPI(self._android_id) api.login(self._user, self._passwd, self._auth_token) return api
def __init__(self): try: creds = loadPlayStoreConfig() self.googleLogin = creds['GOOGLE_LOGIN'] self.googlePassword = creds['GOOGLE_PASSWORD'] self.androidID = creds['ANDROID_ID'] self.authToken = creds['AUTH_TOKEN'] self.api = GooglePlayAPI(self.androidID) # Login to the Play Store except Exception as e: prettyPrintError(e)
def init_api(acct_email, acct_password, gsf): global api if api is None: # Ensure we have all the credentials we need assert acct_email is not None, 'Account email address is required' assert acct_password is not None, 'Account password is required' assert gsf is not None, 'Google Services Framework ID is required' # Authenticate the API api = GooglePlayAPI(androidId=gsf) api.login(email=acct_email, password=acct_password)
def connect(): """ Connect to GooglePlayStore using the googleplay-api """ global config api = GooglePlayAPI(androidId=config["ANDROID_ID"], lang=config["LANG"]) try: api.login(config["GOOGLE_LOGIN"], config["GOOGLE_PASSWORD"], config["AUTH_TOKEN"]) except LoginError as exc: logging.error("Connection to PlayStore failed: %s" % exc) return None logging.info("Connection to GooglePlayStore established") return api
def init_api(acct_email, acct_password, gsf, auth_sub_token=None, max_attempts=15, cooldown_secs=10): global api assert max_attempts > 0, 'max_attempts was %d, must be greater than 0' % max_attempts assert cooldown_secs > 0, 'cooldown_secs was %d, must be greater than 0' % cooldown_secs if api is None: # Ensure we have all the credentials we need assert acct_email is not None, 'Account email address is required' assert acct_password is not None, 'Account password is required' assert gsf is not None, 'Google Services Framework ID is required' # Authenticate the API, keep trying until it works api = GooglePlayAPI(androidId=gsf) for attempt in range(max(1, max_attempts)): attempt = attempt + 1 try: login(email=acct_email, password=acct_password, authSubToken=auth_sub_token) logging.info('Successfully logged in as %s' % acct_email) return except LoginError as e: logging.warning('BadAuthentication on attempt %d/%d' % (attempt, max_attempts)) if(attempt == max_attempts): raise e logging.warning('Retrying authentication in %d seconds' % cooldown_secs) time.sleep(cooldown_secs)
def __init__(self, android_id=None, username=None, password=None, auth_token=None, proxy=None, max_login_retries=10, language=None, debug=False): self._api = GooglePlayAPI(android_id, language, debug) self._username = username self._password = password self._auth_token = auth_token self._proxy = proxy self._max_login_retries = max_login_retries self._login_lock = Lock() self._logged_in = False
def api(self): """ returns googleplay-api instance """ # we should login with different credentials after every 200 requests made to prevent blocking should_recreate = self.__class__.num_requests_made > 200 or self._api is None if should_recreate: self._api = BaseApi(self.id_handler.device_id) self._api.login() self.__class__.num_requests_made = 0 return self._api
def print_result_line(c): global config if config == None: config = GooglePlayAPI.read_config() l = [ str_compat(c.title), c.docid, str_compat(c.creator), len(c.annotations.badgeForCreator), # Is Super Developer? c.offer[0].formattedAmount, c.offer[0].offerType, c.details.appDetails.versionCode, sizeof_fmt(c.details.appDetails.installationSize), "%.2f" % c.aggregateRating.starRating, c.details.appDetails.numDownloads] print(*l, sep=config['SEPARATOR'])
def print_header_line(): global config if config == None: config = GooglePlayAPI.read_config() l = [ "Title", "Package name", "Creator", "Super Dev", "Price", "Offer Type", "Version Code", "Size", "Rating", "Num Downloads", ] print(*l, sep=config['SEPARATOR'])
def download_reference_apk(self): api = GooglePlayAPI(self.android_id) api.login(self.google_login, self.google_password) package = api.details(self.results['package']) doc = package.docV2 version = doc.details.appDetails.versionCode offer_type = doc.offer[0].offerType ref_path = path.join(self.tmpdir, "ref.apk") data = api.download(self.results['package'], version, offer_type) with open(ref_path, "wb") as out: out.write(data) return ref_path
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]) # read config from config.py config = GooglePlayAPI.read_config() # connect to GooglePlayStore api = GooglePlayAPI(config) api.login() 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) helpers.print_header_line() doc = message.doc[0] for c in doc.child: helpers.print_result_line(c)
#!/usr/bin/python # Do not remove GOOGLE_LOGIN = GOOGLE_PASSWORD = AUTH_TOKEN = None import sys import urlparse from pprint import pprint from google.protobuf import text_format from config import * from googleplay_api.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])
#!/usr/bin/python # Do not remove GOOGLE_LOGIN = GOOGLE_PASSWORD = AUTH_TOKEN = None 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 config import * from googleplay_api.googleplay import GooglePlayAPI api = GooglePlayAPI(ANDROID_ID) api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN) try: from IPython import embed embed() except: code.interact(BANNER, local=locals())
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(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"
class GooglePlayApi(object): """ Wrapper for unofficial googleplay-api Handles device_id changes over the time and reduces the complexity of api calls """ num_requests_made = 0 # requests counter (class attribute) def __init__(self, device_ids=None): if device_ids is None: device_ids = config.DEVICE_IDS self.id_handler = DeviceIdHandler(device_ids) self._api = None @property def api(self): """ returns googleplay-api instance """ # we should login with different credentials after every 200 requests made to prevent blocking should_recreate = self.__class__.num_requests_made > 200 or self._api is None if should_recreate: self._api = BaseApi(self.id_handler.device_id) self._api.login() self.__class__.num_requests_made = 0 return self._api def to_dict(self, protobuf_obj): return self.api.toDict(protobuf_obj) @apicall def details(self, bundle_id): if not bundle_id or not isinstance(bundle_id, basestring): raise ValueError return self.api.details(bundle_id) @apicall def bulk_details(self, bundle_ids): return self.api.bulkDetails(bundle_ids) @apicall def list(self, category, subcategory, limit=None, offset=None): return self.api.list(category, subcategory, limit, offset) @apicall def browse(self, category, subcategory): return self.api.browse(category, subcategory) @apicall def search(self, query, limit=None, offset=None): return self.api.search(query, limit, offset) @apicall def download(self, bundle_id, out_dir): """ Downloads apk from play store. Returns absolute path to apk on success, None otherwise. """ filename = path.join(out_dir, bundle_id + '.apk') app_details = self.details(bundle_id) if not app_details: return None doc = app_details.docV2 try: version = doc.details.appDetails.versionCode offer_type = doc.offer[0].offerType chunks = self.api.download(bundle_id, version, offer_type) with open(filename, "wb") as f: for chunk in chunks: if chunk: f.write(chunk) return path.abspath(filename) except Exception: raise
#!/usr/bin/python # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import helpers from googleplay_api.googleplay import GooglePlayAPI packagenames = "com.reliancejio.mobilesecurity" # 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']) # Only one app if (len(packagenames) == 1): response = api.details(packagenames[0]) for item in response.docV2.details.appDetails.permission: print(helpers.str_compat(item)) else: # More than one app response = api.bulkDetails(packagenames)
class PlayStoreCrawler: def __init__(self): try: creds = loadPlayStoreConfig() self.googleLogin = creds['GOOGLE_LOGIN'] self.googlePassword = creds['GOOGLE_PASSWORD'] self.androidID = creds['ANDROID_ID'] self.authToken = creds['AUTH_TOKEN'] self.api = GooglePlayAPI(self.androidID) # Login to the Play Store except Exception as e: prettyPrintError(e) def login(self): """ Logs into the Google account using the received Google credentials """ try: self.api.login(self.googleLogin, self.googlePassword, self.authToken) except Exception as e: prettyPrintError(e) return False return True def getCategories(self): """ Returns a list of app categories available on Google Play Store """ try: cats = self.api.browse() categories = [c.dataUrl[c.dataUrl.rfind('=')+1:] for c in cats.category] except Exception as e: prettyPrintError(e) return [] return categories def getSubCategories(self, category): """ Returns a list of app sub-categories available on Google Play Store """ try: sub = self.api.list(category) subcategories = [s.docid for s in sub.doc] except Exception as e: prettyPrintError(e) return [] return subcategories def getApps(self, category, subcategory): """ Returns a list of "App" objects found under the given (sub)category """ try: apps = self.api.list(category, subcategory) if len(apps.doc) < 1: prettyPrint("Unable to find any apps under \"%s\" > \"%s\"" % (category, subcategory), "warning") return [] applications = [App(a.title, a.docid, a.details.appDetails.versionCode, a.offer[0].offerType, a.aggregateRating.starRating, a.offer[0].formattedAmount, a.details.appDetails.installationSize) for a in apps.doc[0].child] except Exception as e: prettyPrintError(e) return [] return applications def downloadApp(self, application): """ Downloads an app from the Google play store and moves it to the "downloads" directory """ try: if application.appPrice != "Free": prettyPrint("Warning, downloading a non free application", "warning") # Download the app data = self.api.download(application.appID, application.appVersionCode, application.appOfferType) io.open("%s.apk" % application.appID, "wb").write(data) downloadedApps = glob.glob("./*.apk") dstDir = loadDirs()["DOWNLOADS_DIR"] for da in downloadedApps: shutil.move(da, dstDir) except Exception as e: prettyPrintError(e) return False return True
except ImportError: # Python 3 import urllib.parse as urlparse import helpers from googleplay_api.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:] # read config from config.py config = GooglePlayAPI.read_config() # connect to GooglePlayStore api = GooglePlayAPI(config) api.login() # Only one app if (len(packagenames) == 1): response = api.details(packagenames[0]) for item in response.docV2.details.appDetails.permission: print(helpers.str_compat(item)) else: # More than one app response = api.bulkDetails(packagenames) for entry in response.entry:
class ApiClient(object): def __init__(self, android_id=None, username=None, password=None, auth_token=None, proxy=None, max_login_retries=10, language=None, debug=False): self._api = GooglePlayAPI(android_id, language, debug) self._username = username self._password = password self._auth_token = auth_token self._proxy = proxy self._max_login_retries = max_login_retries self._login_lock = Lock() self._logged_in = False def is_logged_in(self): return self._logged_in def login(self): self._logged_in = False with self._login_lock: logger.info('Executing login') login_error = None for _ in xrange(self._max_login_retries): try: self._api.login(self._username, self._password, self._auth_token, self._proxy) self._logged_in = True break except LoginError as err: login_error = err time.sleep(0.2) else: logger.error('Failed to log in: %s', login_error) raise ApiLoginException(login_error) @_with_login def search(self, package_prefix): logger.info('Searching for %s', package_prefix) results = list() response = self._api.search(package_prefix) if len(response.doc): document = response.doc[0] for child in document.child: package_name = child.details.appDetails.packageName if not package_name.startswith(package_prefix): continue item = self._extract_api_item(child, simple=True) results.append(item) return results def developer(self, developer_name): raise NotImplementedError('Searching by developer is not supported') @_with_login def get_details(self, package_name): logger.info('Fetching details for %s', package_name) details = self._api.details(package_name) return self._extract_api_item(details.docV2, simple=False) @staticmethod def _extract_api_item(api_object, simple): details = api_object.details.appDetails item = ApiItem() item.package_name = details.packageName item.title = api_object.title item.creator = api_object.creator item.upload_date = details.uploadDate item.num_downloads = details.numDownloads item.version_code = details.versionCode item.share_url = api_object.shareUrl if not simple: item.description_html = api_object.descriptionHtml item.developer_name = details.developerName item.developer_website = details.developerWebsite item.version_string = details.versionString item.recent_changes_html = details.recentChangesHtml images = list() for image_object in api_object.image: image = ApiItem() image.type = image_object.imageType image.url = image_object.imageUrl if not simple: image.width = image_object.dimension.width image.height = image_object.dimension.height image.position = image_object.positionInSequence images.append(image) item.images = images item.ratings = { 'stars': api_object.aggregateRating.starRating, 'total': api_object.aggregateRating.ratingsCount, 'comments': api_object.aggregateRating.commentCount, 'count': { 1: api_object.aggregateRating.oneStarRatings, 2: api_object.aggregateRating.twoStarRatings, 3: api_object.aggregateRating.threeStarRatings, 4: api_object.aggregateRating.fourStarRatings, 5: api_object.aggregateRating.fiveStarRatings } } return item
class GooglePlayApiTest(unittest.TestCase): api = GooglePlayAPI() @classmethod def setUpClass(cls): details = get_access_details() api = GooglePlayApiTest.api api.androidId = os.environ.get('ANDROID_ID', details.get('androidId')) last_error = None for _ in xrange(10): try: api.login(email=os.environ.get('GOOGLE_USERNAME', details.get('username')), password=os.environ.get('GOOGLE_PASSWORD', details.get('password'))) break except LoginError as err: last_error = err time.sleep(0.2) else: raise last_error def test_search(self): results = self.api.search('hu.rycus') self.assertTrue(hasattr(results, 'doc'), msg='Main doc object not found') self.assertGreater(len(results.doc), 0) document = results.doc[0] self.assertTrue(hasattr(document, 'child'), msg='Child object not found') self.assertGreater(len(document.child), 0) for child in document.child: self._verify_item(child, simple=True) def test_details(self): details = self.api.details('hu.rycus.watchface.triangular') self.assertTrue(hasattr(details, 'docV2'), msg='Main docV2 object not found') document = details.docV2 self._verify_item(document, simple=False) def _verify_item(self, item, simple): for expected in ('title', 'creator', 'image', 'details', 'aggregateRating', 'shareUrl'): self.assertTrue( hasattr(item, expected), msg='Result document does not contain the %s field' % expected) if not simple: self.assertTrue( hasattr(item, 'descriptionHtml'), msg='Result document does not contain the descriptionHtml field' ) for image in item.image: for expected in ('imageType', 'imageUrl'): self.assertTrue(hasattr(image, expected), msg='Image does not contain the %s field' % expected) if not simple: for expected in ('dimension', 'positionInSequence'): self.assertTrue(hasattr(image, expected), msg='Image does not contain the %s field' % expected) dimension = image.dimension for expected in ('width', 'height'): self.assertTrue( hasattr(dimension, expected), msg='Image dimension does not contain the %s field' % expected) details = item.details self.assertTrue(hasattr(details, 'appDetails'), msg='Result does not contain the appDetails object') app_details = details.appDetails for expected in ('packageName', 'uploadDate', 'numDownloads', 'versionCode'): self.assertTrue(hasattr(app_details, expected), msg='App details do not contain the %s field' % expected) if not simple: for expected in ('developerName', 'versionString', 'developerWebsite', 'recentChangesHtml'): self.assertTrue(hasattr(app_details, expected), msg='App details do not contain the %s field' % expected) rating = item.aggregateRating for expected in ('starRating', 'ratingsCount', 'commentCount', 'oneStarRatings', 'twoStarRatings', 'threeStarRatings', 'fourStarRatings', 'fiveStarRatings'): self.assertTrue(hasattr(rating, expected), msg='App rating does not contain the %s field' % expected)
import sys import urlparse from pprint import pprint from google.protobuf import text_format from config import * from googleplay_api.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')
def main(): logging.basicConfig(level=logging.INFO) parser = argparse.ArgumentParser( description='Unofficial PlayStore python interface', add_help=True) parser.add_argument('--request', action="store", dest='request_path', help='Do a generic request, useful for deugging') parser.add_argument('--details', action="store", dest='package_to_detail', help='Shows various details for the ' 'given package') parser.add_argument('--search', action="store", dest='query', help='Search the playstore') parser.add_argument('--similar', action="store", dest='package_similar', help='Shows various packages similar ' 'to the given package') parser.add_argument('--bulk-details', action="store", dest='packages_to_detail', nargs='+', type=str, help='Shows details for a list of packages') list_group = parser.add_argument_group() list_group.add_argument( '--list', action="store_true", dest='list', help= 'List the categories avilable on playstore. If --category is specified, lists the ' 'subcategories of the specified category. If --subcategory is also specified, lists ' 'the app in the subcategory.') list_group.add_argument( '--category', action="store", dest='cat', help='Specify a certain category (e.g. GAME_ARCADE)') list_group.add_argument( '--subcategory', action="store", dest='subcat', help='Specify a certain subcategory (e.g. apps_topselling_free)') group = parser.add_argument_group() group.add_argument('--download', action="store", dest='package_to_download', help='Download the apk with given ' 'package name') group.add_argument('-o', action="store", dest='output_folder', help='(optional) Where to ' 'save the downloaded apk') group.add_argument('--version', action="store", dest='version_code', help='(optional) Version Code of the apk' 'to download (default: latest)') parser.add_argument('--remote-token', action="store", dest='token_url', help='If the authentication token should be' ' retrieved from a remote server') group_proxy = parser.add_argument_group() group_proxy.add_argument('--http-proxy', action="store", dest='http_proxy', help='http proxy, ONLY used for' 'Play Store requests!') group_proxy.add_argument('--https-proxy', action="store", dest='https_proxy', help='https proxy, ONLY used for' 'Play Store requests!') results = parser.parse_args() proxies = None if results.http_proxy: if proxies is None: proxies = {} proxies["http"] = results.http_proxy if results.https_proxy: if proxies is None: proxies = {} proxies["https"] = results.https_proxy global play_store play_store = GooglePlayAPI(throttle=True, proxies=proxies) token = None if results.token_url: response = requests.get(results.token_url) token = response.text print("Using auth token: {0}".format(token)) play_store.login(authSubToken=token) if results.request_path: get_message(results.request_path) return if results.package_to_detail: get_details(results.package_to_detail) return if results.query: search(results.query) return if results.packages_to_detail: get_bulk_details(results.packages_to_detail) return if results.package_similar: get_similar(results.package_similar) return if results.list: list_category(results.cat, results.subcat) return if results.package_to_download: package = results.package_to_download version = results.version_code output_folder = results.output_folder if output_folder: os.path.join(output_folder, package + ".apk") else: output_folder = package + ".apk" download_apk(results.package_to_download, version, output_folder) return parser.print_help()
import sys import urlparse from pprint import pprint from google.protobuf import text_format from config import * from googleplay_api.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
from googleplay_api.googleplay import GooglePlayAPI if (len(sys.argv) < 2): print("Usage: %s packagename [filename]") print("Download an app.") print("If filename is not present, will write to '<packagename>_<versioncode>.apk'.") sys.exit(0) packagename = sys.argv[1] filename = None if (len(sys.argv) == 3): filename = sys.argv[2] # 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']) # 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 if filename == None: filename = "%s_%s.apk" % (packagename, vc) # Download
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)
except ImportError: # Python 3 import urllib.parse as urlparse import helpers from googleplay_api.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:] # 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']) # Only one app if (len(packagenames) == 1): response = api.details(packagenames[0]) for item in response.docV2.details.appDetails.permission: print(helpers.str_compat(item)) else: # More than one app response = api.bulkDetails(packagenames) for entry in response.entry:
from googleplay_api.googleplay import GooglePlayAPI if (len(sys.argv) < 2): print("Usage: %s packagename [filename]") print("Download an app.") print("If filename is not present, will write to '<packagename>_<versioncode>.apk'.") sys.exit(0) packagename = sys.argv[1] filename = None if (len(sys.argv) == 3): filename = sys.argv[2] # read config from config.py config = GooglePlayAPI.read_config() # connect to GooglePlayStore api = GooglePlayAPI(config) 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 if filename == None: filename = "%s_%s.apk" % (packagename, vc) # Download
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" sys.exit(1) 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()
from __future__ import print_function from __future__ import unicode_literals 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 code import helpers try: # Python 2 import urlparse except ImportError: # Python 3 import urllib.parse as urlparse from googleplay_api.googleplay import GooglePlayAPI # 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']) code.interact(BANNER, local=locals())
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" sys.exit(1) 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:
from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import sys try: # Python 2 import urlparse except ImportError: # Python 3 import urllib.parse as urlparse from googleplay_api.googleplay import GooglePlayAPI # read config from config.py config = GooglePlayAPI.read_config() # connect to GooglePlayStore api = GooglePlayAPI(config) api.login() response = api.browse() print("ID", "Name", sep=config['SEPARATOR']) for c in response.category: category = urlparse.parse_qs(c.dataUrl)['cat'][0] name = c.name print(category, name, sep=config['SEPARATOR'])
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] # 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'])
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]) # 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.search(request, nb_res, offset) except: print("Error: something went wrong. Maybe the nb_res you specified was too big?") sys.exit(1) helpers.print_header_line() doc = message.doc[0] for c in doc.child: helpers.print_result_line(c)
from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import sys try: # Python 2 import urlparse except ImportError: # Python 3 import urllib.parse as urlparse from googleplay_api.googleplay import GooglePlayAPI # 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']) response = api.browse() print("ID", "Name", sep=config['SEPARATOR']) for c in response.category: category = urlparse.parse_qs(c.dataUrl)['cat'][0] name = c.name print(category, name, sep=config['SEPARATOR'])
#!/usr/bin/python # Do not remove GOOGLE_LOGIN = GOOGLE_PASSWORD = AUTH_TOKEN = None import sys import urlparse from pprint import pprint from google.protobuf import text_format from config import * from googleplay_api.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])
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] # 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:
from __future__ import print_function from __future__ import unicode_literals 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 code import helpers try: # Python 2 import urlparse except ImportError: # Python 3 import urllib.parse as urlparse from googleplay_api.googleplay import GooglePlayAPI # read config from config.py config = GooglePlayAPI.read_config() # connect to GooglePlayStore api = GooglePlayAPI(config) api.login() code.interact(BANNER, local=locals())