store_api 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 815c553130c66a2e04469be1aafbdc901421be26
4
- data.tar.gz: a3f5193ae4d8f2898718f11fb08807d397b9f357
3
+ metadata.gz: 20c10fc343bdc8389486ff0be8b917379e48612a
4
+ data.tar.gz: adbeafe983c8b4085baf38b07371bcfc756ccb75
5
5
  SHA512:
6
- metadata.gz: 422dc029152f3ab93ead0f7a48e442d0177dfbcbd937a5134214180fcae1afdf6a0949be7aacb6a3760e0fb3e31dc2943f4e2685a0f31d71edc1a6762f7c9c53
7
- data.tar.gz: 2a7e598dea854bcb08632411f24126a5b10d8c31963d4b1cfd161ef84e0d626935151e9cc317f0b055007c59ab8fc63ccdff0413ed1a21129cfa525f8c2dc3e5
6
+ metadata.gz: dd1c6de6aaaed6b2cda456fa6ce8ce31b7cc60d982358e688456f04559b68a01ee1067ca85c3751008f149eb4a3fc9462d772889db7bbfd2b300bfb7193b9368
7
+ data.tar.gz: 0d2b5d3c4531a61a15539955cf108291952ccc979f8337bb93ef6d8f9e8dfe070aca1cfd9f4f0b602c68d71de9a47aa6f234489d3af5d248347ab746f3c29dd2
data/README.md CHANGED
@@ -41,10 +41,13 @@ puts apps.title
41
41
  ```ruby
42
42
  # Top Grossing Android Apps
43
43
  ranking = StoreApi::GooglePlay::Apps::Ranking.new('topgrossing')
44
+ puts ranking.topchart
44
45
  # Top Grossing Games
45
46
  ranking = StoreApi::GooglePlay::Apps::Ranking.new('topgrossing','GAME')
47
+ puts ranking.topchart
46
48
  # Trending Apps
47
49
  trending_apps = StoreApi::GooglePlay::Apps::Ranking.new('movers_shakers')
50
+ puts trending_apps.topchart
48
51
  ```
49
52
 
50
53
  - search apps
@@ -59,6 +62,23 @@ search_apps = StoreApi::GooglePlay::Apps::Search.new('candy crush')
59
62
  developer_apps = StoreApi::GooglePlay::Apps::Developer.new('King')
60
63
  ```
61
64
 
65
+ #### AppStore
66
+ - app details
67
+
68
+ ```ruby
69
+ apps = StoreApi::AppStore::Apps::Details.new('850417475', 'US')
70
+ puts apps.title
71
+ >>> "Candy Crush Soda Saga"
72
+ ```
73
+
74
+ - ranking chart
75
+
76
+ ```ruby
77
+ # us topgrossingapplications Games ranking
78
+ ranking = StoreApi::AppStore::Apps::Ranking.new('topgrossingapplications', '7001', 'us', 20)
79
+ puts ranking.topchart
80
+ ```
81
+
62
82
  ## Contributing
63
83
 
64
84
  1. Fork it ( https://github.com/tatsu07/store_api/fork )
@@ -0,0 +1,68 @@
1
+ # encoding : utf-8
2
+
3
+ module StoreApi
4
+ module AppStore
5
+ module Apps
6
+ ##
7
+ # app store detail class
8
+ class Details
9
+ include StoreApi::Request
10
+ @@path = '/lookup'
11
+ attr_accessor :id, :title, :cover_image, :developer,
12
+ :developer_url, :categories, :category,
13
+ :category_id, :category_ids, :price,
14
+ :screenshot, :description, :rating_value,
15
+ :rating_count, :rating_score, :release_notes, :date_published,
16
+ :file_size, :software_version, :content_rating,
17
+ :supported_devices, :bundle_id
18
+
19
+ ##
20
+ # initialize
21
+ # @param [String] id
22
+ # @param [String] lang
23
+ # @param [Hash] proxy
24
+ # @param [Hash] header
25
+ def initialize(id, country=nil, proxy=nil, header=nil)
26
+ params = {'id' => id, 'country' => country, 'entry' => 'software' }
27
+ begin
28
+ html = get(StoreApi::AppStore::HOST, @@path, params, StoreApi::AppStore::HTTPS, proxy, header)
29
+ @raw_details = JSON.load(html)['results'][0]
30
+ @id = @raw_details['trackId']
31
+ @title = @raw_details['trackName']
32
+ @cover_image = @raw_details['artworkUrl60']
33
+ @developer = @raw_details['sellerName']
34
+ @developer_url = @raw_details['artistViewUrl']
35
+ @category = @raw_details['primaryGenreName']
36
+ @categories = @raw_details['genres']
37
+ @category_id = @raw_details['primaryGenreId']
38
+ @category_ids = @raw_details['genreIds']
39
+ @price = @raw_details['price']
40
+ @screenshot = @raw_details['screenshotUrls']
41
+ @description = @raw_details['description']
42
+ @rating_value = @raw_details['averageUserRating']
43
+ @rating_count = @raw_details['userRatingCount']
44
+ @rating_score = @raw_details['averageUserRating']
45
+ @release_notes = @raw_details['releaseNotes']
46
+ @date_published = @raw_details['releaseDate']
47
+ @file_size = @raw_details['fileSizeBytes']
48
+ @software_version = @raw_details['version']
49
+ @content_rating = @raw_details['contentAdvisoryRating']
50
+ @supported_devices = @raw_details['supportedDevices']
51
+ @bundle_id = @raw_details['bundleId']
52
+ rescue => e
53
+ puts e
54
+ end
55
+ end
56
+
57
+ ##
58
+ # get raw details
59
+ # @return [Hash]
60
+ def raw_details
61
+ @raw_details
62
+ end
63
+
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,50 @@
1
+ # encoding : utf-8
2
+
3
+ module StoreApi
4
+ module AppStore
5
+ module Apps
6
+
7
+ class Ranking
8
+ include StoreApi::Request
9
+ attr_accessor :topchart
10
+
11
+ ##
12
+ # initialize
13
+ # @param [String] ranking_type
14
+ # @param [String] category_id
15
+ # @param [String] country
16
+ # @param [Integer] limit
17
+ # @param [Hash] proxy
18
+ # @param [Hash] header
19
+ def initialize(ranking_type=nil, category_id=nil, country=nil, limit=10, proxy=nil, header=nil)
20
+ if category_id.nil?
21
+ @@path = "/#{country}/rss/#{ranking_type}/limit=#{limit}/json"
22
+ else
23
+ @@path = "/#{country}/rss/#{ranking_type}/limit=#{limit}/genre=#{category_id}/json"
24
+ end
25
+
26
+ @topchart = []
27
+ feed_data = JSON.load(get(StoreApi::AppStore::HOST, @@path,
28
+ nil, StoreApi::AppStore::HTTPS, proxy, header))['feed']['entry']
29
+
30
+ feed_data.each.with_index(1) do |entry, rank|
31
+ @topchart.push({
32
+ :id => entry['id']['attributes']['im:id'],
33
+ :title => entry['im:name']['label'],
34
+ :bundle_id => entry['id']['attributes']['im:bundleId'],
35
+ :category_id => entry['category']['attributes']['im:id'],
36
+ :category => entry['category']['attributes']['label'],
37
+ :cover_image => entry['im:image'][0]['label'],
38
+ :price => entry['im:price']['attributes']['amount'],
39
+ :developer => entry['im:artist']['label'],
40
+ :release_date => entry['im:releaseDate']['label'],
41
+ :rank => rank
42
+ })
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,26 @@
1
+ # encoding : utf-8
2
+ module StoreApi
3
+ module AppStore
4
+ CATEGORY_ID_LIST = [
5
+ '6018', # Books
6
+ '6000', # Business
7
+ '6022', # Catalogs
8
+ '6017', # Education
9
+ '6016', # Entertainment
10
+ '6015', # Finance
11
+ '6023', # Food & Drink
12
+ '6014', # Games
13
+ '6013', # Health & Fitness
14
+ '6012', # Lifestyle
15
+ '6020', # Medical
16
+ '6011', # Music
17
+ '6010', # Navigation
18
+ '6009', # News
19
+ '6021', # Newsstand
20
+ '6008', # Photo & Video
21
+ '6007', # Productivity
22
+ '6006', # Reference
23
+ '6005' # Social Networking
24
+ ]
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ # encoding : utf-8
2
+ module StoreApi
3
+ module AppStore
4
+ RANKING_TYPE_LIST = [
5
+ 'topgrossingapplications', # Top Grossing Applications
6
+ 'topgrossingipadapplications', # Top Grossing iPad Applications
7
+ 'newapplications', # New Applications
8
+ 'newfreeapplications', # New Free Applications
9
+ 'newpaidapplications', # New Paid Applications
10
+ 'topfreeapplications', # Top Free Applications
11
+ 'topfreeipadapplications', # Top Free iPad Applications
12
+ 'toppaidapplications', # Top Paid Applications
13
+ 'toppaidipadapplications' # Top Paid iPad Applications
14
+ ]
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ # encoding : utf-8
2
+ require 'json'
3
+ require 'store_api/app_store/apps/details'
4
+ require 'store_api/app_store/apps/ranking'
5
+
6
+ module StoreApi
7
+ module AppStore
8
+ HOST = 'itunes.apple.com'
9
+ HTTPS = true
10
+ end
11
+ end
@@ -30,7 +30,7 @@ module StoreApi
30
30
  @id = id
31
31
 
32
32
  content_xpath = "id('body-content')"
33
- doc.xpath("#{content_xpath}/div[@class='main-content']//div[@class='details-info']").each do |node|
33
+ doc.xpath("#{content_xpath}//div[@class='details-info']").each do |node|
34
34
  # puts node.methods
35
35
  @title = node.css('.document-title').text.strip
36
36
  @cover_image = node.css('.cover-image').attribute('src').value
@@ -74,7 +74,7 @@ module StoreApi
74
74
  @developer_address = doc.xpath("#{metadata_xpath}//div[@class='content physical-address']").text
75
75
  @developer_address = !@developer_address.nil? ? @developer_address.strip : nil
76
76
  @developer_links = []
77
- doc.xpath("#{metadata_xpath}//div[@class='content contains-text-link']/a[@class='dev-link']").each do |node|
77
+ doc.xpath("#{content_xpath}//div[@class='details-section metadata']//div[@class='content contains-text-link']/a[@class='dev-link']").each do |node|
78
78
  @developer_links.push({'text' => node.text,'link' => node.attribute('href').value})
79
79
  end
80
80
  rescue => e
@@ -1,3 +1,3 @@
1
1
  module StoreApi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/store_api.rb CHANGED
@@ -5,6 +5,7 @@ require "nokogiri"
5
5
  require "store_api/version"
6
6
  require "store_api/request"
7
7
  require "store_api/google_play"
8
+ require "store_api/app_store"
8
9
 
9
10
  module StoreApi
10
11
  # Your code goes here...
@@ -0,0 +1,51 @@
1
+ # encoding : utf-8
2
+ require 'spec_helper'
3
+
4
+ describe StoreApi::AppStore::Apps::Details do
5
+
6
+ it 'details test' do
7
+ apps = StoreApi::AppStore::Apps::Details.new('850417475','US')
8
+ p apps.id
9
+ expect(apps.id).not_to eq(nil), "Test id #{apps.id}"
10
+ p apps.title
11
+ expect(apps.title).not_to be nil
12
+ p apps.cover_image
13
+ expect(apps.cover_image).not_to be nil
14
+ p apps.price
15
+ expect(apps.price).not_to be nil
16
+ p apps.developer
17
+ expect(apps.developer).not_to be nil
18
+ p apps.developer_url
19
+ expect(apps.developer_url).not_to be nil
20
+ p apps.category
21
+ expect(apps.category).not_to be nil
22
+ p apps.category_id
23
+ expect(apps.category_id).not_to be nil
24
+ p apps.screenshot
25
+ expect(apps.screenshot.size).to be > 0
26
+ p apps.description
27
+ expect(apps.description).not_to be nil
28
+ p apps.rating_score
29
+ expect(apps.rating_score).not_to be nil
30
+ p apps.rating_value
31
+ expect(apps.rating_value).not_to be nil
32
+ p apps.rating_count
33
+ expect(apps.rating_count).not_to be nil
34
+ p apps.release_notes
35
+ expect(apps.release_notes).not_to be nil
36
+ p apps.date_published
37
+ expect(apps.date_published).not_to be nil
38
+ p apps.file_size
39
+ expect(apps.file_size).not_to be nil
40
+ p apps.software_version
41
+ expect(apps.software_version).not_to be nil
42
+ p apps.content_rating
43
+ expect(apps.content_rating).not_to be nil
44
+ p apps.supported_devices
45
+ expect(apps.supported_devices.size).to be > 0
46
+ p apps.bundle_id
47
+ expect(apps.bundle_id).not_to be nil
48
+ # p apps.raw_details
49
+ expect(apps.raw_details).not_to be nil
50
+ end
51
+ end
@@ -0,0 +1,13 @@
1
+ # encoding : utf-8
2
+ require 'spec_helper'
3
+
4
+ describe StoreApi::AppStore::Apps::Ranking do
5
+ it "itunes ios ranking test" do
6
+ ranking = StoreApi::AppStore::Apps::Ranking
7
+ .new('topgrossingapplications', '7001', 'us', 20)
8
+ puts ranking.topchart
9
+ expect(ranking.topchart).not_to be nil
10
+ expect(ranking.topchart.size).to eq(20)
11
+ expect(ranking.topchart[0][:rank]).to eq(1)
12
+ end
13
+ end
@@ -6,30 +6,55 @@ describe StoreApi::GooglePlay::Apps::Details do
6
6
  it 'details test' do
7
7
  apps = StoreApi::GooglePlay::Apps::Details.new('com.king.candycrushsodasaga','en')
8
8
  # apps = StoreApi::GooglePlay::Apps::Details.new('com.toiletgaman','en')
9
+ puts 'title : ' + apps.title
9
10
  expect(apps.title).not_to be nil
11
+ puts 'cover_image : ' + apps.cover_image
10
12
  expect(apps.cover_image).not_to be nil
13
+ puts 'price : ' + apps.price
11
14
  expect(apps.price).not_to be nil
15
+ puts 'developer : ' + apps.developer
12
16
  expect(apps.developer).not_to be nil
17
+ puts 'developer_url : ' + apps.developer_url
13
18
  expect(apps.developer_url).not_to be nil
19
+ puts 'category : ' + apps.category
14
20
  expect(apps.category).not_to be nil
21
+ puts 'category_url : ' + apps.category_url
15
22
  expect(apps.category_url).not_to be nil
23
+ puts 'category_id : ' + apps.category_id
16
24
  expect(apps.category_id).not_to be nil
25
+ puts 'badge_title : ' + apps.badge_title
17
26
  expect(apps.badge_title).not_to be nil
27
+ puts 'screenshot : ' + apps.screenshot.to_s
18
28
  expect(apps.screenshot.size).to be > 0
29
+ puts 'video_url : ' + apps.video_url
19
30
  expect(apps.video_url).not_to be nil
31
+ puts 'description : ' + apps.description
20
32
  expect(apps.description).not_to be nil
33
+ puts 'rating_score : ' + apps.rating_score
21
34
  expect(apps.rating_score).not_to be nil
35
+ puts 'rating_value : ' + apps.rating_value
22
36
  expect(apps.rating_value).not_to be nil
37
+ puts 'rating_count : ' + apps.rating_count
23
38
  expect(apps.rating_count).not_to be nil
39
+ puts 'rating_map : ' + apps.rating_map.to_s
24
40
  expect(apps.rating_map.size).to be > 0
41
+ puts 'whatsnew : ' + apps.whatsnew
25
42
  expect(apps.whatsnew).not_to be nil
43
+ puts 'date_published : ' + apps.date_published
26
44
  expect(apps.date_published).not_to be nil
45
+ puts 'file_size : ' + apps.file_size
27
46
  expect(apps.file_size).not_to be nil
47
+ puts 'downloads : ' + apps.downloads
28
48
  expect(apps.downloads).not_to be nil
49
+ puts 'software_version : ' + apps.software_version
29
50
  expect(apps.software_version).not_to be nil
51
+ puts 'operating_system : ' + apps.operating_system
30
52
  expect(apps.operating_system).not_to be nil
53
+ puts 'content_rating : ' + apps.content_rating
31
54
  expect(apps.content_rating).not_to be nil
55
+ puts 'developer_address : ' + apps.developer_address
32
56
  expect(apps.developer_address).not_to be nil
57
+ puts 'developer_links : ' + apps.developer_links.to_s
33
58
  expect(apps.developer_links.size).to be > 0
34
59
  end
35
60
  end
@@ -10,14 +10,14 @@ describe StoreApi::GooglePlay::Apps::Ranking do
10
10
  # ranking = StoreApi::GooglePlay::Apps::Ranking.new('topselling_free')
11
11
  # expect(ranking.topchart).not_to be nil
12
12
  # expect(ranking.topchart.size).to be >= 540
13
- ranking = StoreApi::GooglePlay::Apps::Ranking.new('editors_choice')
14
- expect(ranking.topchart).not_to be nil
15
- ranking = StoreApi::GooglePlay::Apps::Ranking.new('movers_shakers')
16
- expect(ranking.topchart).not_to be nil
17
- ranking = StoreApi::GooglePlay::Apps::Ranking.new('tablet_featured')
18
- expect(ranking.topchart).not_to be nil
19
- ranking = StoreApi::GooglePlay::Apps::Ranking.new('featured')
20
- expect(ranking.topchart).not_to be nil
13
+ # ranking = StoreApi::GooglePlay::Apps::Ranking.new('editors_choice')
14
+ # expect(ranking.topchart).not_to be nil
15
+ # ranking = StoreApi::GooglePlay::Apps::Ranking.new('movers_shakers')
16
+ # expect(ranking.topchart).not_to be nil
17
+ # ranking = StoreApi::GooglePlay::Apps::Ranking.new('tablet_featured')
18
+ # expect(ranking.topchart).not_to be nil
19
+ # ranking = StoreApi::GooglePlay::Apps::Ranking.new('featured')
20
+ # expect(ranking.topchart).not_to be nil
21
21
  end
22
22
 
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: store_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tatsunori_nishikori
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-19 00:00:00.000000000 Z
11
+ date: 2015-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -110,6 +110,11 @@ files:
110
110
  - README.md
111
111
  - Rakefile
112
112
  - lib/store_api.rb
113
+ - lib/store_api/app_store.rb
114
+ - lib/store_api/app_store/apps/details.rb
115
+ - lib/store_api/app_store/apps/ranking.rb
116
+ - lib/store_api/app_store/category_id.rb
117
+ - lib/store_api/app_store/ranking_type.rb
113
118
  - lib/store_api/google_play.rb
114
119
  - lib/store_api/google_play/apps/details.rb
115
120
  - lib/store_api/google_play/apps/developer.rb
@@ -121,6 +126,8 @@ files:
121
126
  - lib/store_api/request.rb
122
127
  - lib/store_api/version.rb
123
128
  - spec/spec_helper.rb
129
+ - spec/store_api/app_store/apps/details_spec.rb
130
+ - spec/store_api/app_store/apps/ranking_sepc.rb
124
131
  - spec/store_api/google_play/apps/details_spec.rb
125
132
  - spec/store_api/google_play/apps/developer_spec.rb
126
133
  - spec/store_api/google_play/apps/ranking_spec.rb
@@ -147,12 +154,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
154
  version: '0'
148
155
  requirements: []
149
156
  rubyforge_project:
150
- rubygems_version: 2.2.2
157
+ rubygems_version: 2.4.5
151
158
  signing_key:
152
159
  specification_version: 4
153
160
  summary: Smartphone app store data acquisition API.
154
161
  test_files:
155
162
  - spec/spec_helper.rb
163
+ - spec/store_api/app_store/apps/details_spec.rb
164
+ - spec/store_api/app_store/apps/ranking_sepc.rb
156
165
  - spec/store_api/google_play/apps/details_spec.rb
157
166
  - spec/store_api/google_play/apps/developer_spec.rb
158
167
  - spec/store_api/google_play/apps/ranking_spec.rb