itunes 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/lib/itunes.rb +66 -0
  3. data/lib/itunes/version.rb +3 -0
  4. metadata +82 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Garrett Bjerkhoel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/lib/itunes.rb ADDED
@@ -0,0 +1,66 @@
1
+ require 'httparty'
2
+
3
+ class ITunes
4
+ include HTTParty
5
+
6
+ base_uri 'ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/ws'
7
+ format :json
8
+
9
+ def method_missing(name, *args)
10
+ methods = %q{movie podcast music music_video audiobook short_film tv_show all}
11
+
12
+ if methods.include?(name.to_s)
13
+ camelcase = name.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
14
+ camelcase[0] = camelcase[0].chr.downcase
15
+
16
+ request(args.first, camelcase)
17
+ else
18
+ super(name, *args)
19
+ end
20
+ end
21
+
22
+ # So you don't have to create an instance if you don't need to
23
+ def self.music(terms)
24
+ self.new.music(terms)
25
+ end
26
+
27
+ def self.podcast(terms)
28
+ self.new.podcast(terms)
29
+ end
30
+
31
+ def self.movie(terms)
32
+ self.new.movie(terms)
33
+ end
34
+
35
+ def self.music_video(terms)
36
+ self.new.music_video(terms)
37
+ end
38
+
39
+ def self.audiobook(terms)
40
+ self.new.audiobook(terms)
41
+ end
42
+
43
+ def self.short_film(terms)
44
+ self.new.short_film(terms)
45
+ end
46
+
47
+ def self.tv_show(terms)
48
+ self.new.tv_show(terms)
49
+ end
50
+
51
+ def self.all(terms)
52
+ self.new.all(terms)
53
+ end
54
+
55
+ private
56
+ def request(term, media='all')
57
+ raise ArgumentError, 'you need to search for something, provide a term.' if term.nil?
58
+
59
+ self.class.get('Search', {
60
+ :query => {
61
+ :term => term,
62
+ :media => media
63
+ }
64
+ })
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ class ITunes
2
+ VERSION = '0.2.0'.freeze
3
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itunes
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
+ platform: ruby
12
+ authors:
13
+ - Garrett Bjerkhoel
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-02 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: httparty
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: iTunes API
36
+ email: me@garrettbjerkhoel.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - MIT-LICENSE
43
+ files:
44
+ - MIT-LICENSE
45
+ - lib/itunes.rb
46
+ - lib/itunes/version.rb
47
+ has_rdoc: true
48
+ homepage: http://github.com/dewski/itunes
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --charset=UTF-8
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ requirements: []
75
+
76
+ rubyforge_project:
77
+ rubygems_version: 1.3.7
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: iTunes
81
+ test_files: []
82
+