예제 #1
0
class Downloader():

    def __init__(self):
        self.api = GooglePlayAPI(ANDROID_ID)
        self.api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    def download(self, pkg, filename):
        doc = self.api.details(pkg).docV2
        vc = doc.details.appDetails.versionCode

        data = self.api.download(pkg, vc)
        with open(filename, 'wb') as apk:
            apk.write(data)

    def downloadall(self, dbname, outdir, maxsize=None):
        mkdir(outdir)
        with sqlite3.connect(dbname, timeout=10) as db:
            with closing(db.cursor()) as cur:
                cur.execute(create)
                for pkg, size in cur.execute(select).fetchall():
                    print 'Processing %s (%s) ...' % (pkg, size)
                    if not sizeallowed(size, maxsize):
                        print Fore.YELLOW + '  [SKIP: too big (%s)]' % size
                        continue
                    path = os.path.join(outdir, pkg + '.apk')
                    try:
                        self.download(pkg, path)
                    except Exception as e:
                        print Fore.RED + '  [ERROR: %s]' % e.message
                    else:
                        print Fore.GREEN + '  [OK: downloaded to %s]' % path
                        cur.execute(insert, (pkg, path))
                        db.commit()
예제 #2
0
def download():
    package = args.package
    filename = package + ".apk"

    # Connect
    api = GooglePlayAPI(args.device, lang='en_US')
    api.login(args.email, args.password, None)

    # Get the version code and the offer type from the app details
    m = api.details(package)
    doc = m.docV2
    vc = doc.details.appDetails.versionCode
    ot = doc.offer[0].offerType

    # Download
    if args.target_arch:
        str_target_arch = '-%s' % args.target_arch
    else:
        str_target_arch = ''
    filename = '%s%s-%s.apk' % (get_datetime(), str_target_arch, package)
    dir_out = args.dir_out
    if dir_out:
        filename = dir_out + '/' + filename

    data = api.download(package, vc, ot)
    open(filename, "wb").write(data)
예제 #3
0
파일: playweka.py 프로젝트: tvldz/playweka
def main():
    search_term = sys.argv[1]
    '''
    apps will be a list of dicts describing each returned app:
    {'app_name':<app name>,'app_id':<app id>,'app_creator':<creator>,'app_permissions':[list]}
    '''
    apps = []
    nb_res = 100 # apps to retrieve. API allows for max of 100.
    offset = 0 
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
    try:
        message = api.search(search_term, nb_res, offset)
    except:
        print "Error: something went wrong. Google may be throttling or rejecting the request."
        sys.exit(1)

    doc = message.doc[0]
    for c in doc.child:
        permissions = []
        details = api.details(c.docid)
        for line in details.docV2.details.appDetails.permission:
            permissions.append(line)
        apps.append({'app_name':c.title,'app_id':c.docid,'app_creator':c.creator,'app_permissions':permissions})

    '''
    We are interested in the set of all possible permissions that start with 'ANDROID.'
    '''
    permissions = Set([])
    for app in apps:
        for permission in app["app_permissions"]:
            if  permission.upper()[0:8] == "ANDROID.":
                permissions.add(permission.upper())

    '''
    Create ARFF output for Weka
    '''
    dataset = open(search_term + ".arff",'w')
    dataset.write("@relation Appdata\n")
    dataset.write("@attribute index NUMERIC\n")
    dataset.write("@attribute app_name STRING\n")
    for att in permissions:
        dataset.write("@attribute "+ att + " {0,1}\n")
    dataset.write("@data\n")
    i = 0 # index for cross-referencing
    for app in apps:
        print("{} {}").format(str(i), str(app)) # index
        perm_str = str(i) + ',' + app['app_id'] + ','
        app_perm_upper = []
        for app_permission in app['app_permissions']:
            app_perm_upper.append(app_permission.upper())
        for permission in permissions:
            if permission in app_perm_upper:
                perm_str = perm_str + '1,'
            else:
                perm_str = perm_str + '0,'
        dataset.write(perm_str[:-1])
        dataset.write("\n")
        i += 1
예제 #4
0
def login():
    api = None
    try:
        api = GooglePlayAPI(ANDROID_ID)
        api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
    except Exception as e:
        print e
    return api
예제 #5
0
파일: new.py 프로젝트: adrooy/shell
def login(logger):
    api = None
    try:
        api = GooglePlayAPI(ANDROID_ID)
        api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
    except Exception as e:
        logger.debug('login google error %s' % e)
    return api
예제 #6
0
def connect(android_id, google_login, google_password, auth_token):
    api = GooglePlayAPI(android_id)
    try:
        api.login(google_login, google_password, auth_token)
    except:
        print >> sys.stderr, int(time.time())
        traceback.print_exc(file=sys.stderr)
    return api
예제 #7
0
def connect(android_id, google_login, google_password, auth_token):
    api = GooglePlayAPI(android_id)
    try:
      api.login(google_login, google_password, auth_token)
    except:
      print >> sys.stderr, int(time.time()) 
      traceback.print_exc(file=sys.stderr)
    return api
예제 #8
0
def download_sdk_to_file(packagename, filename):
    # Connect
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    # Download
    data = api.download(packagename)
    with open(filename, "wb") as f:
        f.write(data)
예제 #9
0
def scrape(id, package):

    packagename = package
    res = urllib2.urlopen("https://play.google.com/store/apps/details?id=%s&hl=en" % packagename)
    html = res.read()

    path = "assets/%d/" % id
    if not os.path.exists(path):
        os.makedirs(path)

    name = html.split('itemprop="name"')[1].split("</div>")[0].split("<div>")[1]
    desc = html.split('<div class="show-more-content text-body" itemprop="description">')[1].split(
        '<div class="show-more-end">'
    )[0]
    rating = html.split("Rated ")[1].split(" stars")[0]
    category = html.split('<span itemprop="genre">')[1].split("</span>")[0]

    stuff = []
    for line in html.split("</div>"):
        if "full-screenshot" in line:
            url = line.split('src="')[1][:-3]
            stuff.append(url)

    x = 0
    for img in stuff[1:]:
        print img
        urllib.urlretrieve(img, "%s%d.webp" % (path, x))
        x += 1

    filename = path + packagename + ".apk"

    # Connect
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    # Get the version code and the offer type from the app details
    m = api.details(packagename)
    doc = m.docV2
    vc = doc.details.appDetails.versionCode
    ot = doc.offer[0].offerType

    # Download
    print "Downloading %s..." % sizeof_fmt(doc.details.appDetails.installationSize),
    data = api.download(packagename, vc, ot)
    open(filename, "wb").write(data)
    print "Done"
    ap = apk.APK(filename)
    badging = os.popen("/home/thomas/dev/android-odroid/out/host/linux-x86/bin/aapt dump badging %s" % filename).read()
    for line in badging.split("\n"):
        if "launchable-activity" in line:
            activity = line.split("'")[1]

    return [name, desc, rating, package, activity, category]
예제 #10
0
 def login(self, retry=0):
     try_count = 0
     while True:
         if retry > 0 and try_count >= retry:
             return
         try:
             api = GooglePlayAPI(self.android_id, lang=self.lang)
             api.login(self.google_login, self.google_password,
                       self.auth_token)
             return api
         except Exception as e:
             print "GooglePlayAPI Login Faild, Has Try Count:%s" % try_count, e
         try_count += 1
예제 #11
0
def get_categories():
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
    response = api.browse()

    categories = []

    # print SEPARATOR.join(["ID", "Name"])
    for c in response.category:
        categories.append(
            SEPARATOR.join(
                i.encode('utf8')
                for i in [urlparse.parse_qs(c.dataUrl)['cat'][0]]))
        # print SEPARATOR.join(i.encode('utf8') for i in [urlparse.parse_qs(c.dataUrl)['cat'][0], c.name])
    return categories
예제 #12
0
파일: store.py 프로젝트: ephracis/hermes
def login(id, mail, password, token):
	""" Login to the Google Play Store.
		
		You can either specify the mail and password, or use
		a valid auth token.
		
		Arguments:
		id       -- the android phone ID
		mail     -- the email address of the account
		password -- the password of the account
		token    -- a valid auth token
		
		Returns:
		A Google Play API object.
		"""
	api = GooglePlayAPI(id)
	api.login(mail, password, token)
	return api
예제 #13
0
def downloadAPKs(start):
    crawler = CrawlerThread("../playapks/", startappID)
    crawler.start()
    time.sleep(1)

    threads = []

    playapi = GooglePlayAPI()
    playapi.login("*****@*****.**", "niklashaxor42")

    for i in range(4): # 4 download threads
        t = DownloadThread(appQueue, "../playapks/", playapi)
        t.start()
        threads.append(t)

    filewriter = FileThread()
    filewriter.start()

    done = False
    #OMG DON'T DIE!
    while not done:
        test = raw_input(">")
        if test == "exit":
            print "Killing threads..."
            for thread in threads:
                thread.stop()
            crawler.stop()
            filewriter.stop()
            while len([t for t in threads if t.stopped == True]):
                time.sleep(1)
                print "Waiting for threads to finish..."
            print "Exiting..."
            done = True


    if os.path.exists("queue.txt"):
        os.remove("queue.txt")

    queueFile = open("queue.txt", 'w')

    for a in list(appQueue.queue):
        queueFile.write(a+"\n")

    queueFile.close()
예제 #14
0
def findAppInfo(packageName):
    request = packageName
    nb_res = None
    offset = None

    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    try:
        message = api.search(request, nb_res, offset)
        doc = message.doc[0]
        for c in doc.child:
            if c.docid.startswith(packageName):
                result = {}
                result["creator"] = c.creator
                result["price"] = c.offer[0].formattedAmount
                return result
    except Exception, e:
        print str(e)
예제 #15
0
def findAppInfo(packageName):
    request = packageName
    nb_res = None
    offset = None

    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    try:
        message = api.search(request, nb_res, offset)
        doc = message.doc[0]
        for c in doc.child:
            if c.docid.startswith(packageName):
                result = {}
                result["creator"] = c.creator
                result["price"] = c.offer[0].formattedAmount
                return result
    except Exception, e:
        print str(e)
예제 #16
0
def list(cat, ctr = None, nb_results = None, offset = None):
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
    try:
        message = api.list(cat, ctr, nb_results, offset)
    except:
        print "Error: HTTP 500 - one of the provided parameters is invalid"

    if (ctr is None):
        print SEPARATOR.join(["Subcategory ID", "Name"])
        for doc in message.doc:
            print SEPARATOR.join([doc.docid.encode('utf8'), doc.title.encode('utf8')])
    else:
        print_header_line()
        doc = message.doc[0]
        results = []
        for c in doc.child:
            results.append(get_parsed_result(c))
        return results
예제 #17
0
def list(cat, ctr=None, nb_results=None, offset=None):
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
    try:
        message = api.list(cat, ctr, nb_results, offset)
    except:
        print "Error: HTTP 500 - one of the provided parameters is invalid"

    if (ctr is None):
        print SEPARATOR.join(["Subcategory ID", "Name"])
        for doc in message.doc:
            print SEPARATOR.join(
                [doc.docid.encode('utf8'),
                 doc.title.encode('utf8')])
    else:
        print_header_line()
        doc = message.doc[0]
        results = []
        for c in doc.child:
            results.append(get_parsed_result(c))
        return results
예제 #18
0
def main(input_file, out_dir):
    total = file_len(input_file)
    fail_counter = FailCounter(50)
    proxy_iterator = ProxyIterator(config.proxy_list)
    proxy_iterator.next()
    file_object = open(input_file)
    try:
         input_text = file_object.read()
    finally:
         file_object.close()

    try:
        data = json.loads(input_text)
        assert data[0]['hl']
    except Exception:
        print '读取json输入文件[ %s ]出错...\n' % (input_file)
        exit(0)

    lang = data[0]['hl']
    api = GooglePlayAPI(ANDROID_ID, lang)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    now = datetime.datetime.now()
    out_file = '%s%s_reviewDesc-%s.txt' % (out_dir,
        lang,
        now.strftime('%Y%m%d-%H:%M:%S'))

    progress = {'total' : len(data), 'current' : 0}
    for i in xrange(len(data)):
        progress['current'] = progress['current'] + 1
        request = data[i]['app_name'].strip()
        print '[ %s ] starting...' % (request)
        if not request:
            continue

        for i in xrange(len(config.proxy_list)):
            stat = list_top_downloads(request, api, out_file, progress)
            if not stat:
                print '切换代理重试中...'
                fail_counter.append(False)
                proxy_iterator.next()
                if fail_counter.fail_rate() > 0.7:
                    time.sleep(60)
                    fail_counter.reset()
                    proxy_iterator.move_to_first()
                    api = GooglePlayAPI(ANDROID_ID, lang=lang)
                    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
            else:
                fail_counter.append(True)
                break
예제 #19
0
def run(packagename):

    if (len(sys.argv) == 3):
        filename = sys.argv[2]
    else:
        filename = packagename + ".apk"


# Connect
    api = GooglePlayAPI(config.ANDROID_ID)

    api.login(config.GOOGLE_LOGIN, config.GOOGLE_PASSWORD, config.AUTH_TOKEN)

    # Get the version code and the offer type from the app details
    m = api.details(packagename)
    doc = m.docV2
    vc = doc.details.appDetails.versionCode
    ot = doc.offer[0].offerType

    # Download
    print "Downloading %s..." % sizeof_fmt(
        doc.details.appDetails.installationSize),
    data = api.download(packagename, vc, ot)
    open(filename, "wb").write(data)
    print "Done"
예제 #20
0
def getPackagePermission(packagenames,androidId):
	api = GooglePlayAPI(androidId)
	'''
		Prajit Das: Cycling through the different androidIds we have 
		to ensure that we are not blocked by Google
		The following statement was the original code
	'''
	#api = GooglePlayAPI(ANDROID_ID)
	api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
	
	# Only one app
	if (len(packagenames) == 1):
		response = api.details(packagenames[0])
		permissionList = []
		#print "\n".join(i.encode('utf8') for i in response.docV2.details.appDetails.permission)
		for permission in response.docV2.details.appDetails.permission:
			permissionList.append(permission.encode('utf8'))
		for permission in permissionList: print permission
		return permissionList
	
	else: # More than one app
		permissionListDict = {}
		response = api.bulkDetails(packagenames)
		for entry in response.entry:
			if (not not entry.ListFields()): # if the entry is not empty
				permissionList = []
#				 print entry.doc.docid + ":"
#				 print "\n".join("	"+i.encode('utf8') for i in entry.doc.details.appDetails.permission)
				for permission in entry.doc.details.appDetails.permission:
					permissionList.append(permission.encode('utf8'))
				for permission in permissionList: print permission

				permissionListDict[entry.doc.docid] = permissionList
				return permissionListDict
예제 #21
0
def getPermissions(packageName, multiple=False):

    api = GooglePlayAPI(config.ANDROID_ID)
    api.login(config.GOOGLE_LOGIN, config.GOOGLE_PASSWORD, config.AUTH_TOKEN)
    result = {}
    # Only one app
    if (not multiple):
        response = api.details(packageName)
        permissions = []
        values = response.docV2.details.appDetails.permission._values
        permissions = [x.encode('utf-8') for x in values]
        name = response.docV2.title
        result["name"] = name.encode("utf8")
        result["permissions"] = permissions
        logo = response.docV2.image._values[0]
        image = logo.imageUrl.encode("utf8")
        result["logo"] = image
        return result

    else:  # More than one app, not tested or used
        response = api.bulkDetails(packageName)
        for entry in response.entry:
            if (not not entry.ListFields()):  # if the entry is not empty
                result[
                    entry.doc.docid] = entry.doc.details.appDetails.permission
        return result
예제 #22
0
def download_apk(packagename, filename):
    # Connect
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    # Get the version code and the offer type from the app details
    m = api.details(packagename)
    doc = m.docV2
    vc = doc.details.appDetails.versionCode
    ot = doc.offer[0].offerType

    # Download
    print "Downloading %s..." % sizeof_fmt(doc.details.appDetails.installationSize),
    data = api.download(packagename, vc, ot)
    open(filename, "wb").write(data)
    print "Done"
예제 #23
0
def main(lang, input_file, out_file, task_tag=''):
    total = file_len(input_file)
    ez_dump = EzDumper(out_file, total, '%s : download_num' % task_tag)

    fail_counter = FailCounter(50)
    proxy_iterator = ProxyIterator(config.proxy_list)
    proxy_iterator.next()

    api = GooglePlayAPI(ANDROID_ID, lang=lang)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    with open(input_file, 'r') as f:
        current = 0
        for line in f:
            current += 1
            request = line.strip()
            if not request:
                continue
            ez_dump.dump(current, "KEYWORD:[%s]" % request)

            for i in xrange(len(config.proxy_list)):
                stat = list_top_downloads(request, ez_dump, api)
                if stat:
                    fail_counter.append(True)
                    break
                else:
                    fail_counter.append(False)
                    ez_dump.dump(None,
                                 "fail_rate:[%s]" % fail_counter.fail_rate())
                    proxy_iterator.next()
                    if fail_counter.fail_rate() > 0.7:
                        ez_dump.dump(None, 'sleep for %s seconds ...' % 60)
                        time.sleep(60)
                        fail_counter.reset()
                        proxy_iterator.move_to_first()
                        api = GooglePlayAPI(ANDROID_ID, lang=lang)
                        api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
예제 #24
0
def crawlAll(id, offset=0):
    # declared as global in order for changes to be acknowledged by every threads
    global FOUND_APP
    global LOCK
    global TOTAL_SIZE
    global THREAD_PROGRESS

    api = GooglePlayAPI(ANDROID_ID[id])
    api.login(GOOGLE_LOGIN[id], GOOGLE_PASSWORD[id], AUTH_TOKEN)
    user = id

    for wordId in range(offset, len(SPLITED_DICO[id])):

        try:
            message = api.search(SPLITED_DICO[id][wordId],
                                 250)  # Search the playstore with the word
        except:
            print "Error: HTTP 500 - one of the provided parameters is invalid"
            return 0

        try:
            doc = message.doc[0]
        except IndexError:  # if we were blocked
            print "Blocked, switching Account"
            connected = 0
            while (connected == 0):
                user += THREAD_NUMBER
                if user >= len(ANDROID_ID):
                    user = id
                print GOOGLE_LOGIN[user]

                time.sleep(4)  # Wait a bit before connecting again
                del api
                api = GooglePlayAPI(ANDROID_ID[user], LANG)
                try:
                    api.login(GOOGLE_LOGIN[user], GOOGLE_PASSWORD[user],
                              None)  # attempt another connection
                    connected = 1
                except LoginError:
                    connected = 0
                    print "Auth error, retrying ..."

            continue

        for c in doc.child:
            try:
                #print_result_line(c)

                package = c.docid
                while LOCK == 1:  # prevent reading while other thread is writing
                    pass
                if package in FOUND_APP:  # if app was found in a previous search
                    continue
                name = c.title
                length = c.details.appDetails.installationSize / float(
                    1024 * 1024)
                TOTAL_SIZE += length

                l = [package, name, str(length) + "MB"]
                print SEPARATOR.join(unicode(i).encode('utf8') for i in l)

                while LOCK == 1:  # prevent writing when other thread is writing
                    pass
                LOCK = 1  # Acquire lock
                FOUND_APP.append(package)  # commit change
                LOCK = 0  # release lock

                print "\nNumber Of app = " + str(len(FOUND_APP))
                print "\nAverage size Of app = " + str(
                    TOTAL_SIZE / len(FOUND_APP))

                if length > 0:  # if apk is more than 1 MB
                    print 'too large, skip'
                    continue

                folder = DOWNLOAD_PATH
                if not os.path.exists(folder):
                    os.mkdir(folder)
                filename = folder + '/' + name + '.apk'
                if not os.path.isfile(filename):
                    downloadApps(api, package, filename)

            except:
                continue
        THREAD_PROGRESS[id] = wordId
        print "processed words by thread #" + str(id) + ": " + str(
            THREAD_PROGRESS[id])
    return FOUND_APP
예제 #25
0
# Dealing with user's parameter
appname = sys.argv[1]
if (len(sys.argv) == 3):
    maxNumReviews = int(sys.argv[2])
    # if specified value is >500, set it to 500 (maximum value).
    if maxNumReviews > 500:
        maxNumReviews = 500
# if not specified, set the number of reviews to 500 (default value).
else:
    maxNumReviews = 500


# ignore unverified HTTPS request warning.
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

# authentication
api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

# Each request returns 20 reviews.
# Loop until you find no more or reach the limit of 500
for offsetNum in range(0, maxNumReviews, 20):
    reviewResponse = api.reviews(appname, offset=offsetNum)
    print text_format.MessageToString(reviewResponse.getResponse)
    # if nextPageUrl is not present in response, there are no reviews left 
    if not reviewResponse.nextPageUrl:
        break


예제 #26
0
    print "subcategory: You can get a list of all subcategories available, by supplying a valid category"
    sys.exit(0)

packagename = sys.argv[1]
filename = None
nb_results = None
offset = None

if (len(sys.argv) >= 3):
    filename = sys.argv[2]
if (len(sys.argv) >= 4):
    nb_results = sys.argv[3]
if (len(sys.argv) == 5):
    offset = sys.argv[4]

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD)
try:
    message = api.list(packagename, filename, nb_results, offset)
except:
    print "Error: HTTP 500 - one of the provided parameters is invalid"

if (filename is None):
    print SEPARATOR.join(["Subcategory ID", "Name"])
    for doc in message.doc:
        print SEPARATOR.join(
            [doc.docid.encode('utf8'),
             doc.title.encode('utf8')])
else:
    topline()
    doc = message.doc[0]
예제 #27
0
import requests
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 google.protobuf import text_format
from requests.packages.urllib3.exceptions import InsecureRequestWarning

if (len(sys.argv) < 2):
     print "\nUsage: %s appPackageName." % sys.argv[0]
     print "Retrieves the details (i.e. description, URL to screenshots etc) of a specific app.\n"
     sys.exit(0)

# Dealing with user's parameter
appname = sys.argv[1]

# Ignore unverified HTTPS request warning.
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

# authentication
api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

#invoking api method to get the app details.
detailsResponse = api.details(appname)
print text_format.MessageToString(detailsResponse)


예제 #28
0
if (len(sys.argv) < 2):
    print "Usage: %s packagename [filename]"
    print "Download an app."
    print "If filename is not present, will write to packagename.apk."
    sys.exit(0)

packagename = sys.argv[1]

if (len(sys.argv) == 3):
    filename = sys.argv[2]
else:
    filename = packagename + ".apk"

# Connect
api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

# Get the version code and the offer type from the app details
m = api.details(packagename)
doc = m.docV2
vc = doc.details.appDetails.versionCode
ot = doc.offer[0].offerType

# Download
print "Downloading %s..." % sizeof_fmt(
    doc.details.appDetails.installationSize),
data = api.download(packagename, vc, ot)
open(filename, "wb").write(data)
print "Done"
예제 #29
0
 def __init__(self):
     self.api = GooglePlayAPI(ANDROID_ID)
     self.api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
예제 #30
0
    print SEPARATOR.join(unicode(i).encode('utf8') for i in l)
    

if (len(sys.argv) < 2):
    print "Usage: %s request [package] [offset]" % sys.argv[0]
    print "Returns 20 reviews for a given app package."
    sys.exit(0)

request = sys.argv[1]
nb_res = 20
offset = 0

if (len(sys.argv) >= 3):
    offset = int(sys.argv[2])

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

try:
    reviews = api.reviews(request, False, 0, nb_res, offset)
except:
    print "Error: something went wrong. Maybe the nb_res you specified was too big?"
    sys.exit(1)

resp = reviews.getResponse
print_header_line()
try:
	for c in resp.review:
	    if c != None:
	        print_result_line(c)
except Exception,e:
예제 #31
0
import sys
import urlparse
from pprint import pprint
from google.protobuf import text_format

from config import *
from googleplay import GooglePlayAPI

if (len(sys.argv) < 2):
    print "Usage: %s packagename1 [packagename2 [...]]" % sys.argv[0]
    print "Display permissions required to install the specified app(s)."
    sys.exit(0)

packagenames = sys.argv[1:]

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

# Only one app
if (len(packagenames) == 1):
    response = api.details(packagenames[0])
    print "\n".join(
        i.encode('utf8') for i in response.docV2.details.appDetails.permission)

else:  # More than one app
    response = api.bulkDetails(packagenames)

    for entry in response.entry:
        if (not not entry.ListFields()):  # if the entry is not empty
            print entry.doc.docid + ":"
            print "\n".join("    " + i.encode('utf8')
예제 #32
0
        config = json.loads(
            config_file.read().strip()
        )
        try:
            deviceid = config["deviceid"]
            email = config["email"]
            password = config["password"]
        except KeyError:
            logger.critical('Config problem: %s', 'Missing config parameters')
            sys.exit(1)
except IOError:
    logger.critical('Config problem: %s', 'Missing config file')
    sys.exit(1)


api = GooglePlayAPI(deviceid)
api.login(email, password)

logger.info('Conecting to host {}:{}'.format('localhost', '27017'))
client = pymongo.MongoClient("localhost", 27017)
db = client.test

SUB_CAT = (
    'apps_topselling_paid',
    'apps_topselling_free',
    'apps_topgrossing',
    'apps_topselling_new_paid',
    'apps_topselling_new_free'
)

count = 0
예제 #33
0
class GoogleAnalysis(object):
    """docstring for GoogleAnalysis."""
    def __init__(self):
        super(GoogleAnalysis, self).__init__()
        self.api = GooglePlayAPI(ANDROID_ID)
        self.api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    def category_list(self):
        response = self.api.browse()
        return list(
            map(
                lambda c: SEPARATOR.join(
                    i.encode('utf8')
                    for i in [urlparse.parse_qs(c.dataUrl)['browse?cat'][0]]),
                response.category))

    def read_files(self, cate):
        with open(dirname(__file__) + '/resource_list/' + cate + '.txt',
                  'r') as f:
            for line in f.readlines():
                filename = line.strip()
                print Color.Green + '[!] Start:  ' + Color.NoCo + filename
                self.details(filename)

    def details(self, packageName):
        message = self.api.details(packageName).docV2
        result = {
            "docid": message.docid,
            "title": message.title,
            "creator": message.creator,
            "descriptionHtml": message.descriptionHtml,
            "offer": {
                "currencyCode": message.offer[0].currencyCode,
                "formattedAmount": message.offer[0].formattedAmount
            },
            "details": {
                "appDetails": {
                    "developerName": message.details.appDetails.developerName,
                    "versionCode": message.details.appDetails.versionCode,
                    "versionString": message.details.appDetails.versionString,
                    "contentRating": message.details.appDetails.contentRating,
                    "installationSize":
                    message.details.appDetails.installationSize,
                    # "permission": message.details.appDetails.permission,
                    "numDownloads": message.details.appDetails.numDownloads,
                    "packageName": message.details.appDetails.packageName,
                    "uploadDate": message.details.appDetails.uploadDate,
                }
            },
            "aggregateRating": {
                "starRating": message.aggregateRating.starRating,
                "ratingsCount": message.aggregateRating.ratingsCount,
                "oneStarRatings": message.aggregateRating.oneStarRatings,
                "twoStarRatings": message.aggregateRating.twoStarRatings,
                "threeStarRatings": message.aggregateRating.threeStarRatings,
                "fourStarRatings": message.aggregateRating.fourStarRatings,
                "fiveStarRatings": message.aggregateRating.fiveStarRatings,
                "commentCount": message.aggregateRating.commentCount
            }
        }

        doc = message
        vc = doc.details.appDetails.versionCode
        ot = doc.offer[0].offerType
        self.download(packageName, vc, ot)

        with open(
                dirname(abspath(__file__)) + '/detail_reports/' + packageName,
                'w') as f:
            json.dump(result,
                      f,
                      sort_keys=True,
                      indent=4,
                      separators=(',', ': '))
            f.close()
        # print json.dumps(result, sort_keys=True, indent=4, separators=(',', ': '))

    def download(self, packageName, vc, ot):
        data = self.api.download(packageName, vc, ot)

        with open(
                dirname(abspath(__file__)) + '/apk_files/' + packageName +
                '.apk', 'w') as f:
            f.write(data)
            print "Done"
            f.close()

    def test(self):
        lists = list('!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c')
        for i in lists:
            try:
                print self.api.list('ART_AND_DESIGN', 'apps_topselling_free',
                                    '1', 'CA' + i)
            except:
                print i
예제 #34
0
 def __init__(self):
     super(GoogleAnalysis, self).__init__()
     self.api = GooglePlayAPI(ANDROID_ID)
     self.api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
예제 #35
0
def retrieveCategoryPackageNames(request):

    nb_res = None
    offset = None
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)


    packageNamesList = []
    #print_header_line()

    # continue requesting until receive ALL apps by category. use to make histogram.
    while True:
        try:
            message = api.search(request, nb_res, offset)
        except:
            break

        if message.doc:
            doc = message.doc[0]

            for c in doc.child:
                packageNamesList.append(c.docid)
            offset = len(packageNamesList)
        else:
            break

    dic = {}
    final_results = {}

    # Only one app returned TODO update this
    if (len(packageNamesList) == 1):
        response = api.details(packageNamesList[0])
        print "\n".join(i.encode('utf8') for i in response.docV2.details.appDetails.permission)

    # More than one app
    else:
        response = api.bulkDetails(packageNamesList)

        for entry in response.entry:
            hasCustom = False
            if (entry.ListFields()):
                iconUrl = ""
                for x in entry.doc.image:
                    if x.imageType == 4:
                        iconUrl = x.imageUrl
                final_results[entry.doc.docid] = {'package': entry.doc.docid, 'title':entry.doc.title, 
                                          'creator':entry.doc.creator, 
                                          'price':{'amount':entry.doc.offer[0].formattedAmount, 'currency':entry.doc.offer[0].currencyCode}, 
                                          'icon':iconUrl,
                                          'permissions':[perm for perm in entry.doc.details.appDetails.permission],
                                          'rating':{'stars':entry.doc.aggregateRating.starRating, 'count':entry.doc.aggregateRating.ratingsCount},
                                          'shareUrl': entry.doc.shareUrl 
                                          }
                for permission in entry.doc.details.appDetails.permission:
                    # apps can have custom permissions that don't start with android.permission.PERM_NAME_HERE
                    # are they safe? Will warn users about custom permissions.
                    perm = permission.split(".")
                    if (permission != "com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" and permission != "com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" and (len(perm) !=3 or perm[0] != "android" or perm[1] != "permission")):
                        hasCustom = True
                        continue # don't want to count custom permissions in the histogram dictionary since they will all of them will be unusual
                    #perm = perm[-2] + "." + perm[-1]
                    if permission in dic:
                        dic[permission] += 1;
                    else:
                        dic[permission] = 1;
                final_results[entry.doc.docid]['custom'] = hasCustom
    #print dic

    DANGEROUS_PERMS = ["android.permission.ACCESS_COARSE_LOCATION",
                       "android.permission.ACCESS_FINE_LOCATION",
                       "android.permission.ACCESS_MOCK_LOCATION",
                       "android.permission.AUTHENTICATE_ACCOUNTS",
                       "android.permission.BLUETOOTH",
                       "android.permission.BLUETOOTH_ADMIN",
                       "android.permission.CALL_PHONE",
                       "android.permission.CAMERA",
                       "android.permission.CHANGE_CONFIGURATION",
                       "android.permission.CHANGE_NETWORK_STATE",
                       "android.permission.CHANGE_WIFI_MULTICAST_STATE",
                       "android.permission.CHANGE_WIFI_STATE",
                       "android.permission.CLEAR_APP_CACHE",
                       "android.permission.DUMP",
                       "android.permission.GET_TASKS",
                       "android.permission.INTERNET",
                       "android.permission.MANAGE_ACCOUNTS",
                       "android.permission.MODIFY_AUDIO_SETTINGS",
                       "android.permission.MODIFY_PHONE_STATE",
                       "android.permission.MOUNT_FORMAT_FILESYSTEMS",
                       "android.permission.MOUNT_UNMOUNT_FILESYSTEMS",
                       "android.permission.PERSISTENT_ACTIVITY",
                       "android.permission.PROCESS_OUTGOING_CALLS",
                       "android.permission.READ_CALENDAR",
                       "android.permission.READ_CONTACTS",
                       "android.permission.READ_LOGS",
                       "android.permission.READ_OWNER_DATA",
                       "android.permission.READ_PHONE_STATE",
                       "android.permission.READ_SMS",
                       "android.permission.READ_USER_DICTIONARY",
                       "android.permission.RECEIVE_MMS",
                       "android.permission.RECEIVE_SMS",
                       "android.permission.RECEIVE_WAP_PUSH",
                       "android.permission.RECORD_AUDIO",
                       "android.permission.REORDER_TASKS",
                       "android.permission.SEND_SMS",
                       "android.permission.SET_ALWAYS_FINISH",
                       "android.permission.SET_ANIMATION_SCALE",
                       "android.permission.SET_DEBUG_APP",
                       "android.permission.SET_PROCESS_LIMIT",
                       "android.permission.SET_TIME_ZONE",
                       "android.permission.SIGNAL_PERSISTENT_PROCESSES",
                       "android.permission.SUBSCRIBED_FEEDS_WRITE",
                       "android.permission.SYSTEM_ALERT_WINDOW",
                       "android.permission.USE_CREDENTIALS",
                       "android.permission.WAKE_LOCK",
                       "android.permission.WRITE_APN_SETTINGS",
                       "android.permission.WRITE_CALENDAR",
                       "android.permission.WRITE_CONTACTS",
                       "android.permission.WRITE_EXTERNAL_STORAGE",
                       "android.permission.WRITE_OWNER_DATA",
                       "android.permission.WRITE_SETTINGS",
                       "android.permission.WRITE_SMS",
                       "android.permission.WRITE_SYNC_SETTINGS",
                       "com.android.browser.permission.READ_HISTORY_BOOKMARKS",
                       "com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"]
    #go through final_results and add field for unusual permissions
    for docid in final_results: 
        final_results[docid]['unusual'] = False
        final_results[docid]['dangerous'] = False
        for permission in final_results[docid]['permissions']:
            perm = permission.split(".")
            if (permission != "com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" and permission != "com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" and (len(perm) !=3 or perm[0] != "android" or perm[1] != "permission")):
                continue
            elif dic[permission] < 0.05*offset:
                final_results[docid]['unusual'] = True
                if 'unusual_perms' in final_results[docid]:
                    final_results[docid]['unusual_perms'].append(permission)
                else:
                    final_results[docid]['unusual_perms'] = [permission]
                if permission in DANGEROUS_PERMS:
                    final_results[docid]['dangerous'] = True
                    if 'dangerous_permissions' in final_results[docid]:
                        final_results[docid]['dangerous_permissions'].append(permission)
                    else:
                        final_results[docid]['dangerous_permissions'] = [permission]

    final = json.dumps({"app": final_results.values()})
    print final
    return None
if (len(sys.argv) == 1):
    print "You did not provide AppID. This parameter default is com.WiredDFW.DIRECTV.unWiredRemoteLite"

elif (len(sys.argv) == 2):
    packageName = sys.argv[1]
   
elif (len(sys.argv) >= 3):
    print "Wrong input, there may be a tab character!"
    sys.exit(0)


# Check request content   
print "packageName:",packageName


api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

#for i in range(MAX_RESULTS/NB_RESULTS):
    
response = api.details(packageName)
#j = response.getResponse
c = response.docV2

CATEGORY = c.details.appDetails.appCategory
print "anh yeu em"
print c
            #print j.docid.encode('utf8')
            #write_result_line(j,saveFile)
print "Em khong yeu anh"
print_details_line(c)
elif (len(sys.argv) == 2):
    packageName = sys.argv[1]

elif (len(sys.argv) >= 3):
    print "Wrong input, there may be a tab character!"
    sys.exit(0)



# Check request content   
print "packageName:",packageName
print "Number of request:", NB_RES



api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
ID = "AOqpTOEjTOe3SLM39KkxcHYWJ_HZ5f9pdv7pstjBjn3rwRF_0LpZrIED-Ok31aoQnlnuW8qdmwsLZeKxufpupgQ"

#response = api.reviewById(packageName, filterByDevice, ID)
#print response
#packageName = "com.WiredDFW.DIRECTV.unWiredRemoteLite" #Default value
#packageName = "com.happybug.livewallpaper.jellyfishlite"
print "Nextline:", packageName
filterByDevice=False
sort=0


api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
예제 #38
0
  print "subcategory: You can get a list of all subcategories available, by supplying a valid category"
  sys.exit(0)
  
cat = sys.argv[1]
ctr = None
nb_results = None
offset = None

if(len(sys.argv) >= 3):
  ctr = sys.argv[2]
if(len(sys.argv) >= 4):
  nb_results = sys.argv[3]
if(len(sys.argv) == 5):
  offset = sys.argv[4]

api = GooglePlayAPI()
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
try:
  message = api.list(cat, ctr, nb_results, offset)
except:
  print "Error: HTTP 500 - one of the provided parameters is invalid"


if(ctr is None):
  print SEPARATOR.join(["Subcategory ID", "Name"])
  for doc in message.doc:
    print SEPARATOR.join([doc.docid.encode('utf8'), doc.title.encode('utf8')])

else:
  print_header_line()
  doc = message.doc[0]
예제 #39
0
#!/usr/bin/python2

import sys
import urlparse
import code
from pprint import pprint
from google.protobuf import text_format

from config import *
from googleplay import GooglePlayAPI
import os
import requests

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

package_name = "com.tellm.android.app"

r = api.details(package_name)
version = r.docV2.details.appDetails.versionString
date = r.docV2.details.appDetails.uploadDate
version_code = r.docV2.details.appDetails.versionCode
file_size = r.docV2.details.appDetails.installationSize

print "current version is ", version, "published on ", date
f_name = "/root/jodeldecompile/apks/com.tellm.android.app-%s.apk" % version

if os.path.isfile(f_name) and os.path.getsize(f_name) == file_size:
    print "already downloaded"
else:
    print "downloading apk to %s" % f_name
예제 #40
0
    m = api.details(packagename)
    doc = m.docV2
    vc = doc.details.appDetails.versionCode
    ot = doc.offer[0].offerType

    # Download
    print "Downloading %s..." % sizeof_fmt(
        doc.details.appDetails.installationSize),
    data = api.download(packagename, vc, ot)
    open(filename, "wb").write(data)
    print "Done"


if __name__ == '__main__':
    #get categories
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    #getApps(api,'GAME','apps_topselling_free','100',None)
    #getApps(api,'BOOKS_AND_REFERENCE','apps_topselling_free','100',None)
    #getApps(api,'BUSINESS','apps_topselling_free','3','100')
    #getApps(api,'COMICS','apps_topselling_free','10','100')
    #getApps(api,'COMMUNICATION','apps_topselling_free','2','100')
    #getApps(api,'EDUCATION','apps_topselling_free','100',None)
    #getApps(api,'ENTERTAINMENT','apps_topselling_free','30','100')
    #getApps(api,'FINANCE','apps_topselling_free','10','290')
    #getApps(api,'HEALTH_AND_FITNESS','apps_topselling_free','5','125')
    #getApps(api,'LIBRARIES_AND_DEMO','apps_topselling_free','20','120')
    #getApps(api,'LIFESTYLE','apps_topselling_free','50','200')
    #getApps(api,'APP_WALLPAPER','apps_topselling_free','100','100')
    #getApps(api,'MEDIA_AND_VIDEO','apps_topselling_free','10','100')
예제 #41
0
cat = sys.argv[1]
ctr = None
nb_results = None
offset = None

if (len(sys.argv) >= 3):
    ctr = sys.argv[2]
if (len(sys.argv) >= 4):
    nb_results = sys.argv[3]
if (len(sys.argv) == 5):
    offset = sys.argv[4]

if nb_results == None:
    nb_results = 20

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

n = 0
while (n < nb_results):
    if n == 0:
        n += 20
        message = api.list(cat, ctr, '20', offset)
        if message == False:
            print "Error: HTTP 500 - one of the provided parameters is invalid"
            exit(1)
    else:
        time.sleep(2)
        message = api.getNextPage(nextPageUrl)
        if message == False:
                print 'error or no more app'
예제 #42
0


if (len(sys.argv) >= 3):
     NB_RES = int(sys.argv[2])

if (len(sys.argv) >= 4):
     OFFSET = int(sys.argv[3])
    
# Check request content   
print "Request:", request
print "Number of request:", NB_RES
print "Offset:", OFFSET


api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
print "NB_RES/OFFSET:",NB_RES/OFFSET
for i in range (50):
    message = api.search(request, str(NB_RES), str(i*NB_RES))
    doc = message.doc[0]
    for c in doc.child:
        print c
        l = [           
                # unicode type
                c.docid,
                c.title,
                c.creator,
                c.descriptionHtml, # need to remove control characters
                c.offer[0].formattedAmount,
                            
예제 #43
0
if (len(sys.argv) < 2):
    print "Usage: %s request [nb_results] [offset]" % sys.argv[0]
    print "Search for an app."
    print "If request contains a space, don't forget to surround it with \"\""
    sys.exit(0)

request = sys.argv[1]
nb_res = None
offset = None

if (len(sys.argv) >= 3):
    nb_res = int(sys.argv[2])

if (len(sys.argv) >= 4):
    offset = int(sys.argv[3])

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

try:
    message = api.search(request, nb_res, offset)
except:
    print "Error: something went wrong. Maybe the nb_res you specified was too big?"
    sys.exit(1)

print_header_line()
doc = message.doc[0]
for c in doc.child:
    print_result_line(c)

    print "Usage: %s request [nb_results] [offset]" % sys.argv[0]
    print "Search for an app."
    print "If request contains a space, don't forget to surround it with \"\""
    sys.exit(0)

request = sys.argv[1]
nb_res = None
offset = None

if (len(sys.argv) >= 3):
    nb_res = int(sys.argv[2])

if (len(sys.argv) >= 4):
    offset = int(sys.argv[3])

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

try:
    message = api.search(request, nb_res, offset)
except:
    print "Error: something went wrong. Maybe the nb_res you specified was too big?"
    sys.exit(1)

print_header_line()
print message
doc = message.doc[0]
for c in doc.child:
    print_result_line(c)

예제 #45
0
#!/usr/bin/python

# Do not remove
GOOGLE_LOGIN = GOOGLE_PASSWORD = AUTH_TOKEN = None

from config import *
from pprint import pprint
from googleplay import GooglePlayAPI
from google.protobuf import text_format
import sys
import urlparse

api = GooglePlayAPI()
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
response = api.browse()

print SEPARATOR.join(["ID", "Name"])
for c in response.category:
  print SEPARATOR.join(i.encode('utf8') for i in [urlparse.parse_qs(c.dataUrl)['cat'][0], c.name])


예제 #46
0
def getReviews(packageName,pip):
    NB_RES = 20;
    MAX_RESULTS = 500;
    #packageName = "com.WiredDFW.DIRECTV.unWiredRemoteLite" #Default value
    #packageName = "com.happybug.livewallpaper.jellyfishlite"
    print "Nextline:", packageName
    filterByDevice=False
    sort=0


    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN,pip)

    #response = api.reviewById(packageName, filterByDevice, ID)
    #print response
    for s in range(4):
        sort = s
        time.sleep(3)
        for m in range(MAX_RESULTS/NB_RES):
            time.sleep(1)
            response = api.reviews(packageName, filterByDevice, sort, str(NB_RES),str(m*NB_RES),pip=pip)
    #        print response
            for n in range(NB_RES):
                try:
                    c = response.getResponse.review[n]
                    l = [  
                               
                               c.documentVersion,
                               
                               c.timestampMsec,
                               
                               c.starRating,
                               c.title,
                               c.comment,
                               c.commentId,
                               
                               c.deviceName,
#                               c.replyText,
#                               c.replyTimestampMsec, 
                               ]

                    #Check whether comment exists
                    fileName = "%d.%s.csv" %(s,packageName)
                    openfile = open(fileName,"a+")
                  
                    previousFileName = "previous.%s.csv" %packageName 
                    openPreviousFile = open(previousFileName,"a+")
                  
                    if hasInFile(openfile,c.commentId, c.timestampMsec) or hasInFile(openPreviousFile,c.commentId,c.timestampMsec):
                        openfile.close()
                        openPreviousFile.close()
                        continue
                    else:
                        print "There is new review of s = %d m = %d n = %d" %(s,m,n)
                        saveFile = open(fileName, "a+b")
                        savePreviousFile = open(previousFileName, "a+b")
                        wpb = UnicodeWriter(savePreviousFile)
                        wb = UnicodeWriter(saveFile)
                        k = []

                        for i in range(len(l)):
                            if isinstance(l[i], basestring):
                                if isinstance(l[i],unicode):
                                    l[i] = l[i].encode("utf-8")
                                    l[i] = removeSpecialKey(l[i])
        #                            print i
        #                            print type(l[i])
        #                            print l[i]
                            k = k  + [l[i]]            
                        wb.writerow(k)
                        wpb.writerow(k)
                        saveFile.close()
                        savePreviousFile.close()
                except IndexError:
                    print IndexError
                    break
            print "Getting %d to %d ..." %(m*20,(m+1)*20)
예제 #47
0
    print "subcategory: You can get a list of all subcategories available, by supplying a valid category"
    sys.exit(0)

cat = sys.argv[1]
ctr = None
nb_results = None
offset = None

if (len(sys.argv) >= 3):
    ctr = sys.argv[2]
if (len(sys.argv) >= 4):
    nb_results = sys.argv[3]
if (len(sys.argv) == 5):
    offset = sys.argv[4]

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
try:
    message = api.list(cat, ctr, nb_results, offset)
except:
    print "Error: HTTP 500 - one of the provided parameters is invalid"

if (ctr is None):
    print SEPARATOR.join(["Subcategory ID", "Name"])
    for doc in message.doc:
        print SEPARATOR.join(
            [doc.docid.encode('utf8'),
             doc.title.encode('utf8')])
else:
    print_header_line()
    doc = message.doc[0]
예제 #48
0
import sys
import urlparse
from pprint import pprint
from google.protobuf import text_format

from __init__ import *
from googleplay import GooglePlayAPI

if (len(sys.argv) < 2):
    print "Usage: %s packagename1 [packagename2 [...]]" % sys.argv[0]
    print "Display permissions required to install the specified app(s)."
    sys.exit(0)

packagenames = sys.argv[1:]

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

# Only one app
if (len(packagenames) == 1):
    response = api.details(packagenames[0])
    print "\n".join(i.encode('utf8') for i in response.docV2.details.appDetails.permission)

else: # More than one app
    response = api.bulkDetails(packagenames)

    for entry in response.entry:
        if (not not entry.ListFields()): # if the entry is not empty
            print entry.doc.docid + ":"
            print "\n".join("    "+i.encode('utf8') for i in entry.doc.details.appDetails.permission)
            print
예제 #49
0
if ((len(sys.argv) >= 3) and (len(sys.argv)<5)):
    filename = sys.argv[2]
    google_pass = sys.argv[3]
elif (len(sys.argv)<3):
    filename = packagename + ".apk"
    google_pass = getpass.getpass()
else:
    print "Usage: %s packagename filename, password]"
    print "Download an app."
    print "If filename is not present, will write to packagename.apk."
    print "If password is not present, user will be prompted for one"
    sys.exit(0)

# Connect
api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, google_pass, AUTH_TOKEN)

# Get the version code and the offer type from the app details
m = api.details(packagename)
doc = m.docV2
vc = doc.details.appDetails.versionCode
ot = doc.offer[0].offerType

# Download
print "Downloading %s..." % sizeof_fmt(doc.details.appDetails.installationSize),
data = api.download(packagename, vc, ot)
open(filename, "wb").write(data)
print "Done"

예제 #50
0
if (len(sys.argv) < 2):
    print "Usage: %s packagename [filename]"
    print "Download an app."
    print "If filename is not present, will write to packagename.apk."
    sys.exit(0)

packagename = sys.argv[1]

if (len(sys.argv) == 3):
    filename = sys.argv[2]
else:
    filename = packagename + ".apk"

# Connect
api = GooglePlayAPI("3eded73a231f2845")
api.login("*****@*****.**", "gruegrue", AUTH_TOKEN)

# Get the version code and the offer type from the app details
m = api.details(packagename)
doc = m.docV2
vc = doc.details.appDetails.versionCode
ot = doc.offer[0].offerType

# Download
print "Downloading %s..." % sizeof_fmt(
    doc.details.appDetails.installationSize),
data = api.download(packagename, vc, ot)
open(filename, "wb").write(data)
print "Done"
예제 #51
0
parser.add_argument("--offset", nargs=1, type=int, default=None,
                    help='You can get a list of all subcategories available, \
                    by supplying a valid category')

args = parser.parse_args()
cat = args.category[0]
ctr = args.subcategory[0]
nb_results = args.nb_results[0]
if args.offset:
    logging.debug("there's offset : {}".format(args.offset))
    offset = args.offset[0]
else:
    offset = None

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
try:
    message = api.list(cat, ctr, nb_results, offset)
except:
    logging.error("Error: HTTP 500 - one of the provided parameters is invalid")
    raise

today = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
rank = 1
for i in message.doc[0].child:

    result = {}

    result['vt_scan'] = False
예제 #52
0
if (len(sys.argv) < 2):
    print "Usage: %s packagename [filename] [versionCode]"
    print "Download an app."
    print "If filename is not present, will write to packagename.apk."
    sys.exit(0)

packagename = sys.argv[1]

if (len(sys.argv) == 3):
    filename = sys.argv[2]
else:
    filename = packagename + ".apk"

# Connect
api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

# Get the version code and the offer type from the app details
m = api.details(packagename)
if m == False:
    print 'error in api.details'
    exit(1)

doc = m.docV2
vc = doc.details.appDetails.versionCode

# Set the version code
if (len(sys.argv) == 3):
    vc = int(sys.argv[2])
else:
예제 #53
0
#!/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.
Feel free to use help(api).
"""

import sys
import urlparse
import code
from pprint import pprint
from google.protobuf import text_format

from config import *
from googleplay import GooglePlayAPI

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

try:
    from IPython import embed
    embed()
except:
    code.interact(BANNER, local=locals())
예제 #54
0
#!/usr/bin/python

# Do not remove
GOOGLE_LOGIN = GOOGLE_PASSWORD = AUTH_TOKEN = None

import requests
import sys
import urlparse
from pprint import pprint
from google.protobuf import text_format

from config import *
from googleplay import GooglePlayAPI

# Ignore unverified HTTPS request warning.
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
response = api.browse()

print SEPARATOR.join(["ID", "Name"])
for c in response.category:
    print SEPARATOR.join(
        i.encode('utf8')
        for i in [urlparse.parse_qs(c.dataUrl)['cat'][0], c.name])
예제 #55
0
from config import *
from googleplay import GooglePlayAPI
from helpers import sizeof_fmt, print_header_line, print_result_line, print_first_result

if (len(sys.argv) < 2):
    print "Usage: %s request [nb_results] [offset]" % sys.argv[0]
    print "Search for an app."
    print "If request contains a space, don't forget to surround it with \"\""
    sys.exit(0)

packagename = sys.argv[1]
nb_res = None
offset = None

if (len(sys.argv) >= 3):
    nb_res = int(sys.argv[2])

if (len(sys.argv) >= 4):
    offset = int(sys.argv[3])

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

m = api.details(packagename)
doc = m.docV2
vc = doc.details.appDetails.versionCode

f = open('version_codes','w')
f.write(str(vc))
f.close()