30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/m2ts_parser/application/epg_parse.rb', line 30
def event_to_epg(service_id, event)
{
id: [service_id, event.event_id.to_i],
service_id: service_id,
event_id: event.event_id.to_i,
start_time: event.start_time.to_s,
duration: event.duration.to_sec,
duration_pretty: event.duration.to_s,
event_name: event.descriptors
.select{|d| d.is_a? ShortEventDescriptor}
.map{|d| d.event_name ? d.event_name.content_description : ""},
text: event.descriptors
.select{|d| d.is_a? ShortEventDescriptor}
.map{|d| d.text ? d.text.content_description : ""},
extended_text: event.descriptors
.select{|d| d.is_a? ExtendedEventDescriptor}
.map{|d| d.items.map{|i|
{
description: i.item_description_char ? i.item_description_char.content_description : "",
text: i.item_char ? i.item_char.content_description : ""
}}},
content_nibble: event.descriptors
.select{|d| d.is_a? ContentDescriptor}
.map{|d| d.contents.map{|c|
{
:level1 => {id: c.content_nibble_level_1.to_i, name: c.genre1},
:level2 => {id: c.content_nibble_level_2.to_i, name: c.genre2},
}}}
}
end
|