fetchapp 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/fetchapp +3 -0
- data/lib/ConditionFetch.rb +44 -0
- data/lib/FetchItunes.rb +66 -0
- data/lib/HTTPItunesGetRequest.rb +34 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 70ef6a8f692f7fe6690c18919683a8bd34a30871
|
4
|
+
data.tar.gz: 84ac7190e5ddacb65f4578573a462ebbcb8de989
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 454ea5cd4e43eb4cdef7934503c5a574719f0f27c58cffc37ee19d9b1297ff4660f5a6cbfd58c1286be04637fa73627bdf41729304e259bf17cbc19482beecc1
|
7
|
+
data.tar.gz: fbbb62290ebd6dfc9935e83fa33b3055cfec6e654b109df162a7130cc4ac6d2c9e071bd73a8c49d001113b5cf5a0212936603c0e759bea2d2470f8d01cfcc0b6
|
data/bin/fetchapp
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
class ConditionFetch
|
2
|
+
|
3
|
+
def self.fetch_ios_apple(json_body,type_value)
|
4
|
+
#fetch content key
|
5
|
+
track_name_key="trackName"
|
6
|
+
track_id_key="trackId"
|
7
|
+
niminum_os_version_key="minimumOsVersion"
|
8
|
+
track_url_key="trackViewUrl"
|
9
|
+
bundle_id_key="bundleId"
|
10
|
+
version_key="version"
|
11
|
+
|
12
|
+
final_apps=Array.new
|
13
|
+
results_array=json_body["results"]
|
14
|
+
results_array.each do |result|
|
15
|
+
support_array=result["supportedDevices"]
|
16
|
+
if support_array
|
17
|
+
support_content= support_array.join
|
18
|
+
if support_content.upcase.start_with? type_value.upcase
|
19
|
+
track_name=result[track_name_key]
|
20
|
+
track_id =result[track_id_key]
|
21
|
+
track_nimi_os=result[niminum_os_version_key]
|
22
|
+
track_url=result[track_url_key]
|
23
|
+
track_bundle_id=result[bundle_id_key]
|
24
|
+
track_version=result[version_key]
|
25
|
+
|
26
|
+
app=Hash.new
|
27
|
+
app[track_name_key]=track_name
|
28
|
+
app[track_id_key]=track_id
|
29
|
+
app[niminum_os_version_key]=track_nimi_os
|
30
|
+
app[track_url_key]=track_url
|
31
|
+
app[bundle_id_key]=track_bundle_id
|
32
|
+
app[version_key]=track_version
|
33
|
+
|
34
|
+
final_apps << app
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
return final_apps
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
data/lib/FetchItunes.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
module FetchItunes
|
2
|
+
autoload :ConditionFetch, 'ConditionFetch'
|
3
|
+
autoload :HTTPItunesGetRequest, 'HTTPItunesGetRequest'
|
4
|
+
|
5
|
+
def self.fetch
|
6
|
+
if ARGV.length==0 || ARGV == nil
|
7
|
+
puts "error: Parameter does not match,there is not any parameter"
|
8
|
+
return nil
|
9
|
+
end
|
10
|
+
arg_flags=ARGV
|
11
|
+
flags=Array.new
|
12
|
+
|
13
|
+
type_key="-t"
|
14
|
+
type_value=nil
|
15
|
+
|
16
|
+
all_info_key="-a"
|
17
|
+
isAll=false
|
18
|
+
|
19
|
+
arg_flags.each do |flag|
|
20
|
+
if flag == type_key
|
21
|
+
flag_content_index=arg_flags.index(flag) +1
|
22
|
+
raise "args count not match !" if arg_flags.count <= flag_content_index
|
23
|
+
type_value=arg_flags[flag_content_index];
|
24
|
+
elsif flag == all_info_key
|
25
|
+
isAll=true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
#fetch content key
|
30
|
+
track_name_key="trackName"
|
31
|
+
track_id_key="trackId"
|
32
|
+
niminum_os_version_key="minimumOsVersion"
|
33
|
+
track_url_key="trackViewUrl"
|
34
|
+
bundle_id_key="bundleId"
|
35
|
+
version_key="version"
|
36
|
+
|
37
|
+
request = HTTPItunesGetRequest.new
|
38
|
+
request.item_id="284417353"
|
39
|
+
request.country="cn"
|
40
|
+
request.entity="software"
|
41
|
+
json_body= request.getItemInfos
|
42
|
+
|
43
|
+
fetch_items= ConditionFetch.fetch_ios_apple(json_body,type_value)
|
44
|
+
fetch_items.each do |item|
|
45
|
+
name=item[track_name_key]
|
46
|
+
track_id=item[track_id_key]
|
47
|
+
niminum_version=item[niminum_os_version_key]
|
48
|
+
track_url=item[track_url_key]
|
49
|
+
bundle_id=item[bundle_id_key]
|
50
|
+
version=item[version_key]
|
51
|
+
|
52
|
+
space=" : "
|
53
|
+
|
54
|
+
if isAll
|
55
|
+
puts "--------#{name}----------"
|
56
|
+
puts track_id_key + space + track_id.to_s
|
57
|
+
puts niminum_os_version_key + space + niminum_os_version_key
|
58
|
+
puts track_url_key + space + track_url_key
|
59
|
+
puts bundle_id_key + space + bundle_id_key.to_s
|
60
|
+
puts version_key + space + version_key
|
61
|
+
elsif
|
62
|
+
puts "------#{name}------#{bundle_id}---------"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#Checkout all apple's app. Name and identifier
|
2
|
+
|
3
|
+
require "net/http"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
class HTTPItunesGetRequest
|
7
|
+
|
8
|
+
attr_reader :base_url
|
9
|
+
attr_accessor :item_id
|
10
|
+
attr_accessor :country
|
11
|
+
attr_accessor :entity
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@base_url="https://itunes.apple.com/lookup?"
|
15
|
+
end
|
16
|
+
|
17
|
+
def getItemInfos
|
18
|
+
begin
|
19
|
+
raise "Item_id is empty" if @item_id.empty?
|
20
|
+
full_url=@base_url + "id=#{@item_id}" + "&country=#{@country}" + "&entity=#{@entity}" + "&limit=200";
|
21
|
+
uri=URI(full_url);
|
22
|
+
puts "start request ....."
|
23
|
+
res=Net::HTTP.get_response(uri)
|
24
|
+
response_body=res.body
|
25
|
+
json_body = JSON.parse response_body;
|
26
|
+
puts "request OK !" if res.code == "200"
|
27
|
+
return json_body
|
28
|
+
rescue Exception => e
|
29
|
+
puts e
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fetchapp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- chengkai
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: fetch apple app
|
14
|
+
email: chengkai@1853.com
|
15
|
+
executables:
|
16
|
+
- fetchapp
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/ConditionFetch.rb
|
21
|
+
- lib/FetchItunes.rb
|
22
|
+
- lib/HTTPItunesGetRequest.rb
|
23
|
+
- bin/fetchapp
|
24
|
+
homepage: http://rubygems.org/gems/fetchapp
|
25
|
+
licenses: []
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.0.14
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: fetch app
|
47
|
+
test_files: []
|