13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/traktor/nml/collection.rb', line 13
def initialize(node)
@collection = node.map do |el|
Traktor::NML::Track.new({
title: try_text(el.attribute('TITLE')),
artist: try_text(el.attribute('ARTIST')),
album: {
title: el.xpath('ALBUM[@TITLE]').attribute('TITLE').map{ |e| e.text }.join(", "),
track: try_text(el.xpath('ALBUM[@TRACK]').attribute('TRACK').first),
},
primarykey: el.xpath('LOCATION').map { |loc|
loc.attribute('VOLUME').text + loc.attribute('DIR').text + loc.attribute('FILE').text
}.first,
genre: el.xpath('INFO[@GENRE]').attribute('GENRE').map{ |e| e.text }.join(", "),
label: el.xpath('INFO[@LABEL]').attribute('LABEL').map{ |e| e.text }.join(", "),
playtime: el.xpath('INFO[@PLAYTIME]').attribute('PLAYTIME').map{ |e| e.text.to_f }.first,
release_date: parse_date(el.xpath('INFO[@RELEASE_DATE]').attribute('RELEASE_DATE').map{ |e| e.text }.join(", ")),
bpm: el.xpath('TEMPO[@BPM]').attribute('BPM').map{ |e| e.text.to_f }.first,
key: try_text(el.xpath('INFO[@KEY]').attribute('KEY').first),
musical_key: try_text(el.xpath('MUSICAL_KEY[@VALUE]').attribute('VALUE').first),
cues: el.xpath('CUE_V2').map do |cue|
Traktor::NML::Cue.new({
name: cue.attribute('NAME').value,
type: cue.attribute('TYPE').value.to_i,
start: cue.attribute('START').value.to_f,
length: cue.attribute('LEN').value.to_f,
repeats: cue.attribute('REPEATS').value.to_i,
hotcue: cue.attribute('HOTCUE').value.to_i
})
end
})
end
end
|