Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Feature/reviews #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ By default, all scripts have CSV output. You can use Linux's `column` to prettif
Earth 3D com.jmsys.earth3d Dokon Jang 0 Gratuit 1 12 3.4MB 4.05 500 000+
[...]

### Fetch reviews
$ python reviews.py
Usage: reviews.py request [package] [offset]
Returns 20 reviews for a given app package.

$ python reviews.py com.google.android.gm

### Browse categories

You can list all app categories this way:
Expand Down
72 changes: 72 additions & 0 deletions reviews.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/python

# Do not remove
GOOGLE_LOGIN = GOOGLE_PASSWORD = AUTH_TOKEN = None

import sys
from pprint import pprint

from config import *
from googleplay import GooglePlayAPI
from helpers import sizeof_fmt

def print_header_line():
l = [ "authorName",
"url",
"source",
"documentVersion",
"timestampMsec",
"starRating",
"title",
"comment",
"commentId",
"deviceName",
"replyText",
"replyTimestampMsec" ]
print SEPARATOR.join(l)

def print_result_line(c):
#c.offer[0].micros/1000000.0
#c.offer[0].currencyCode
l = [ c.authorName,
c.url,
c.source,
c.documentVersion,
c.timestampMsec,
c.starRating,
c.title,
c.comment.replace("\n", ' '),
c.commentId,
c.deviceName,
c.replyText.replace("\n", ' '),
c.replyTimestampMsec]
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, 2, 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()
for c in resp.review:
if c != None:
print_result_line(c)