Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

ProtoBuf definitions for checkins #10

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@

# ignore downloaded apps
*.apk

# ignore egg build leftovers
build/
Empty file added googleplayapi/__init__.py
Empty file.
7 changes: 2 additions & 5 deletions apishell.py → googleplayapi/apishell.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/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.
Expand All @@ -15,8 +12,8 @@
from pprint import pprint
from google.protobuf import text_format

from config import *
from googleplay import GooglePlayAPI
from googleplayapi.config import *
from googleplayapi.googleplay import GooglePlayAPI

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
Expand Down
7 changes: 2 additions & 5 deletions categories.py → googleplayapi/categories.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
#!/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 import GooglePlayAPI
from googleplayapi.config import *
from googleplayapi.googleplay import GooglePlayAPI

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
Expand Down
File renamed without changes.
17 changes: 9 additions & 8 deletions download.py → googleplayapi/download.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/usr/bin/python

# Do not remove
GOOGLE_LOGIN = GOOGLE_PASSWORD = AUTH_TOKEN = None

import sys
from pprint import pprint

from config import *
from googleplay import GooglePlayAPI
from helpers import sizeof_fmt
from googleplayapi.config import *
from googleplayapi.googleplay import GooglePlayAPI
from googleplayapi.helpers import sizeof_fmt

if (len(sys.argv) < 2):
print "Usage: %s packagename [filename]"
Expand All @@ -24,8 +21,12 @@
filename = packagename + ".apk"

# Connect
api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
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)
Expand Down
86 changes: 86 additions & 0 deletions googleplay.proto → googleplayapi/googleplay.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1830,3 +1830,89 @@ message UninstallReasonRequestProto {
}
message UninstallReasonResponseProto {
}
message AndroidCheckinProto {
optional AndroidBuildProto build = 1;
optional int64 lastCheckinMsec = 2;
repeated AndroidEventProto event = 3;
repeated AndroidStatisticProto stat = 4;
repeated string requestedGroup = 5;
optional string cellOperator = 6;
optional string simOperator = 7;
optional string roaming = 8;
optional int32 userNumber = 9;
}
message AndroidBuildProto {
optional string id = 1;
optional string product = 2;
optional string carrier = 3;
optional string radio = 4;
optional string bootloader = 5;
optional string client = 6;
optional int64 timestamp = 7;
optional int32 googleServices = 8;
optional string device = 9;
optional int32 sdkVersion = 10;
optional string model = 11;
optional string manufacturer = 12;
optional string buildProduct = 13;
optional bool otaInstalled = 14;
}
message AndroidEventProto {
optional string tag = 1;
optional string value = 2;
optional int64 timeMsec = 3;
}
message AndroidStatisticProto {
optional string tag = 1;
optional int32 count = 2;
optional float sum = 3;
}
message AndroidIntentProto {
optional string action = 1;
optional string dataUri = 2;
optional string mimeType = 3;
optional string javaClass = 4;
repeated group Extra = 5 {
optional string name = 6;
optional string value = 7;
}
}
message AndroidCheckinRequest {
optional string imei = 1;
optional int64 id = 2;
optional string digest = 3;
optional AndroidCheckinProto checkin = 4;
optional string desiredBuild = 5;
optional string locale = 6;
optional int64 loggingId = 7;
optional string marketCheckin = 8;
repeated string macAddr = 9;
optional string meid = 10;
repeated string accountCookie = 11;
optional string timeZone = 12;
optional fixed64 securityToken = 13;
optional int32 version = 14;
repeated string otaCert = 15;
optional string serialNumber = 16;
optional string esn = 17;
optional DeviceConfigurationProto deviceConfiguration = 18;
repeated string macAddrType = 19;
optional int32 fragment = 20;
optional string userName = 21;
}
message AndroidCheckinResponse {
optional bool statsOk = 1;
repeated AndroidIntentProto intent = 2;
optional int64 timeMsec = 3;
optional string digest = 4;
repeated GservicesSetting setting = 5;
optional bool marketOk = 6;
optional fixed64 androidId = 7;
optional fixed64 securityToken = 8;
optional bool settingsDiff = 9;
repeated string deleteSetting = 10;
}
message GservicesSetting {
optional bytes name = 1;
optional bytes value = 2;
}
45 changes: 36 additions & 9 deletions googleplay.py → googleplayapi/googleplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from google.protobuf import text_format
from google.protobuf.message import Message, DecodeError

import googleplay_pb2
import config
import googleplayapi.googleplay_pb2 as googleplay_pb2
import googleplayapi.config as config

class LoginError(Exception):
def __init__(self, value):
Expand Down Expand Up @@ -46,12 +46,33 @@ class GooglePlayAPI(object):
authSubToken = None
context = None

def __init__(self, androidId=None, debug=False): # you must use a device-associated androidId value
def __init__(self, androidId=None, authSubToken=None, email=None, password=None, debug=False):
"""Google Play API

authSubToken - pass in this value instead of calling login() multiple times

email - Google Play username

password - Google Play Password

androidId - device id associated with the same Google Play account

debug - increase verbosity and clutter up the screen
"""
self.preFetch = {}

self.debug = debug

# store immediately to avoid more params to login() later
self.email = email
self.password = password
self.authSubToken = authSubToken

# try to grab androidId from config as a last resort
if androidId == None:
import googleplayapi.config as config
androidId = config.ANDROID_ID
self.androidId = androidId
self.debug = debug

def toDict(self, protoObj):
"""Converts the (protobuf) result from an API call into a dict, for
Expand Down Expand Up @@ -92,14 +113,20 @@ def _try_register_preFetch(self, protoObj):
def setAuthSubToken(self, authSubToken):
self.authSubToken = authSubToken

# put your auth token in config.py to avoid multiple login requests
if self.debug:
print "authSubToken: " + authSubToken

def login(self, email=None, password=None, authSubToken=None):
"""Login to your Google Account. You must provide either:
"""Login to your Google account. You must provide either:
- an email and password
- a valid Google authSubToken"""
if email == None:
email = self.email
if password == None:
password = self.password
# Don't load authSubToken from self because maybe we're logging in
# again.

if (authSubToken is not None):
self.setAuthSubToken(authSubToken)
else:
Expand All @@ -114,9 +141,9 @@ def login(self, email=None, password=None, authSubToken=None):
"androidId": self.androidId,
"app": "com.android.vending",
#"client_sig": self.client_sig,
"device_country": "fr",
"operatorCountry": "fr",
"lang": "fr",
"device_country": "us",
"operatorCountry": "us",
"lang": "en",
"sdk_version": "16"}
headers = {
"Accept-Encoding": "",
Expand Down
1,494 changes: 1,238 additions & 256 deletions googleplay_pb2.py → googleplayapi/googleplay_pb2.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion helpers.py → googleplayapi/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from config import SEPARATOR
from googleplayapi.config import SEPARATOR

def sizeof_fmt(num):
for x in ['bytes','KB','MB','GB','TB']:
Expand Down
9 changes: 3 additions & 6 deletions list.py → googleplayapi/list.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/usr/bin/python

# Do not remove
GOOGLE_LOGIN = GOOGLE_PASSWORD = AUTH_TOKEN = None

import sys
from pprint import pprint

from config import *
from googleplay import GooglePlayAPI
from helpers import sizeof_fmt, print_header_line, print_result_line
from googleplayapi.config import *
from googleplayapi.googleplay import GooglePlayAPI
from googleplayapi.helpers import sizeof_fmt, print_header_line, print_result_line

if (len(sys.argv) < 2):
print "Usage: %s category [subcategory] [nb_results] [offset]" % sys.argv[0]
Expand Down
7 changes: 2 additions & 5 deletions permissions.py → googleplayapi/permissions.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
#!/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 import GooglePlayAPI
from googleplayapi.config import *
from googleplayapi.googleplay import GooglePlayAPI

if (len(sys.argv) < 2):
print "Usage: %s packagename1 [packagename2 [...]]" % sys.argv[0]
Expand Down
9 changes: 3 additions & 6 deletions search.py → googleplayapi/search.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/usr/bin/python

# Do not remove
GOOGLE_LOGIN = GOOGLE_PASSWORD = AUTH_TOKEN = None

import sys
from pprint import pprint

from config import *
from googleplay import GooglePlayAPI
from helpers import sizeof_fmt, print_header_line, print_result_line
from googleplayapi.config import *
from googleplayapi.googleplay import GooglePlayAPI
from googleplayapi.helpers import sizeof_fmt, print_header_line, print_result_line

if (len(sys.argv) < 2):
print "Usage: %s request [nb_results] [offset]" % sys.argv[0]
Expand Down
12 changes: 12 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from setuptools import setup, find_packages

version = "1.0.0"

setup(name="googleplayapi",
version=version,
author="Emilien Girault",
author_email="[email protected]",
license="BSD",
description="Google Play API for Android",
url="https://github.com/kanzure/googleplay-api",
packages=find_packages())