Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py3 partial support #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 15 additions & 14 deletions gplay-downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
# program. If not, go to http://www.gnu.org/licenses/gpl.html
# or write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import httplib, urllib, base64, zlib, re, optparse
import urllib, base64, zlib, re, optparse
import http.client as httplib

class Market:
LOGIN_HOST = "www.google.com"
Expand All @@ -34,7 +35,7 @@ def __init__( self, email, password ):
self.token = None

def login( self ):
params = urllib.urlencode({
params = urllib.parse.urlencode({
"Email" : self.email,
"Passwd" : self.password,
"service" : Market.LOGIN_SERVICE,
Expand Down Expand Up @@ -62,7 +63,7 @@ def login( self ):
raise Exception( "Unexpected response." )

def get_asset( self, request ):
params = urllib.urlencode({
params = urllib.parse.urlencode({
"version" : 2,
"request" : request
})
Expand Down Expand Up @@ -389,39 +390,39 @@ def encode( self ):
(o,args) = parser.parse_args()

if o.email is None:
print "No email specified."
print("No email specified.")

elif o.password is None:
print "No password specified."
print ("No password specified.")

elif o.package is None:
print "No package specified."
print ("No package specified.")

elif o.country is None or o.country not in Operator.OPERATORS:
print "Empty or invalid country specified, choose from : \n\n" + ", ".join( Operator.OPERATORS.keys() )
print ("Empty or invalid country specified, choose from : \n\n" + ", ".join( Operator.OPERATORS.keys()))

elif o.operator is None or o.operator not in Operator.OPERATORS[ o.country ]:
print "Empty or invalid operator specified, choose from : \n\n" + ", ".join( Operator.OPERATORS[ o.country ].keys() )
print ("Empty or invalid operator specified, choose from : \n\n" + ", ".join( Operator.OPERATORS[ o.country ].keys()))

elif o.device is None:
print "No device id specified."
print ("No device id specified.")

elif o.sdklevel < 2:
print "The SDK API level cannot be less than 2."
print ("The SDK API level cannot be less than 2.")

else:
print "@ Logging in ..."
print ("@ Logging in ...")

market = Market( o.email, o.password )
market.login()

print "@ Requesting package ..."
print ("@ Requesting package ...")

operator = Operator( o.country, o.operator )
request = AssetRequest( o.package, market.token, o.device, operator, o.devname, o.sdklevel )
asset = market.get_asset( request.encode() )

print "@ Download %s from :\n %s" % ( o.package, asset )
print ("@ Download %s from :\n %s" % ( o.package, asset ))

except Exception as e:
print e
print(e)