eyeq_metadata 1.0.0 → 1.2.2
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 +4 -4
- data/README.md +22 -0
- data/lib/eyeq_metadata.rb +52 -3
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 180de951519cc968bdd1082755e959ac76ced6c4
|
4
|
+
data.tar.gz: a8e1ea5bd9008400be28b9c3710353f3e8c3d1ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a37ec859d3e6e54bdb215c1c983670f1bb76ad1cdec38f7f23986fe86bf3a7c83c06c53bcdefc8f5d448e040d14fe530dd5053194acfb805915e3d5839129f5
|
7
|
+
data.tar.gz: 86a8b1ba431d91125488c88b8df86be11b1a769ac2f55d63f8f88b7f32a48287bae279da909aeeba1c2594fc06560bfebde24e1dbb53b39bf810a2325a73b3ad
|
data/README.md
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
#eyeq_metadata
|
2
|
+
|
3
|
+
##Installation
|
4
|
+
```
|
5
|
+
gem install eyeq_metadata
|
6
|
+
```
|
7
|
+
|
8
|
+
##Usage
|
9
|
+
```ruby
|
10
|
+
require 'eyeq_metadata'
|
11
|
+
|
12
|
+
eyeq = EyeQ.new(clientid, clientid_tag)
|
13
|
+
response.request("query_type: 'tvchannel_fetch', gnid: '123-456-789")
|
14
|
+
#returns a Nokogiri::XML object that contains the response from eyeq
|
15
|
+
```
|
16
|
+
|
17
|
+
##Navigating Nokogiri::XML objects
|
18
|
+
[Nokogiri Docs](http://www.nokogiri.org/tutorials/searching_a_xml_html_document.html)
|
19
|
+
```ruby
|
20
|
+
response.css('RESPONSES')
|
21
|
+
#returns RESPONSES from Nokogiri::XML
|
22
|
+
```
|
data/lib/eyeq_metadata.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require 'rest-client'
|
2
1
|
require 'nokogiri'
|
2
|
+
require 'httpi'
|
3
3
|
|
4
4
|
class EyeQ
|
5
5
|
attr_reader :eyeq_url, :eyeq_userid, :eyeq_clientid
|
@@ -7,9 +7,11 @@ class EyeQ
|
|
7
7
|
def initialize(clientid, clientid_tag)
|
8
8
|
@eyeq_url = "https://c#{clientid}.ipg.web.cddbp.net/webapi/xml/1.0/"
|
9
9
|
@eyeq_clientid = "#{clientid}-#{clientid_tag}"
|
10
|
+
HTTPI.log = false
|
10
11
|
|
11
12
|
register_query = "<QUERIES><QUERY CMD='REGISTER'><CLIENT>#{@eyeq_clientid}</CLIENT></QUERY></QUERIES>"
|
12
|
-
response =
|
13
|
+
response = HTTPI.post(construct_request(register_query))
|
14
|
+
|
13
15
|
response_xml = Nokogiri::XML(response.body)
|
14
16
|
|
15
17
|
raise 'Invalid clientid or clientid_tag. Query returned an ERROR.' if response_xml.css('RESPONSE').attr('STATUS').text == 'ERROR'
|
@@ -18,12 +20,18 @@ class EyeQ
|
|
18
20
|
|
19
21
|
def request(options)
|
20
22
|
query = construct_query(options)
|
21
|
-
response =
|
23
|
+
response = HTTPI.post(construct_request(query))
|
22
24
|
Nokogiri::XML(response.body)
|
23
25
|
end
|
24
26
|
|
25
27
|
private
|
26
28
|
|
29
|
+
def construct_request(query)
|
30
|
+
request = HTTPI::Request.new(url: @eyeq_url, body: query)
|
31
|
+
request.headers['Content-Type'] = 'text/xml'
|
32
|
+
request
|
33
|
+
end
|
34
|
+
|
27
35
|
def construct_query(options)
|
28
36
|
query = '<QUERIES>'
|
29
37
|
query += options[:lang].nil? ? lang : lang(options[:lang])
|
@@ -50,8 +58,16 @@ class EyeQ
|
|
50
58
|
when 'tvprogram_fetch'
|
51
59
|
throw new Error(':gnid option required') if options[:gnid].nil?
|
52
60
|
query_type = tvprogram_fetch(options[:gnid])
|
61
|
+
when 'tvgrid_search'
|
62
|
+
throw new Error(':program_title option required') if options[:program_title].nil?
|
63
|
+
throw new Error(':tvchannel_gnid option required') if options[:tvchannel_gnid].nil?
|
64
|
+
query_type = tvgrid_search(options)
|
65
|
+
when 'tvgrid_lookup'
|
66
|
+
throw new Error(':tvchannel_gnid option required') if options[:tvchannel_gnid].nil?
|
67
|
+
query_type = tvgrid_lookup(options)
|
53
68
|
end
|
54
69
|
|
70
|
+
puts query_type
|
55
71
|
query_type
|
56
72
|
end
|
57
73
|
|
@@ -86,4 +102,37 @@ class EyeQ
|
|
86
102
|
def tvprogram_fetch(gnid)
|
87
103
|
"<QUERY CMD='TVPROGRAM_FETCH'><GN_ID>#{gnid}</GN_ID></QUERY>"
|
88
104
|
end
|
105
|
+
|
106
|
+
def tvgrid_search(options)
|
107
|
+
program_title = options[:program_title]
|
108
|
+
tvchannel_gnid = options[:tvchannel_gnid]
|
109
|
+
|
110
|
+
query = "<QUERY CMD='TVGRID_SEARCH'><TEXT TYPE='TVPROGRAM_TITLE'>#{program_title}</TEXT><TVCHANNEL>"
|
111
|
+
return query << "<GN_ID>#{tvchannel_gnid}</GN_ID></TVCHANNEL>#{insert_date_time(options)}</QUERY>" unless tvchannel_gnid.is_a? Array
|
112
|
+
|
113
|
+
tvchannel_gnid.each do |gnid|
|
114
|
+
query << "<GN_ID>#{gnid}</GN_ID>"
|
115
|
+
end
|
116
|
+
query << "</TVCHANNEL>#{insert_date_time(options)}</QUERY>"
|
117
|
+
end
|
118
|
+
|
119
|
+
def tvgrid_lookup(options)
|
120
|
+
tvchannel_gnid = options[:tvchannel_gnid]
|
121
|
+
|
122
|
+
query = "<QUERY CMD='TVGRID_LOOKUP'><TVCHANNEL>"
|
123
|
+
return query << "<GN_ID>#{tvchannel_gnid}</GN_ID></TVCHANNEL>#{insert_date_time(options)}</QUERY>" unless tvchannel_gnid.is_a? Array
|
124
|
+
|
125
|
+
tvchannel_gnid.each do |gnid|
|
126
|
+
query << "<GN_ID>#{gnid}</GN_ID>"
|
127
|
+
end
|
128
|
+
query << "</TVCHANNEL>#{insert_date_time(options)}</QUERY>"
|
129
|
+
end
|
130
|
+
|
131
|
+
def insert_date_time(options)
|
132
|
+
date_start = options[:date_start] unless options[:date_start].nil?
|
133
|
+
date_end = options[:date_end] unless options[:date_end].nil?
|
134
|
+
|
135
|
+
date = "<DATE TYPE='START'>#{date_start}</DATE>" unless options[:date_start].nil?
|
136
|
+
date << "<DATE TYPE='END'>#{date_end}</DATE>" unless options[:date_end].nil?
|
137
|
+
end
|
89
138
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eyeq_metadata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaiah Soung
|
@@ -11,59 +11,59 @@ cert_chain: []
|
|
11
11
|
date: 2016-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: httpi
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.4.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.4.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.41.1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.41.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 3.5.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.5.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: webmock
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 2.1.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 2.1.0
|
69
69
|
description: Request Gracenote EyeQ metadata using the eyeq api
|
@@ -86,7 +86,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '0'
|
90
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
92
|
- - ">="
|