Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial version with support for both search and lookup APIs
- Loading branch information
0 parents
commit 061d34f
Showing
13 changed files
with
1,984 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2010 Richard Livsey | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
= ITunesSearchAPI | ||
|
||
Ruby interface to the ITunes Search API | ||
|
||
http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html | ||
|
||
== Usage | ||
|
||
ITunesSearchAPI.search(:term => "The Killers", :country => "US", :media => "music") | ||
ITunesSearchAPI.lookup(:id => 284910350) | ||
|
||
See the API docs for more info on the parameters you can use to filter the search | ||
|
||
== Note on Patches/Pull Requests | ||
|
||
* Fork the project. | ||
* Make your feature addition or bug fix. | ||
* Add tests for it. This is important so I don't break it in a future version unintentionally. | ||
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself in another branch so I can ignore when I pull) | ||
* Send me a pull request. Bonus points for topic branches. | ||
|
||
== Install | ||
|
||
$ gem install itunes-search-api | ||
|
||
== Copyright | ||
|
||
See LICENSE for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
require "rubygems" | ||
require "rake/gempackagetask" | ||
require "rake/rdoctask" | ||
|
||
require "spec" | ||
require "spec/rake/spectask" | ||
Spec::Rake::SpecTask.new do |t| | ||
t.spec_opts = %w(--format specdoc --colour) | ||
t.libs = ["spec"] | ||
end | ||
|
||
|
||
task :default => ["spec"] | ||
|
||
# This builds the actual gem. For details of what all these options | ||
# mean, and other ones you can add, check the documentation here: | ||
# | ||
# http://rubygems.org/read/chapter/20 | ||
# | ||
spec = Gem::Specification.new do |s| | ||
|
||
# Change these as appropriate | ||
s.name = "itunes-search-api" | ||
s.version = "0.1.0" | ||
s.summary = "Ruby interface to the ITunes Search API" | ||
s.author = "Richard Livsey" | ||
s.email = "richard@livsey.org" | ||
s.homepage = "http://github.com/rlivsey/itunes-search-api" | ||
|
||
s.has_rdoc = true | ||
s.extra_rdoc_files = %w(README.rdoc) | ||
s.rdoc_options = %w(--main README.rdoc) | ||
|
||
# Add any extra files to include in the gem | ||
s.files = %w(LICENSE README.rdoc) + Dir.glob("{spec,lib/**/*}") | ||
s.require_paths = ["lib"] | ||
|
||
# If you want to depend on other gems, add them here, along with any | ||
# relevant versions | ||
s.add_dependency("httparty") | ||
|
||
# If your tests use any gems, include them here | ||
s.add_development_dependency("rspec") | ||
s.add_development_dependency("webmock") | ||
end | ||
|
||
# This task actually builds the gem. We also regenerate a static | ||
# .gemspec file, which is useful if something (i.e. GitHub) will | ||
# be automatically building a gem for this project. If you're not | ||
# using GitHub, edit as appropriate. | ||
# | ||
# To publish your gem online, install the 'gemcutter' gem; Read more | ||
# about that here: http://gemcutter.org/pages/gem_docs | ||
Rake::GemPackageTask.new(spec) do |pkg| | ||
pkg.gem_spec = spec | ||
end | ||
|
||
desc "Build the gemspec file #{spec.name}.gemspec" | ||
task :gemspec do | ||
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec" | ||
File.open(file, "w") {|f| f << spec.to_ruby } | ||
end | ||
|
||
task :package => :gemspec | ||
|
||
# Generate documentation | ||
Rake::RDocTask.new do |rd| | ||
rd.main = "README.rdoc" | ||
rd.rdoc_files.include("README.rdoc", "lib/**/*.rb") | ||
rd.rdoc_dir = "rdoc" | ||
end | ||
|
||
desc 'Clear out RDoc and generated packages' | ||
task :clean => [:clobber_rdoc, :clobber_package] do | ||
rm "#{spec.name}.gemspec" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- encoding: utf-8 -*- | ||
|
||
Gem::Specification.new do |s| | ||
s.name = %q{itunes-search-api} | ||
s.version = "0.1.0" | ||
|
||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | ||
s.authors = ["Richard Livsey"] | ||
s.date = %q{2010-08-20} | ||
s.email = %q{richard@livsey.org} | ||
s.extra_rdoc_files = ["README.rdoc"] | ||
s.files = ["LICENSE", "README.rdoc", "lib/itunes-search-api.rb"] | ||
s.homepage = %q{http://github.com/rlivsey/itunes-search-api} | ||
s.rdoc_options = ["--main", "README.rdoc"] | ||
s.require_paths = ["lib"] | ||
s.rubygems_version = %q{1.3.7} | ||
s.summary = %q{Ruby interface to the ITunes Search API} | ||
|
||
if s.respond_to? :specification_version then | ||
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION | ||
s.specification_version = 3 | ||
|
||
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then | ||
s.add_runtime_dependency(%q<httparty>, [">= 0"]) | ||
s.add_development_dependency(%q<rspec>, [">= 0"]) | ||
s.add_development_dependency(%q<webmock>, [">= 0"]) | ||
else | ||
s.add_dependency(%q<httparty>, [">= 0"]) | ||
s.add_dependency(%q<rspec>, [">= 0"]) | ||
s.add_dependency(%q<webmock>, [">= 0"]) | ||
end | ||
else | ||
s.add_dependency(%q<httparty>, [">= 0"]) | ||
s.add_dependency(%q<rspec>, [">= 0"]) | ||
s.add_dependency(%q<webmock>, [">= 0"]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'httparty' | ||
|
||
class ITunesSearchAPI | ||
include HTTParty | ||
base_uri 'http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa' | ||
format :json | ||
|
||
class << self | ||
def search(query={}) | ||
get("/wsSearch", :query => query)["results"] | ||
end | ||
|
||
def lookup(query={}) | ||
if results = get("/wsLookup", :query => query)["results"] | ||
results[0] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"resultCount":0, | ||
"results": | ||
[ | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"resultCount":1, | ||
"results": | ||
[ | ||
{ | ||
"amgArtistId":468749, | ||
"amgVideoArtistId":null, | ||
"artistId":909253, | ||
"artistLinkUrl":"http://itunes.apple.com/us/artist/jack-johnson/id909253?uo=4", | ||
"artistName":"Jack Johnson", | ||
"artistType":"Artist", | ||
"primaryGenreId":21, | ||
"primaryGenreName":"Rock", | ||
"wrapperType":"artist" | ||
} | ||
] | ||
} |
Oops, something went wrong.