As I'm not able to understand via documentation, please help in where do I enter the email id and password if I want to use test.py as an example.
from gpapi.googleplay import GooglePlayAPI, RequestError
import sys
import argparse
ap = argparse.ArgumentParser(description='Test download of expansion files')
ap.add_argument('-e', '--email', dest='email', help='google username')
ap.add_argument('-p', '--password', dest='password', help='google password')
args = ap.parse_args()
server = GooglePlayAPI('it_IT', 'Europe/Rome')
# LOGIN
print('\nLogging in with email and password\n')
server.login(args.email, args.password, None, None)
gsfId = server.gsfId
authSubToken = server.authSubToken
print('\nNow trying secondary login with ac2dm token and gsfId saved\n')
server = GooglePlayAPI('it_IT', 'Europe/Rome')
server.login(None, None, gsfId, authSubToken)
# SEARCH
apps = server.search('telegram', 34, None)
print('\nSearch suggestion for "fir"\n')
print(server.searchSuggest('fir'))
print('nb_result: 34')
print('number of results: %d' % len(apps))
print('\nFound those apps:\n')
for a in apps:
print(a['docId'])
I re-wrote some of it, modernized it (Python 3.7), and used global variables instead of system args (command line). I commented it best I could using the GitHub page given and the source code.
from gpapi.googleplay import GooglePlayAPI
# Create global variables for easy settings change and use.
LOCALE = "us_US"
TIMEZONE = "America/Chicago"
MAX_RESPONSE = 34
APP_NAME = "Super Fun Game"
EMAIL = "test@gmail.com"
PASSWORD = "stackoverflow5"
# Create instance of API with ( locale, time zone )
server = GooglePlayAPI(locale = LOCALE, timezone = TIMEZONE)
# Login using just username and password.
print("\nTrying log in with just email and password\n")
server.login(email = "abc123babyYouandMe@gmail.com", password = "jaksun5")
gsfId = server.gsfId
authSubToken = server.authSubToken
# Now that we've been authorized once, we can use the gsfID and token previously
# generated to create a new instance w/o email or password.
print("\nTrying secondary login with ac2dm token and gsfId saved...\n")
server = GooglePlayAPI(locale = LOCALE, timezone = TIMEZONE)
server.login(gsfId = gsfId, authSubToken = authSubToken)
# Search the Play Store using `search` function
# First: Search query for the Play Store.
# Specify the maximum amount of apps that meet criteria that can be returned.
# Third param is `offset`. Determines if you want to start at a certain
# index in the returned list. Default is `None`.
apps = server.search(query = APP_NAME, nb_result = MAX_RESPONSE)
# Get the suggested search options from our desired app name
print("Search Suggestions for `%s`:" % APP_NAME)
print(server.searchSuggest(APP_NAME))
# Print our max limit and then the actual amount returned
print("Max #of Results: %i" % MAX_RESPONSE)
print("Actual #of Results: %d" % len(apps))
# if at least 1 app found, then print out its ID.
if len(apps) > 0:
print("Found apps: ")
# each app acts as a Dictionary
for _app in apps:
print("App[docID]: %s" % app["docId"])
PS: Stick to PEP 8 for coding styles, conventions, naming, etc. Since you're just starting off, it will come in handy for coding your own programs and understanding others.