Skip to content

Commit

Permalink
Bool flag to control expansion files + cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Domenico Iezzi <[email protected]>
  • Loading branch information
Domenico Iezzi committed Oct 17, 2017
1 parent b3f28cb commit 6857b15
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions gpapi/googleplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from Crypto.Cipher import PKCS1_OAEP
from clint.textui import progress

from os.path import splitext
import requests
import base64
from itertools import chain
Expand Down Expand Up @@ -446,8 +445,8 @@ def _deliver_data(self, url, cookies, progress_bar):
bar.done()
return response_content

def delivery(self, packageName, versionCode,
offerType=1, downloadToken=None, progress_bar=False):
def delivery(self, packageName, versionCode, offerType=1,
downloadToken=None, progress_bar=False, expansion_files=False):
"""Download an already purchased app.
Args:
Expand Down Expand Up @@ -493,9 +492,12 @@ def delivery(self, packageName, versionCode,
str(cookie.name): str(cookie.value)
}
result['data'] = self._deliver_data(downloadUrl, cookies, progress_bar)
count = 1
if not expansion_files:
return result
for obb in resObj.payload.deliveryResponse.appDeliveryData.additionalFile:
a = {}
# fileType == 0 -> main
# fileType == 1 -> patch
if obb.fileType == 0:
obbType = 'main'
else:
Expand All @@ -506,9 +508,8 @@ def delivery(self, packageName, versionCode,
result['additionalData'].append(a)
return result


def download(self, packageName, versionCode,
offerType=1, progress_bar=False):
def download(self, packageName, versionCode, offerType=1,
progress_bar=False, expansion_files=False):
"""Download an app and return its raw data (APK file). Free apps need
to be "purchased" first, in order to retrieve the download cookie.
If you want to download an already purchased app, use *delivery* method.
Expand Down Expand Up @@ -544,8 +545,8 @@ def download(self, packageName, versionCode,
raise RequestError(resObj.commands.displayErrorMessage)
else:
dlToken = resObj.payload.buyResponse.downloadToken
return self.delivery(packageName, versionCode,
offerType, dlToken, progress_bar=progress_bar)
return self.delivery(packageName, versionCode, offerType, dlToken,
progress_bar=progress_bar, expansion_files=expansion_files)

def changeDevice(self, device_codename):
self.deviceBuilder = config.DeviceBuilder(device_codename)
Expand Down

0 comments on commit 6857b15

Please sign in to comment.