From 1d4de35240adce11b60a8f7122eb81f1a4586054 Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Thu, 6 Feb 2014 14:26:54 +0200 Subject: [PATCH 1/2] New script to fetch reviews --- reviews.py | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 reviews.py diff --git a/reviews.py b/reviews.py new file mode 100755 index 0000000..3f369a9 --- /dev/null +++ b/reviews.py @@ -0,0 +1,79 @@ +#!/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 + +# documentVersion: "0.9.6" +# timestampMsec: 1391263931919 +# starRating: 2 +# title: "Still doesn\'t help" +# comment: "No pop account access so does not help me with linking my workspace email" +# commentId: "gp:AOqpTOG3eCEN9z45LVqgX6fGqEKgLnjfH9hmQ2HioQv3s1dGdlLJGVqWjX1FovY7V9NmjzeYA0E14BeNrbam_aE" + +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) + From ece12eafc4c273855c8ffb62b149a6b991d8533e Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Thu, 6 Feb 2014 14:29:54 +0200 Subject: [PATCH 2/2] Adjust README --- README.md | 7 +++++++ reviews.py | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 379d54c..3a4f45a 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/reviews.py b/reviews.py index 3f369a9..6556b7f 100755 --- a/reviews.py +++ b/reviews.py @@ -10,13 +10,6 @@ from googleplay import GooglePlayAPI from helpers import sizeof_fmt -# documentVersion: "0.9.6" -# timestampMsec: 1391263931919 -# starRating: 2 -# title: "Still doesn\'t help" -# comment: "No pop account access so does not help me with linking my workspace email" -# commentId: "gp:AOqpTOG3eCEN9z45LVqgX6fGqEKgLnjfH9hmQ2HioQv3s1dGdlLJGVqWjX1FovY7V9NmjzeYA0E14BeNrbam_aE" - def print_header_line(): l = [ "authorName", "url",