itunes-zach 1.0
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.
- checksums.yaml +7 -0
- data/lib/itunes.rb +46 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d2140f34d3675154d9be92cd7d1e3c112a6fb0f7
|
4
|
+
data.tar.gz: c4a0ac305269d63aabed90b7e27a1995f065c915
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3a1a87445bc3d6362f8f7b78c429f3629d5fb3b18466c2049d94c3f939ccae03f63592833c755cb2e21f80210ff2c83c91b817bedb55d28df59c9f23b84dc2bb
|
7
|
+
data.tar.gz: 065e1eb099bc91341056c885106728359676798f3c846f50c90742a7650567c811a806dbc03ba40aecdfcd5eb3805c95eef6d142ad573543840063048670db37
|
data/lib/itunes.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# require 'net/http'
|
2
|
+
# require 'json'
|
3
|
+
|
4
|
+
|
5
|
+
class APIS::Itunes
|
6
|
+
attr_accessor :song_list, :search
|
7
|
+
|
8
|
+
def initialize()
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def fetch_and_parse(param_uri)
|
13
|
+
uri = URI(param_uri)
|
14
|
+
response = Net::HTTP.get(uri) # => String
|
15
|
+
parsed = JSON.parse(response)
|
16
|
+
pull_title_and_id(parsed)
|
17
|
+
# add_songs_to_list(parsed)
|
18
|
+
end
|
19
|
+
|
20
|
+
def search_by_term(term)
|
21
|
+
fetch_and_parse("https://itunes.apple.com/search?term=#{URI.encode(term)}")
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def pull_title_and_id(parsed)
|
26
|
+
songs = parsed["results"]
|
27
|
+
ar = []
|
28
|
+
songs.each do |song|
|
29
|
+
hash = {name: song["trackName"], song_id: song["trackId"]}
|
30
|
+
ar << Song.new(hash)
|
31
|
+
end
|
32
|
+
ar
|
33
|
+
# Song.new(hash)
|
34
|
+
end
|
35
|
+
|
36
|
+
def search_by_id(param_id)
|
37
|
+
|
38
|
+
my_url="https://itunes.apple.com/lookup?id=#{param_id}"
|
39
|
+
uri = URI(my_url)
|
40
|
+
fetch(uri)
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_songs_to_list(list)
|
44
|
+
self.song_list = list
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: itunes-zach
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zach Krzyzanowski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Access Itunes API
|
14
|
+
email:
|
15
|
+
- zkrzyz@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/itunes.rb
|
21
|
+
homepage: https://github.com/zkrzyzanowski/itunes
|
22
|
+
licenses:
|
23
|
+
- GPLv2
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.0.0
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.4.5.1
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Access Itunes API
|
45
|
+
test_files: []
|