itunes_store_bot 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/README.md +4 -0
- data/itunes_json_responses_example/reviews.json +3033 -0
- data/itunes_json_responses_example/reviews_summary.json +44 -0
- data/itunes_store_bot.gemspec +19 -0
- data/lib/itunes_store_bot.rb +167 -0
- metadata +90 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// URL https://itunes.apple.com/gb/customer-reviews/id576939960?dataOnly=true&displayable-kind=11
|
|
2
|
+
// Host: itunes.apple.com
|
|
3
|
+
// X-Apple-Store-Front: 143444,17
|
|
4
|
+
// Accept-Encoding: gzip, deflate
|
|
5
|
+
// Accept-Language: en-us, en;q=0.50
|
|
6
|
+
// Accept: */*
|
|
7
|
+
// User-Agent: iTunes/11.1.5 (Macintosh; OS X 10.9.2) AppleWebKit/537.74.9
|
|
8
|
+
// Connection: keep-alive
|
|
9
|
+
// Referer: https://itunes.apple.com/gb/app/minigore-2-zombies/id576939960?mt=8
|
|
10
|
+
// X-Dsid: 107225448
|
|
11
|
+
// Cookie: itsMetricsR=Search-GB@@Media%20Search%20Pages@@Tab_allResults%7CSwoosh_1%7CLockup_1@@; mz_user_info_version=0; X-JS-SP-TOKEN=ShFFJg7tbLc73quBpXRx9A==; X-JS-TIMESTAMP=1398522586; dssid2=8c2b3fbc-280c-40e1-8ffa-e62cd445996c; itspod=16; mz_at0-107225448=AwQAAAEBAAGuGAAAAABTDGLhY26IOIbXt7Dsyv9cBKkMPiF3XZQ=; mz_at_ssl-107225448=AwUAAAEBAAGuGAAAAABTDGLh9z+4LJ4qMCzdE4BpGWpJVIufa8c=; ns-mzf-inst=35-139-80-104-92-8186-162518-16-nk11; Pod=16; pxro=1; s_fid=66291422B54414F6-23C1CAE2F51BB888; s_vi=[CS]v1|2937EB8085010821-60000101E0001D80[CE]; s_vnum_n2_us=3|12,97|1,0|1; X-Dsid=107225448; xp_ci=3zra8w6zCCqz5KIzAfBz1A0JaXYPl
|
|
12
|
+
// X-Apple-Tz: 3600
|
|
13
|
+
// Pragma: no-cache
|
|
14
|
+
// Cache-Control: no-cache
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
"adamId": 576939960,
|
|
19
|
+
"totalNumberOfReviews": 189,
|
|
20
|
+
"writeUserReviewUrl": "https://userpub.itunes.apple.com/WebObjects/MZUserPublishing.woa/wa/writeUserReview?cc=gb&displayable-kind=11&id=576939960",
|
|
21
|
+
"clickToRateUrl": "https://userpub.itunes.apple.com/WebObjects/MZUserPublishing.woa/wa/userRateContent?displayable-kind=11&id=576939960",
|
|
22
|
+
"userReviewsRowUrl": "https://itunes.apple.com/WebObjects/MZStore.woa/wa/userReviewsRow",
|
|
23
|
+
"userReviewsSortOptions": [{
|
|
24
|
+
"sortId": 1,
|
|
25
|
+
"name": "Most Helpful"
|
|
26
|
+
}, {
|
|
27
|
+
"sortId": 2,
|
|
28
|
+
"name": "Most Favorable"
|
|
29
|
+
}, {
|
|
30
|
+
"sortId": 3,
|
|
31
|
+
"name": "Most Critical"
|
|
32
|
+
}, {
|
|
33
|
+
"sortId": 4,
|
|
34
|
+
"name": "Most Recent"
|
|
35
|
+
}],
|
|
36
|
+
"kindId": 11,
|
|
37
|
+
"kindExtId": "iosSoftware",
|
|
38
|
+
"kindName": "software",
|
|
39
|
+
"saveUserReviewUrl": "https://userpub.itunes.apple.com/WebObjects/MZUserPublishing.woa/wa/saveUserReview?displayable-kind=11",
|
|
40
|
+
"ratingAverage": 4.25494000000000038852476791362278163433074951171875,
|
|
41
|
+
"ratingCount": 506,
|
|
42
|
+
"ariaLabelForRatings": "4 and a half stars",
|
|
43
|
+
"ratingCountList": [48, 23, 28, 60, 347]
|
|
44
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = 'itunes_store_bot'
|
|
7
|
+
s.version = '0.1.3'
|
|
8
|
+
s.date = '2014-04-26'
|
|
9
|
+
s.summary = 'Get any iOS App Rating info'
|
|
10
|
+
s.description = '[Alpha version] Get your iOS App Rating, number of votes.. from the iTunes Store'
|
|
11
|
+
s.authors = ['Stefano Bortolotti']
|
|
12
|
+
s.files = `git ls-files`.split($/)
|
|
13
|
+
s.require_paths = ['lib']
|
|
14
|
+
s.homepage = 'http://rubygems.org/gems/itunes_store_bot'
|
|
15
|
+
s.license = 'MIT'
|
|
16
|
+
|
|
17
|
+
s.add_dependency('http', '~> 0.5', '>= 0.5.0')
|
|
18
|
+
s.add_dependency('json', '~> 1.8', '>= 1.8.0')
|
|
19
|
+
end
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'openssl'
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
class AppStoreBot
|
|
6
|
+
|
|
7
|
+
def initialize(app_id, app_country='gb')
|
|
8
|
+
@app_id = app_id
|
|
9
|
+
@app_country = app_country
|
|
10
|
+
|
|
11
|
+
@itunes_domain_url = 'itunes.apple.com'
|
|
12
|
+
@itunes_http_options = {'User-Agent' => 'iTunes/11.1.5 (Macintosh; OS X 10.9.2) AppleWebKit/537.74.9'}
|
|
13
|
+
@itunes_reviews_url = ''
|
|
14
|
+
|
|
15
|
+
@app_data = {}
|
|
16
|
+
get_app_info
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def get_app_data
|
|
20
|
+
@app_data
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def update_app_data
|
|
24
|
+
get_app_info
|
|
25
|
+
@app_data
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def get_app_rating
|
|
29
|
+
@app_data['all_versions'][:ratingAverage]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def get_app_voters_count
|
|
33
|
+
@app_data['all_versions'][:ratingCount]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def get_last_app_rating
|
|
37
|
+
@app_data['last_version'][:ratingAverage]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def get_last_app_voters_count
|
|
41
|
+
@app_data['last_version'][:ratingCount]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def get_last_version_reviews(sort_type='4') # 1: , 2: , 3: , 4: most recent
|
|
45
|
+
get_reviews('last_version', sort_type)
|
|
46
|
+
@app_data['last_version'][:reviews]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def get_all_versions_reviews(sort_type='4') # 1: , 2: , 3: , 4: most recent
|
|
50
|
+
get_reviews('all_versions', sort_type)
|
|
51
|
+
@app_data['all_versions'][:reviews]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
def get_app_info
|
|
57
|
+
|
|
58
|
+
# https://itunes.apple.com/gb/customer-reviews/id576939960?dataOnly=true&displayable-kind=11&appVersion=current
|
|
59
|
+
http = Net::HTTP.new(@itunes_domain_url, Net::HTTP.https_default_port())
|
|
60
|
+
http.use_ssl = true
|
|
61
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # disable ssl certificate check
|
|
62
|
+
|
|
63
|
+
path = "/#{@app_country}/customer-reviews/id#{@app_id}?dataOnly=true&displayable-kind=11"
|
|
64
|
+
# request the current app json data
|
|
65
|
+
response = http.request( Net::HTTP::Get.new( path + "&appVersion=current" , @itunes_http_options) )
|
|
66
|
+
|
|
67
|
+
if response.code != '200'
|
|
68
|
+
puts "App Store store website communication (status-code: #{response.code})\n#{response.body}"
|
|
69
|
+
else
|
|
70
|
+
data = extract_app_data_from_raw_json( response.body )
|
|
71
|
+
if data[:error]
|
|
72
|
+
puts "Application requested couldn't be found [#{data[:error]}]"
|
|
73
|
+
end
|
|
74
|
+
@app_data['last_version'] = data
|
|
75
|
+
#puts "#{@app_data['last_version']}"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# request the app all versions json data
|
|
79
|
+
response2 = http.request( Net::HTTP::Get.new( path , @itunes_http_options) )
|
|
80
|
+
|
|
81
|
+
if response2.code != '200'
|
|
82
|
+
puts "App Store store website communication (status-code: #{response2.code})\n#{response2.body}"
|
|
83
|
+
else
|
|
84
|
+
data = extract_app_data_from_raw_json( response2.body )
|
|
85
|
+
if data[:error]
|
|
86
|
+
puts "Application requested couldn't be found [#{data[:error]}]"
|
|
87
|
+
end
|
|
88
|
+
@app_data['all_versions'] = data
|
|
89
|
+
#puts "#{@app_data['all_versions']}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def extract_app_data_from_raw_json(data)
|
|
95
|
+
raw_app_data = JSON.parse( data )
|
|
96
|
+
set_itunes_review_url_path( raw_app_data['userReviewsRowUrl'] || nil ) unless raw_app_data['error']
|
|
97
|
+
parsed_app_data = {
|
|
98
|
+
:ratingCount => raw_app_data['ratingCount'] || 0,
|
|
99
|
+
:ratingAverage => raw_app_data['ratingAverage'] || 0.0,
|
|
100
|
+
:ratingCountList => raw_app_data['ratingCountList'] || [0, 0, 0, 0, 0],
|
|
101
|
+
:numberOfReviews => raw_app_data['totalNumberOfReviews'] || 0,
|
|
102
|
+
:reviews => []
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if raw_app_data['error']
|
|
106
|
+
parsed_app_data[:error] = raw_app_data['error']
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
parsed_app_data
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def set_itunes_review_url_path(url)
|
|
113
|
+
if url
|
|
114
|
+
index = url.index(@itunes_domain_url)
|
|
115
|
+
@itunes_reviews_url = url[index, url.length].sub! @itunes_domain_url, ""
|
|
116
|
+
else
|
|
117
|
+
puts 'Please provide a valid URL string.'
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def get_reviews(version='last_version', sort_type='1')
|
|
122
|
+
|
|
123
|
+
# https://itunes.apple.com/WebObjects/MZStore.woa/wa/userReviewsRow?cc=gb&id=576939960&displayable-kind=11&startIndex=0&endIndex=8&sort=1&appVersion=current
|
|
124
|
+
http = Net::HTTP.new(@itunes_domain_url, Net::HTTP.https_default_port())
|
|
125
|
+
http.use_ssl = true
|
|
126
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # disable ssl certificate check
|
|
127
|
+
|
|
128
|
+
query_parameters = "?cc=#{@app_country}&id=#{@app_id}&displayable-kind=11&startIndex=0&endIndex=9&sort=#{sort_type}"
|
|
129
|
+
query_parameters += "&appVersion=current" if ( version == 'last_version' )
|
|
130
|
+
path = @itunes_reviews_url + query_parameters
|
|
131
|
+
#puts path
|
|
132
|
+
|
|
133
|
+
# request the app json data
|
|
134
|
+
response = http.request( Net::HTTP::Get.new( path + query_parameters, @itunes_http_options) )
|
|
135
|
+
|
|
136
|
+
if response.code != '200'
|
|
137
|
+
puts "App Store store communication (status-code: #{response.code})\n#{response.body}"
|
|
138
|
+
else
|
|
139
|
+
#print "#{response.body}\n"
|
|
140
|
+
reviews = JSON.parse( response.body )
|
|
141
|
+
parsed_reviews = []
|
|
142
|
+
|
|
143
|
+
reviews['userReviewList'].each do |review|
|
|
144
|
+
#print "#{review}\n"
|
|
145
|
+
parsed_reviews.push( {
|
|
146
|
+
:title => review['title'],
|
|
147
|
+
:vote => review['rating'],
|
|
148
|
+
:body => review['body'],
|
|
149
|
+
:date => review['date'],
|
|
150
|
+
:name => review['name'],
|
|
151
|
+
:id => review['userReviewId']
|
|
152
|
+
} )
|
|
153
|
+
end
|
|
154
|
+
@app_data[version][:reviews] = parsed_reviews
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
#a = AppStoreBot.new('457876088', 'us') # minigore 576939960; ASOS 457876088
|
|
161
|
+
#puts "Last App Rating #{a.get_last_app_rating}"
|
|
162
|
+
#puts "Last App Voters count #{a.get_last_app_voters_count}"
|
|
163
|
+
#puts "All time App Rating #{a.get_app_rating}"
|
|
164
|
+
#puts "All time App Voters count #{a.get_app_voters_count}"
|
|
165
|
+
#puts "#{a.get_last_version_reviews('4')}"
|
|
166
|
+
#puts a.get_app_data
|
|
167
|
+
|
metadata
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: itunes_store_bot
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Stefano Bortolotti
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-04-26 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: http
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.5'
|
|
20
|
+
- - '>='
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 0.5.0
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - ~>
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0.5'
|
|
30
|
+
- - '>='
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 0.5.0
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: json
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ~>
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '1.8'
|
|
40
|
+
- - '>='
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: 1.8.0
|
|
43
|
+
type: :runtime
|
|
44
|
+
prerelease: false
|
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ~>
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '1.8'
|
|
50
|
+
- - '>='
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: 1.8.0
|
|
53
|
+
description: '[Alpha version] Get your iOS App Rating, number of votes.. from the
|
|
54
|
+
iTunes Store'
|
|
55
|
+
email:
|
|
56
|
+
executables: []
|
|
57
|
+
extensions: []
|
|
58
|
+
extra_rdoc_files: []
|
|
59
|
+
files:
|
|
60
|
+
- .gitignore
|
|
61
|
+
- README.md
|
|
62
|
+
- itunes_json_responses_example/reviews.json
|
|
63
|
+
- itunes_json_responses_example/reviews_summary.json
|
|
64
|
+
- itunes_store_bot.gemspec
|
|
65
|
+
- lib/itunes_store_bot.rb
|
|
66
|
+
homepage: http://rubygems.org/gems/itunes_store_bot
|
|
67
|
+
licenses:
|
|
68
|
+
- MIT
|
|
69
|
+
metadata: {}
|
|
70
|
+
post_install_message:
|
|
71
|
+
rdoc_options: []
|
|
72
|
+
require_paths:
|
|
73
|
+
- lib
|
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
|
+
requirements:
|
|
76
|
+
- - '>='
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: '0'
|
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - '>='
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '0'
|
|
84
|
+
requirements: []
|
|
85
|
+
rubyforge_project:
|
|
86
|
+
rubygems_version: 2.2.2
|
|
87
|
+
signing_key:
|
|
88
|
+
specification_version: 4
|
|
89
|
+
summary: Get any iOS App Rating info
|
|
90
|
+
test_files: []
|