diff --git a/.travis.yml b/.travis.yml index f1da0af..23060e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: python python: '3.6' -install: pip install -r requirements.txt +install: pip install . script: python test.py diff --git a/README.md b/README.md index 7d9cd4f..744ac90 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,25 @@ This project contains an unofficial API for google play interactions. The code mainly comes from [GooglePlayAPI project](https://github.com/egirault/googleplay-api/) which was written for python2 and it's not -maintained anymore. The code was ported to python3 with some minor additions and updates, mainly for python3 compatibility. +maintained anymore. The code was ported to python3 with some important changes: -All credit goes to the original author [egirault](https://github.com/egirault). +* ac2dm authentication with checkin and device info upload +* updated search and download calls +* using headers of a Nexus 6P. Add you own device under `device.properties` file -This project is released under the BSD license. +# Usage +Check the test.py module for a simple example. + +An important note about login function: +``` +def login(self, email, password, ac2dmToken=None, gsfId=None) +``` +for first time logins, you should only provide email and password. +The module will take care of retrieving an ac2dm token, registering +"your device" to the google account you supplied, and retrieving +a Google Service Framework ID (which basically is the android ID of a device). + +For the next logins you **should** save the ac2dm master token and the gsfId (androidId), and provide them as parameters to the login function. If you login again with email and password only, this is the equivalent of deleting the google account from you device and re-initalize it every time. # API reversing diff --git a/gpapi/__init__.py b/gpapi/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config.py b/gpapi/config.py similarity index 99% rename from config.py rename to gpapi/config.py index 2bd6d68..e588ead 100644 --- a/config.py +++ b/gpapi/config.py @@ -1,4 +1,4 @@ -import googleplay_pb2 +from . import googleplay_pb2 import time import os import configparser diff --git a/device.properties b/gpapi/device.properties similarity index 100% rename from device.properties rename to gpapi/device.properties diff --git a/googleplay.py b/gpapi/googleplay.py similarity index 99% rename from googleplay.py rename to gpapi/googleplay.py index dce13f0..7bb50c0 100644 --- a/googleplay.py +++ b/gpapi/googleplay.py @@ -11,13 +11,11 @@ from Crypto.Hash import SHA from Crypto.Cipher import PKCS1_OAEP import requests -import config import base64 import struct import itertools -import googleplay_pb2 -import utils +from . import googleplay_pb2, config, utils ssl_verify = True @@ -165,7 +163,7 @@ class GooglePlayAPI(object): response = googleplay_pb2.ResponseWrapper.FromString(res.content) - def login(self, email=None, password=None, ac2dmToken=None, gsfId=None): + def login(self, email, password, ac2dmToken=None, gsfId=None): """Login to your Google Account. For first time login you should provide: * email diff --git a/googleplay_pb2.py b/gpapi/googleplay_pb2.py similarity index 100% rename from googleplay_pb2.py rename to gpapi/googleplay_pb2.py diff --git a/utils.py b/gpapi/utils.py similarity index 100% rename from utils.py rename to gpapi/utils.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4071fed --- /dev/null +++ b/setup.py @@ -0,0 +1,18 @@ +from setuptools import setup + +setup( + name='googleplay-api', + version='0.1.0', + description='Unofficial python3 api for google play', + url='https://github.com/NoMore201/googleplay-api', + author='NoMore201', + author_email='domenico.iezzi.201@gmail.com', + license='MIT', + packages=['gpapi'], + package_data={ + 'gpapi': ['device.properties'], + }, + install_requires=['pycrypto', + 'protobuf', + 'requests'], +) diff --git a/test.py b/test.py index e9ef700..270792a 100644 --- a/test.py +++ b/test.py @@ -1,4 +1,4 @@ -from googleplay import GooglePlayAPI +from gpapi.googleplay import GooglePlayAPI import sys