itunes-search-rb 0.3.2 → 0.3.4
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.
- data/VERSION +1 -1
- data/itunes-search.gemspec +2 -1
- data/lib/itunes-search.rb +1 -0
- data/lib/itunes-search/base.rb +4 -1
- data/lib/itunes-search/lookup.rb +34 -0
- data/lib/itunes-search/search.rb +1 -1
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
data/itunes-search.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{itunes-search-rb}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Caleb Adam Haye"]
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"itunes-search.gemspec",
|
26
26
|
"lib/itunes-search.rb",
|
27
27
|
"lib/itunes-search/base.rb",
|
28
|
+
"lib/itunes-search/lookup.rb",
|
28
29
|
"lib/itunes-search/result.rb",
|
29
30
|
"lib/itunes-search/search.rb",
|
30
31
|
"test/helper.rb",
|
data/lib/itunes-search.rb
CHANGED
@@ -7,4 +7,5 @@ require "cgi"
|
|
7
7
|
directory = File.expand_path(File.dirname(__FILE__))
|
8
8
|
require File.join(directory,"itunes-search", "base")
|
9
9
|
require File.join(directory,"itunes-search","search")
|
10
|
+
require File.join(directory,"itunes-search","lookup")
|
10
11
|
require File.join(directory,"itunes-search","result")
|
data/lib/itunes-search/base.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module ItunesSearch
|
2
2
|
|
3
|
-
ENDPOINT = "http://itunes.apple.com
|
3
|
+
ENDPOINT = "http://itunes.apple.com" #"http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/wsSearch"
|
4
4
|
|
5
5
|
class Base
|
6
6
|
attr_accessor :search_type
|
@@ -22,5 +22,8 @@ module ItunesSearch
|
|
22
22
|
def search(search_type, query, media="all", entity="allTrack", limit=50)
|
23
23
|
return ItunesSearch::Search.new(search_type, CGI::escape(query), media, entity, limit)
|
24
24
|
end
|
25
|
+
def lookup(search_type, id, media="all", entity="song", limit=50)
|
26
|
+
return ItunesSearch::Lookup.new(search_type, CGI::escape(id), media, entity, limit)
|
27
|
+
end
|
25
28
|
end
|
26
29
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module ItunesSearch
|
2
|
+
|
3
|
+
class Lookup
|
4
|
+
attr_accessor :id, :media, :entity, :limit, :result_hash, :json, :search_type
|
5
|
+
alias :original_method_missing :method_missing
|
6
|
+
|
7
|
+
def initialize(search_type, id, media, entity, limit)
|
8
|
+
self.search_type = search_type
|
9
|
+
self.id = id
|
10
|
+
self.media = media
|
11
|
+
self.entity = entity
|
12
|
+
self.limit = limit
|
13
|
+
end
|
14
|
+
def fetch
|
15
|
+
itunes_search_url = "#{ItunesSearch::ENDPOINT}/lookup/?#{self.search_type}=#{self.id}&media=#{media}&entity=#{entity}&limit=#{limit}"
|
16
|
+
puts "itunes_search_url: #{itunes_search_url}"
|
17
|
+
self.json = RestClient.get(itunes_search_url)
|
18
|
+
puts self.json
|
19
|
+
self.json
|
20
|
+
end
|
21
|
+
def results
|
22
|
+
ra = []
|
23
|
+
ra = self.to_hash["results"].collect {|r| ItunesSearch::Result.new(r)} unless self.to_hash["results"].empty?
|
24
|
+
puts "result"
|
25
|
+
puts ra.inspect
|
26
|
+
return ra
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_hash
|
30
|
+
self.result_hash ||= JSON.parse(fetch)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/itunes-search/search.rb
CHANGED
@@ -12,7 +12,7 @@ module ItunesSearch
|
|
12
12
|
self.limit = limit
|
13
13
|
end
|
14
14
|
def fetch
|
15
|
-
itunes_search_url = "#{ItunesSearch::ENDPOINT}/?#{self.search_type}=#{self.query}&media=#{media}&entity=#{entity}&limit=#{limit}"
|
15
|
+
itunes_search_url = "#{ItunesSearch::ENDPOINT}/search/?#{self.search_type}=#{self.query}&media=#{media}&entity=#{entity}&limit=#{limit}"
|
16
16
|
puts "itunes_search_url: #{itunes_search_url}"
|
17
17
|
self.json = RestClient.get(itunes_search_url)
|
18
18
|
puts self.json
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itunes-search-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 4
|
10
|
+
version: 0.3.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Caleb Adam Haye
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- itunes-search.gemspec
|
51
51
|
- lib/itunes-search.rb
|
52
52
|
- lib/itunes-search/base.rb
|
53
|
+
- lib/itunes-search/lookup.rb
|
53
54
|
- lib/itunes-search/result.rb
|
54
55
|
- lib/itunes-search/search.rb
|
55
56
|
- test/helper.rb
|