Improved python2 compatibility

Signed-off-by: Domenico Iezzi <domenico.iezzi.201@gmail.com>
This commit is contained in:
Domenico Iezzi 2017-10-04 13:42:52 +02:00
parent 65e33a5c74
commit 0a5e270049
4 changed files with 25 additions and 7 deletions

View File

@ -1,4 +1,6 @@
language: python
python: '3.6'
python:
- "2.7"
- "3.5"
install: pip install .
script: python test.py

View File

@ -1,8 +1,8 @@
# Google play python3 API [![Build Status](https://travis-ci.org/NoMore201/googleplay-api.svg?branch=master)](https://travis-ci.org/NoMore201/googleplay-api)
# Google play python API [![Build Status](https://travis-ci.org/NoMore201/googleplay-api.svg?branch=master)](https://travis-ci.org/NoMore201/googleplay-api)
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 important changes:
[GooglePlayAPI project](https://github.com/egirault/googleplay-api/) which is not
maintained anymore. The code was updated with some important changes:
* ac2dm authentication with checkin and device info upload
* updated search and download calls

View File

@ -1,7 +1,13 @@
from . import googleplay_pb2
import time
import os
import configparser
import sys
VERSION = sys.version_info[0]
if VERSION == 2:
import ConfigParser
else:
import configparser
# separator used by search.py, categories.py, ...
SEPARATOR = ";"
@ -13,7 +19,11 @@ GOOGLE_PUBKEY = "AAAAgMom/1a/v0lblO2Ubrt60J2gcuXSljGFQXgcyZWveWLEwo6prwgi3iJIZ
# if you want to add another phone, just create another section in
# the file. Some configurations for common phones can be found here:
# https://github.com/yeriomin/play-store-api/tree/master/src/main/resources
config = configparser.ConfigParser()
if VERSION == 2:
config = ConfigParser.ConfigParser()
else:
config = configparser.ConfigParser()
filepath = os.path.join( os.path.dirname( os.path.realpath(__file__) ), 'device.properties')
config.read(filepath)
device = {}

View File

@ -1,4 +1,7 @@
import struct
import sys
VERSION = sys.version_info[0]
def fromDocToDictionary(app):
return {
@ -65,6 +68,9 @@ def toBigInt(byteArray):
array = byteArray[::-1] # reverse array
out = 0
for key, value in enumerate(array):
decoded = struct.unpack("B", bytes([value]))[0]
if VERSION == 3:
decoded = struct.unpack("B", bytes([value]))[0]
else:
decoded = struct.unpack("B", value)[0]
out = out | decoded << key*8
return out