syobocal 0.10.0 → 0.14.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.
@@ -0,0 +1,103 @@
1
+ module Syobocal
2
+ module Comment
3
+ class Parser
4
+ ELEMENT_CLASSES = [
5
+ Element::Header2,
6
+ Element::Header1,
7
+ Element::List,
8
+ Element::Row,
9
+ Element::Blank,
10
+ Element::TextNode, # NOTE Sentinel
11
+ ]
12
+
13
+ def initialize(comment)
14
+ @comment = comment
15
+ end
16
+
17
+ def parse
18
+ return @parse if defined? @parse
19
+
20
+ return @parse = Element::Root.new([]) unless @comment
21
+
22
+ elements = @comment.each_line.map do |line|
23
+ line.chomp!
24
+ ELEMENT_CLASSES.find { |clazz| clazz.match?(line) }.parse(line)
25
+ end
26
+
27
+ @parse = Element::Root.new(elements)
28
+ end
29
+
30
+ def staffs
31
+ return @staffs if defined? @staffs
32
+
33
+ rows = sections.find { |section| section.staff_section? }&.rows || []
34
+
35
+ @staffs = create_staff_list(rows)
36
+ end
37
+
38
+ def casts
39
+ return @casts if defined? @casts
40
+
41
+ rows = sections.find { |section| section.cast_section? }&.rows || []
42
+
43
+ @casts = create_cast_list(rows)
44
+ end
45
+
46
+ def musics
47
+ return @musics if defined? @musics
48
+
49
+ @musics = create_musics(all_sections)
50
+ end
51
+
52
+ def links
53
+ return @links if defined? @links
54
+
55
+ @links = sections.find { |section| section.link_section? }&.links || []
56
+ end
57
+
58
+ def sections
59
+ return @sections if defined? @sections
60
+
61
+ @sections = Section.create_sections(parse.elements)
62
+ end
63
+
64
+ def all_sections
65
+ return enum_for(:all_sections) unless block_given?
66
+
67
+ sections.each do |section|
68
+ yield section
69
+
70
+ section.sub_sections.each do |sub_section|
71
+ yield sub_section
72
+ end
73
+ end
74
+ end
75
+
76
+ private
77
+
78
+ def create_staff_list(rows)
79
+ rows.map do |row|
80
+ role = row.attr_node.inner_text
81
+ people = row.value_node.split.map { |str| Person.parse(str) }
82
+
83
+ Staff.new(role, people)
84
+ end
85
+ end
86
+
87
+ def create_cast_list(rows)
88
+ rows.map do |row|
89
+ character = row.attr_node.inner_text
90
+ people = row.value_node.split.map { |str| Person.parse(str) }
91
+
92
+ Cast.new(character, people)
93
+ end
94
+ end
95
+
96
+ def create_musics(sections)
97
+ sections.each_with_object([]) do |section, musics|
98
+ musics << section.to_music if section.music_section?
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,33 @@
1
+ module Syobocal
2
+ module Comment
3
+ class Person
4
+ PERSON_SEPARATOR = "、"
5
+ ENCODED_SEPARATOR = "\t"
6
+
7
+ attr_reader :name, :note
8
+
9
+ def initialize(name, note)
10
+ @name, @note = name, note
11
+ end
12
+
13
+ def ==(other)
14
+ other.instance_of?(self.class) && other.name == name && other.note == note
15
+ end
16
+
17
+ def self.parse(str)
18
+ _, name, note = *(str.match(/\A([^\(\)]+?)(?:\((.*?)\))?\Z/).to_a)
19
+
20
+ Person.new(name, note)
21
+ end
22
+
23
+ def self.multi_parse(str)
24
+ Helper::Fragment.parse(str).to_a.map{|f|
25
+ name = f.text
26
+ note = f&.child&.to_s
27
+
28
+ Person.new(name, note)
29
+ }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,136 @@
1
+ module Syobocal
2
+ module Comment
3
+ class Section
4
+ attr_reader :header, :elements, :sub_sections
5
+
6
+ class RestrictedOperation < StandardError; end
7
+
8
+ def initialize(header, elements)
9
+ @header, @elements = header, elements
10
+ @sub_sections = []
11
+ end
12
+
13
+ def sub_section?
14
+ @header.instance_of? Element::Header2
15
+ end
16
+
17
+ def add_subsection(sub_section)
18
+ raise RestrictedOperation if sub_section?
19
+ raise RestrictedOperation unless sub_section.sub_section?
20
+
21
+ @sub_sections << sub_section
22
+ end
23
+
24
+ STAFF_WORD = "スタッフ"
25
+ CAST_WORD = "キャスト"
26
+ LINK_WORD = "リンク"
27
+ MUSIC_WORDS = %w(テーマ ソング 歌 曲)
28
+ MUSIC_TITLE_REGEXP = /\A(.*)「(.+?)」\Z/
29
+
30
+ def staff_section?
31
+ header.text_node.inner_text.include?(STAFF_WORD)
32
+ end
33
+
34
+ def cast_section?
35
+ header.text_node.inner_text.include?(CAST_WORD)
36
+ end
37
+
38
+ def link_section?
39
+ header.text_node.inner_text.include?(LINK_WORD)
40
+ end
41
+
42
+ def music_section?
43
+ str = header.text_node.inner_text
44
+
45
+ MUSIC_WORDS.any? { |keyword| str.include?(keyword) } && str.match(MUSIC_TITLE_REGEXP)
46
+ end
47
+
48
+ def to_music
49
+ m = header.text_node.inner_text.match(MUSIC_TITLE_REGEXP)
50
+ title = m[2]
51
+ category = m[1]
52
+
53
+ data_list = rows.map do |row|
54
+ attr = row.attr_node.inner_text
55
+
56
+ attr_fragment = Helper::Fragment.parse(attr)
57
+
58
+ if attr_fragment.to_a.size == 1
59
+ attr_text = attr_fragment.text
60
+ attr_note = attr_fragment&.child&.to_s
61
+ else
62
+ attr_text = attr_fragment.to_s
63
+ attr_note = nil
64
+ end
65
+
66
+ value = row.value_node.inner_text
67
+ people = Person.multi_parse(value)
68
+
69
+ MusicData.new(attr, attr_text, attr_note, value, people)
70
+ end
71
+
72
+ Music.new(title, category, data_list)
73
+ end
74
+
75
+ def rows
76
+ elements.select { |element| element.is_a? Element::Row }
77
+ end
78
+
79
+ def links
80
+ elements.each_with_object([]) { |element, links|
81
+ case element
82
+ when Element::List
83
+ links << element.text_node.text_elements.select { |elm| elm.instance_of? Element::Link }
84
+ when Element::TextNode
85
+ links << element.text_elements.select { |elm| elm.instance_of? Element::Link }
86
+ end
87
+ }.flatten
88
+ end
89
+
90
+ def self.create_sections(elements)
91
+ sections = []
92
+ current_header = nil
93
+ buffered_elements = []
94
+
95
+ elements.each do |element|
96
+ case element
97
+ when Element::Header1, Element::Header2
98
+ if current_header
99
+ sections << Section.new(current_header, buffered_elements)
100
+ buffered_elements = []
101
+ end
102
+
103
+ current_header = element
104
+ else
105
+ buffered_elements << element if current_header
106
+ end
107
+ end
108
+
109
+ if current_header
110
+ sections << Section.new(current_header, buffered_elements)
111
+ end
112
+
113
+ structure_sections(sections)
114
+ end
115
+
116
+ def self.structure_sections(sections)
117
+ root_sections = []
118
+ parent_section = nil
119
+
120
+ sections.each do |section|
121
+ if section.sub_section?
122
+ # NOTE parent_sectionがないパターンは不正なので無視する
123
+ parent_section.add_subsection(section) if parent_section
124
+ else
125
+ root_sections << section
126
+ parent_section = section
127
+ end
128
+ end
129
+
130
+ root_sections
131
+ end
132
+
133
+ private_class_method :structure_sections
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,15 @@
1
+ module Syobocal
2
+ module Comment
3
+ class Staff
4
+ attr_reader :role, :people
5
+
6
+ def initialize(role, people)
7
+ @role, @people = role, people
8
+ end
9
+
10
+ def ==(other)
11
+ other.instance_of?(self.class) && other.role == role && other.people == people
12
+ end
13
+ end
14
+ end
15
+ end
data/lib/syobocal/db.rb CHANGED
@@ -3,14 +3,14 @@ module Syobocal
3
3
  module Mapper
4
4
  def map(elm)
5
5
  result = {}
6
- elm.each_element{|child|
7
- set(result, to_snake(child.name).to_sym, child, @map[child.name])
6
+ elm.each_element { |child|
7
+ set(result, to_snake(child.name).to_sym, child, @map[child.name])
8
8
  }
9
9
  result
10
10
  end
11
11
 
12
12
  def to_snake(name)
13
- name.gsub(/([a-z])([A-Z])/){ $1 + '_' + $2 }.downcase
13
+ name.gsub(/([a-z])([A-Z])/) { $1 + "_" + $2 }.downcase
14
14
  end
15
15
 
16
16
  def set(hash, key, elm, type)
@@ -36,11 +36,11 @@ module Syobocal
36
36
 
37
37
  module TitleLookup
38
38
  def get(params = {})
39
- parse(open(url(params)))
39
+ parse(URI.open(url(params)))
40
40
  end
41
41
 
42
42
  def url(params)
43
- 'http://cal.syoboi.jp/db.php?Command=TitleLookup' + Syobocal::Util.format_params_amp(params)
43
+ "http://cal.syoboi.jp/db.php?Command=TitleLookup" + Syobocal::Util.format_params_amp(params)
44
44
  end
45
45
 
46
46
  def parse(xml)
@@ -48,10 +48,10 @@ module Syobocal
48
48
 
49
49
  result = LookupResult.new
50
50
 
51
- result.code = xml.elements['TitleLookupResponse/Result/Code'].text.to_i
52
- result.message = xml.elements['TitleLookupResponse/Result/Message'].text
51
+ result.code = xml.elements["TitleLookupResponse/Result/Code"].text.to_i
52
+ result.message = xml.elements["TitleLookupResponse/Result/Message"].text
53
53
 
54
- xml.elements.each('TitleLookupResponse/TitleItems/TitleItem'){|item|
54
+ xml.elements.each("TitleLookupResponse/TitleItems/TitleItem") { |item|
55
55
  mapper = Mapper.new
56
56
  result << mapper.map(item)
57
57
  }
@@ -91,11 +91,11 @@ module Syobocal
91
91
 
92
92
  module ProgLookup
93
93
  def get(params = {})
94
- parse(open(url(params)))
94
+ parse(URI.open(url(params)))
95
95
  end
96
96
 
97
97
  def url(params)
98
- 'http://cal.syoboi.jp/db.php?Command=ProgLookup' + Syobocal::Util.format_params_amp(params)
98
+ "http://cal.syoboi.jp/db.php?Command=ProgLookup" + Syobocal::Util.format_params_amp(params)
99
99
  end
100
100
 
101
101
  def parse(xml)
@@ -103,10 +103,10 @@ module Syobocal
103
103
 
104
104
  result = LookupResult.new
105
105
 
106
- result.code = xml.elements['ProgLookupResponse/Result/Code'].text.to_i
107
- result.message = xml.elements['ProgLookupResponse/Result/Message'].text
106
+ result.code = xml.elements["ProgLookupResponse/Result/Code"].text.to_i
107
+ result.message = xml.elements["ProgLookupResponse/Result/Message"].text
108
108
 
109
- xml.elements.each('ProgLookupResponse/ProgItems/ProgItem'){|item|
109
+ xml.elements.each("ProgLookupResponse/ProgItems/ProgItem") { |item|
110
110
  mapper = Mapper.new
111
111
  result << mapper.map(item)
112
112
  }
@@ -143,11 +143,11 @@ module Syobocal
143
143
 
144
144
  module ChLookup
145
145
  def get(params = {})
146
- parse(open(url(params)))
146
+ parse(URI.open(url(params)))
147
147
  end
148
148
 
149
149
  def url(params)
150
- 'http://cal.syoboi.jp/db.php?Command=ChLookup' + Syobocal::Util.format_params_amp(params)
150
+ "http://cal.syoboi.jp/db.php?Command=ChLookup" + Syobocal::Util.format_params_amp(params)
151
151
  end
152
152
 
153
153
  def parse(xml)
@@ -155,10 +155,10 @@ module Syobocal
155
155
 
156
156
  result = LookupResult.new
157
157
 
158
- result.code = xml.elements['ChLookupResponse/Result/Code'].text.to_i
159
- result.message = xml.elements['ChLookupResponse/Result/Message'].text
158
+ result.code = xml.elements["ChLookupResponse/Result/Code"].text.to_i
159
+ result.message = xml.elements["ChLookupResponse/Result/Message"].text
160
160
 
161
- xml.elements.each('ChLookupResponse/ChItems/ChItem'){|item|
161
+ xml.elements.each("ChLookupResponse/ChItems/ChItem") { |item|
162
162
  mapper = Mapper.new
163
163
  result << mapper.map(item)
164
164
  }
@@ -189,11 +189,11 @@ module Syobocal
189
189
 
190
190
  module ChGroupLookup
191
191
  def get(params = {})
192
- parse(open(url(params)))
192
+ parse(URI.open(url(params)))
193
193
  end
194
194
 
195
195
  def url(params)
196
- 'http://cal.syoboi.jp/db.php?Command=ChGroupLookup' + Syobocal::Util.format_params_amp(params)
196
+ "http://cal.syoboi.jp/db.php?Command=ChGroupLookup" + Syobocal::Util.format_params_amp(params)
197
197
  end
198
198
 
199
199
  def parse(xml)
@@ -201,10 +201,10 @@ module Syobocal
201
201
 
202
202
  result = LookupResult.new
203
203
 
204
- result.code = xml.elements['ChGroupLookupResponse/Result/Code'].text.to_i
205
- result.message = xml.elements['ChGroupLookupResponse/Result/Message'].text
204
+ result.code = xml.elements["ChGroupLookupResponse/Result/Code"].text.to_i
205
+ result.message = xml.elements["ChGroupLookupResponse/Result/Message"].text
206
206
 
207
- xml.elements.each('ChGroupLookupResponse/ChGroupItems/ChGroupItem'){|item|
207
+ xml.elements.each("ChGroupLookupResponse/ChGroupItems/ChGroupItem") { |item|
208
208
  mapper = Mapper.new
209
209
  result << mapper.map(item)
210
210
  }
@@ -231,11 +231,11 @@ module Syobocal
231
231
 
232
232
  module TitleViewCount
233
233
  def get(params = {})
234
- parse(open(url(params)))
234
+ parse(URI.open(url(params)))
235
235
  end
236
236
 
237
237
  def url(params)
238
- 'http://cal.syoboi.jp/db.php?Command=TitleViewCount' + Syobocal::Util.format_params_amp(params)
238
+ "http://cal.syoboi.jp/db.php?Command=TitleViewCount" + Syobocal::Util.format_params_amp(params)
239
239
  end
240
240
 
241
241
  def parse(xml)
@@ -247,11 +247,11 @@ module Syobocal
247
247
 
248
248
  module TitleRankHistory
249
249
  def get(params = {})
250
- parse(open(url(params)))
250
+ parse(URI.open(url(params)))
251
251
  end
252
252
 
253
253
  def url(params)
254
- 'http://cal.syoboi.jp/db.php?Command=TitleRankHistory' + Syobocal::Util.format_params_amp(params)
254
+ "http://cal.syoboi.jp/db.php?Command=TitleRankHistory" + Syobocal::Util.format_params_amp(params)
255
255
  end
256
256
 
257
257
  def parse(xml)
@@ -263,11 +263,11 @@ module Syobocal
263
263
 
264
264
  module TitlePointHistory
265
265
  def get(params = {})
266
- parse(open(url(params)))
266
+ parse(URI.open(url(params)))
267
267
  end
268
268
 
269
269
  def url(params)
270
- 'http://cal.syoboi.jp/db.php?Command=TitlePointHistory' + Syobocal::Util.format_params_amp(params)
270
+ "http://cal.syoboi.jp/db.php?Command=TitlePointHistory" + Syobocal::Util.format_params_amp(params)
271
271
  end
272
272
 
273
273
  def parse(xml)
@@ -279,11 +279,11 @@ module Syobocal
279
279
 
280
280
  module TitlePointTop
281
281
  def get(params = {})
282
- parse(open(url(params)))
282
+ parse(URI.open(url(params)))
283
283
  end
284
284
 
285
285
  def url(params)
286
- 'http://cal.syoboi.jp/db.php?Command=TitlePointTop' + Syobocal::Util.format_params_amp(params)
286
+ "http://cal.syoboi.jp/db.php?Command=TitlePointTop" + Syobocal::Util.format_params_amp(params)
287
287
  end
288
288
 
289
289
  def parse(xml)
@@ -298,21 +298,21 @@ module Syobocal
298
298
 
299
299
  result = TableResult.new
300
300
 
301
- result.code = xml.elements['TableData/Result/Code'].text.to_i
302
- result.message = xml.elements['TableData/Result/Message'].text
301
+ result.code = xml.elements["TableData/Result/Code"].text.to_i
302
+ result.message = xml.elements["TableData/Result/Message"].text
303
303
 
304
304
  result.columns = []
305
305
  if result.code == 200
306
- result.title = xml.elements['TableData/Title'].text
307
- result.type = xml.elements['TableData/Type'].text
306
+ result.title = xml.elements["TableData/Title"].text
307
+ result.type = xml.elements["TableData/Type"].text
308
308
 
309
- xml.elements.each('TableData/Columns/Value'){|item|
309
+ xml.elements.each("TableData/Columns/Value") { |item|
310
310
  result.columns << item.text
311
311
  }
312
312
 
313
- xml.elements.each('TableData/Line'){|line|
313
+ xml.elements.each("TableData/Line") { |line|
314
314
  line_data = {}
315
- line.elements.each_with_index{|value, index|
315
+ line.elements.each_with_index { |value, index|
316
316
  key = result.columns[index]
317
317
  if key == "Date"
318
318
  line_data[key] = Date.parse(value.text)
data/lib/syobocal/json.rb CHANGED
@@ -2,11 +2,11 @@ module Syobocal
2
2
  module JSON
3
3
  module TitleMedium
4
4
  def get(params = {})
5
- parse(open(url(params)))
5
+ parse(URI.open(url(params)))
6
6
  end
7
7
 
8
8
  def url(params = {})
9
- 'http://cal.syoboi.jp/json.php?Req=TitleMedium' + Syobocal::Util.format_params_amp(params)
9
+ "http://cal.syoboi.jp/json.php?Req=TitleMedium" + Syobocal::Util.format_params_amp(params)
10
10
  end
11
11
 
12
12
  def parse(json)
@@ -18,11 +18,11 @@ module Syobocal
18
18
 
19
19
  module TitleLarge
20
20
  def get(params = {})
21
- parse(open(url(params)))
21
+ parse(URI.open(url(params)))
22
22
  end
23
23
 
24
24
  def url(params = {})
25
- 'http://cal.syoboi.jp/json.php?Req=TitleLarge' + Syobocal::Util.format_params_amp(params)
25
+ "http://cal.syoboi.jp/json.php?Req=TitleLarge" + Syobocal::Util.format_params_amp(params)
26
26
  end
27
27
 
28
28
  def parse(json)
@@ -34,11 +34,11 @@ module Syobocal
34
34
 
35
35
  module TitleFull
36
36
  def get(params = {})
37
- parse(open(url(params)))
37
+ parse(URI.open(url(params)))
38
38
  end
39
39
 
40
40
  def url(params = {})
41
- 'http://cal.syoboi.jp/json.php?Req=TitleFull' + Syobocal::Util.format_params_amp(params)
41
+ "http://cal.syoboi.jp/json.php?Req=TitleFull" + Syobocal::Util.format_params_amp(params)
42
42
  end
43
43
 
44
44
  def parse(json)
@@ -50,11 +50,11 @@ module Syobocal
50
50
 
51
51
  module ProgramByPID
52
52
  def get(params = {})
53
- parse(open(url(params)))
53
+ parse(URI.open(url(params)))
54
54
  end
55
55
 
56
56
  def url(params = {})
57
- 'http://cal.syoboi.jp/json.php?Req=ProgramByPID' + Syobocal::Util.format_params_amp(params)
57
+ "http://cal.syoboi.jp/json.php?Req=ProgramByPID" + Syobocal::Util.format_params_amp(params)
58
58
  end
59
59
 
60
60
  def parse(json)
@@ -66,11 +66,11 @@ module Syobocal
66
66
 
67
67
  module ProgramByCount
68
68
  def get(params = {})
69
- parse(open(url(params)))
69
+ parse(URI.open(url(params)))
70
70
  end
71
71
 
72
72
  def url(params = {})
73
- 'http://cal.syoboi.jp/json.php?Req=ProgramByCount' + Syobocal::Util.format_params_amp(params)
73
+ "http://cal.syoboi.jp/json.php?Req=ProgramByCount" + Syobocal::Util.format_params_amp(params)
74
74
  end
75
75
 
76
76
  def parse(json)
@@ -82,11 +82,11 @@ module Syobocal
82
82
 
83
83
  module ProgramByDate
84
84
  def get(params = {})
85
- parse(open(url(params)))
85
+ parse(URI.open(url(params)))
86
86
  end
87
87
 
88
88
  def url(params = {})
89
- 'http://cal.syoboi.jp/json.php?Req=ProgramByDate' + Syobocal::Util.format_params_amp(params)
89
+ "http://cal.syoboi.jp/json.php?Req=ProgramByDate" + Syobocal::Util.format_params_amp(params)
90
90
  end
91
91
 
92
92
  def parse(json)
@@ -98,11 +98,11 @@ module Syobocal
98
98
 
99
99
  module SubTitles
100
100
  def get(params = {})
101
- parse(open(url(params)))
101
+ parse(URI.open(url(params)))
102
102
  end
103
103
 
104
104
  def url(params = {})
105
- 'http://cal.syoboi.jp/json.php?Req=SubTitles' + Syobocal::Util.format_params_amp(params)
105
+ "http://cal.syoboi.jp/json.php?Req=SubTitles" + Syobocal::Util.format_params_amp(params)
106
106
  end
107
107
 
108
108
  def parse(json)
@@ -114,11 +114,11 @@ module Syobocal
114
114
 
115
115
  module ChFilter
116
116
  def get(params = {})
117
- parse(open(url(params)))
117
+ parse(URI.open(url(params)))
118
118
  end
119
119
 
120
120
  def url(params = {})
121
- 'http://cal.syoboi.jp/json.php?Req=ChFilter' + Syobocal::Util.format_params_amp(params)
121
+ "http://cal.syoboi.jp/json.php?Req=ChFilter" + Syobocal::Util.format_params_amp(params)
122
122
  end
123
123
 
124
124
  def parse(json)
@@ -130,11 +130,11 @@ module Syobocal
130
130
 
131
131
  module ChIDFilter
132
132
  def get(params = {})
133
- parse(open(url(params)))
133
+ parse(URI.open(url(params)))
134
134
  end
135
135
 
136
136
  def url(params = {})
137
- 'http://cal.syoboi.jp/json.php?Req=ChIDFilter' + Syobocal::Util.format_params_amp(params)
137
+ "http://cal.syoboi.jp/json.php?Req=ChIDFilter" + Syobocal::Util.format_params_amp(params)
138
138
  end
139
139
 
140
140
  def parse(json)
data/lib/syobocal/rss.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  module Syobocal
2
2
  module RSS
3
3
  def get(params = {})
4
- parse(open(url(params)))
4
+ parse(URI.open(url(params)))
5
5
  end
6
6
 
7
7
  def url(params = {})
8
- 'http://cal.syoboi.jp/rss.php' + Syobocal::Util.format_params(params)
8
+ "http://cal.syoboi.jp/rss.php" + Syobocal::Util.format_params(params)
9
9
  end
10
10
 
11
11
  def parse(rss)
@@ -13,25 +13,25 @@ module Syobocal
13
13
 
14
14
  result = Result.new
15
15
 
16
- channel = rss.elements['rdf:RDF/channel']
17
- result.title = channel.elements['title'].text
18
- result.link = channel.elements['link'].text
19
- result.description = channel.elements['description'].text
20
-
21
- rss.elements.each('rdf:RDF/item'){|item|
22
- tv = item.elements['tv:feed']
16
+ channel = rss.elements["rdf:RDF/channel"]
17
+ result.title = channel.elements["title"].text
18
+ result.link = channel.elements["link"].text
19
+ result.description = channel.elements["description"].text
20
+
21
+ rss.elements.each("rdf:RDF/item") { |item|
22
+ tv = item.elements["tv:feed"]
23
23
  result << {
24
24
  :about => item.attribute("rdf:about").to_s,
25
- :title => item.elements['title'].text,
26
- :link => item.elements['link'].text,
27
- :description => item.elements['description'].text,
28
- :dc_date => Time.parse(item.elements['dc:date'].text),
29
- :dc_publisher => item.elements['dc:publisher'].text,
30
- :tv_genre => tv.elements['tv:genre'].text,
31
- :tv_start_datetime => Time.parse(tv.elements['tv:startDatetime'].text),
32
- :tv_end_datetime => Time.parse(tv.elements['tv:endDatetime'].text),
33
- :tv_iepg_url => tv.elements['tv:iepgUrl'].text,
34
- :tv_performer => tv.elements['tv:performer'].text,
25
+ :title => item.elements["title"].text,
26
+ :link => item.elements["link"].text,
27
+ :description => item.elements["description"].text,
28
+ :dc_date => Time.parse(item.elements["dc:date"].text),
29
+ :dc_publisher => item.elements["dc:publisher"].text,
30
+ :tv_genre => tv.elements["tv:genre"].text,
31
+ :tv_start_datetime => Time.parse(tv.elements["tv:startDatetime"].text),
32
+ :tv_end_datetime => Time.parse(tv.elements["tv:endDatetime"].text),
33
+ :tv_iepg_url => tv.elements["tv:iepgUrl"].text,
34
+ :tv_performer => tv.elements["tv:performer"].text,
35
35
  }
36
36
  }
37
37