traktor-nml 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03629056548e366400192f205b2b3a4385c23dc7
4
- data.tar.gz: e35ee6cdf549e24f8c8836954222c0a69d9573b5
3
+ metadata.gz: 0a3afb8e98241015e5d186c1e309f84f5a28dbd5
4
+ data.tar.gz: 2f487b2db2e9cf1a06ce61c45035fc660b83a42a
5
5
  SHA512:
6
- metadata.gz: 7233f47a8863017a8edcf532c5a2072983c89be39d0acb3aa5dc0199103d1323161ce0fe140d32459d02fff7cc13c408592a2f97fbbded94e797f6cd61d3dd95
7
- data.tar.gz: 761cac2f45e9df14aa6dd2a5d30605d1bfebf8a3a4da587484cd62e2bee075ce66d5a87a9fde0aab6a7295816b83e7126498374b75a62266d6032a85ef8dd8a0
6
+ metadata.gz: dbbfb8e69974494ca670824c8fde3a41e04d799c7b0fd5822e0feec62be13db7defb6b9971046e228eb83fcf4c63975c9c198f0c31c3a600a2cfec167fa84628
7
+ data.tar.gz: 4f99c1e87c39c7dcb19c9d820746cf1b1dea1ffc8e66767cee8a3350459774b1f2ec9280cbe7027e5bded3e4e622bbe425ff0a468ceaafe5ca7fcdcfb9b623f5
data/README.md CHANGED
@@ -31,6 +31,40 @@ Traktor::NML.parse File.open("path/to/playlist.nml")
31
31
  Traktor::NML.parse content_of_nml
32
32
  ```
33
33
 
34
+ `Traktor::NML.parse` will return array of hash like this:
35
+
36
+ ```ruby
37
+ [{:title=>"Green Night Parade (PandaBoY Remix)",
38
+ :artist=>"fu_mou",
39
+ :album=>"Green Night Parade EP",
40
+ :primarykey=>
41
+ "G:/:Music/:fu_mou/:Green Night Parade EP/:06 Green Night Parade (PandaBoY Remi.mp3",
42
+ :genre=>"ALTEMA Records",
43
+ :label=>"",
44
+ :playtime=>371.0,
45
+ :release_date=>"2011/1/1",
46
+ :bpm=>131.999},
47
+ {:title=>"Sweet Tear(Y calla K Cut Electro Remix)",
48
+ :artist=>"Calla Soiled",
49
+ :album=>"Sweet Tear EP",
50
+ :primarykey=>
51
+ "G:/:Music/:Calla Soiled/:Sweet Tear EP/:02 Sweet Tear(Y calla K Cut Electro.mp3",
52
+ :genre=>"ALTEMA Records",
53
+ :label=>"",
54
+ :playtime=>320.0,
55
+ :release_date=>"2010/1/1",
56
+ :bpm=>132.0},
57
+ {:title=>"もしも星屑が泣いたとして",
58
+ :artist=>"Calla Soiled",
59
+ :album=>"Dirty Nucleus",
60
+ :primarykey=>"G:/:Music/:Calla Soiled/:Dirty Nucleus/:07 もしも星屑が泣いたとして.mp3",
61
+ :genre=>"",
62
+ :label=>"",
63
+ :playtime=>362.0,
64
+ :release_date=>"2010/1/1",
65
+ :bpm=>139.005}]
66
+ ```
67
+
34
68
  ## Contributing
35
69
 
36
70
  1. Fork it ( https://github.com/polamjag/traktor-nml/fork )
data/lib/traktor/nml.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "traktor/collection"
2
- require "traktor/playlist"
1
+ require "traktor/nml/collection"
2
+ require "traktor/nml/playlist"
3
3
  require "traktor/nml/version"
4
4
  require "oga"
5
5
 
@@ -0,0 +1,56 @@
1
+ require "oga"
2
+
3
+ module Traktor
4
+ module NML
5
+ class Collection
6
+ attr_reader :collection
7
+
8
+ def initialize(node)
9
+ @collection = node.map do |el|
10
+ {
11
+ title: try_text(el.attribute('TITLE')),
12
+ artist: try_text(el.attribute('ARTIST')),
13
+ album: {
14
+ title: el.xpath('ALBUM[@TITLE]').attribute('TITLE').map{ |e| e.text }.join(", "),
15
+ track: try_text(el.xpath('ALBUM[@TRACK]').attribute('TRACK').first),
16
+ },
17
+ primarykey: el.xpath('LOCATION').map { |loc|
18
+ loc.attribute('VOLUME').text + loc.attribute('DIR').text + loc.attribute('FILE').text
19
+ }.first,
20
+ genre: el.xpath('INFO[@GENRE]').attribute('GENRE').map{ |e| e.text }.join(", "),
21
+ label: el.xpath('INFO[@LABEL]').attribute('LABEL').map{ |e| e.text }.join(", "),
22
+ playtime: el.xpath('INFO[@PLAYTIME]').attribute('PLAYTIME').map{ |e| e.text.to_f }.first,
23
+ release_date: el.xpath('INFO[@RELEASE_DATE]').attribute('RELEASE_DATE').map{ |e| e.text }.join(", "),
24
+ bpm: el.xpath('TEMPO[@BPM]').attribute('BPM').map{ |e| e.text.to_f }.first,
25
+ key: try_text(el.xpath('INFO[@KEY]').attribute('KEY').first),
26
+ musical_key: try_text(el.xpath('MUSICAL_KEY[@VALUE]').attribute('VALUE').first),
27
+ cues: el.xpath('CUE_V2').map do |cue|
28
+ {
29
+ name: cue.attribute('NAME').value,
30
+ type: cue.attribute('TYPE').value.to_i,
31
+ start: cue.attribute('START').value.to_f,
32
+ length: cue.attribute('LEN').value.to_f,
33
+ repeats: cue.attribute('REPEATS').value.to_i,
34
+ hotcue: cue.attribute('HOTCUE').value.to_i
35
+ }
36
+ end
37
+ }
38
+ end
39
+ end
40
+
41
+ def track_from_primarykey(primarykey)
42
+ @collection.select do |track|
43
+ track[:primarykey] == primarykey
44
+ end.first
45
+ end
46
+
47
+ def try_text(elm)
48
+ if elm.nil?
49
+ ""
50
+ else
51
+ elm.text
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
File without changes
@@ -1,5 +1,5 @@
1
1
  module Traktor
2
2
  module NML
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -0,0 +1,68 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
2
+ <NML VERSION="18"><HEAD COMPANY="www.native-instruments.com" PROGRAM="Traktor"></HEAD>
3
+ <MUSICFOLDERS></MUSICFOLDERS>
4
+ <COLLECTION ENTRIES="3"><ENTRY MODIFIED_DATE="2014/12/28" MODIFIED_TIME="8906" AUDIO_ID="AUAkNGr//////////////u/////////////////////////////7r////////////////////////////////////////////+//////////////////////////////////////////////////////////////7///////////////////////////////////////////////////////////////////////////zf//////////////7Jv////////////////////////////////////////////+/////////////////O3e3d3t7N7e7O3/+UIRERAAAA==" TITLE="Sweet Tear(Y calla K Cut Electro Remix)" ARTIST="Calla Soiled"><LOCATION DIR="/:Music/:Calla Soiled/:Sweet Tear EP/:" FILE="02 Sweet Tear(Y calla K Cut Electro.mp3" VOLUME="G:" VOLUMEID="90556b77"></LOCATION>
5
+ <ALBUM TRACK="2" TITLE="Sweet Tear EP"></ALBUM>
6
+ <MODIFICATION_INFO AUTHOR_TYPE="user"></MODIFICATION_INFO>
7
+ <INFO BITRATE="320000" GENRE="ALTEMA Records" COMMENT="0" COVERARTID="060/2R1ISTB4HRKYXALEVRSIAIIHBX0C" KEY="12d" PLAYCOUNT="16" PLAYTIME="320" IMPORT_DATE="2015/2/18" LAST_PLAYED="2014/12/28" RELEASE_DATE="2010/1/1" FLAGS="12" FILESIZE="13085"></INFO>
8
+ <TEMPO BPM="132" BPM_QUALITY="100"></TEMPO>
9
+ <LOUDNESS PEAK_DB="-1.63274" PERCEIVED_DB="0" ANALYZED_DB="-2.71053"></LOUDNESS>
10
+ <MUSICAL_KEY VALUE="5"></MUSICAL_KEY>
11
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="26.5843" LEN="0" REPEATS="-1" HOTCUE="0"></CUE_V2>
12
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="4" START="3666.41" LEN="0" REPEATS="-1" HOTCUE="1"></CUE_V2>
13
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="18208.4" LEN="0" REPEATS="-1" HOTCUE="2"></CUE_V2>
14
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="32753.9" LEN="0" REPEATS="-1" HOTCUE="3"></CUE_V2>
15
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="47299.3" LEN="0" REPEATS="-1" HOTCUE="4"></CUE_V2>
16
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="90935.7" LEN="0" REPEATS="-1" HOTCUE="5"></CUE_V2>
17
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="120027" LEN="0" REPEATS="-1" HOTCUE="6"></CUE_V2>
18
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="149117" LEN="0" REPEATS="-1" HOTCUE="7"></CUE_V2>
19
+ </ENTRY>
20
+ <ENTRY MODIFIED_DATE="2015/1/23" MODIFIED_TIME="55714" AUDIO_ID="AXMCbe//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+///////////////////////////////////////7///////////////////////////////////////////////////////////////////////////////////////////////7e/M3+3d3szf27qrqry6q6qauTEAAA==" TITLE="Green Night Parade (PandaBoY Remix)" ARTIST="fu_mou"><LOCATION DIR="/:Music/:fu_mou/:Green Night Parade EP/:" FILE="06 Green Night Parade (PandaBoY Remi.mp3" VOLUME="G:" VOLUMEID="90556b77"></LOCATION>
21
+ <ALBUM OF_TRACKS="6" TRACK="6" TITLE="Green Night Parade EP"></ALBUM>
22
+ <MODIFICATION_INFO AUTHOR_TYPE="user"></MODIFICATION_INFO>
23
+ <INFO BITRATE="320000" GENRE="ALTEMA Records" COMMENT="000034D9 00003850 00016FA9 00010876 0000A86F 0001D265 00008000 00008000 00000FF6 000005FC" COVERARTID="045/NFGNHGAGUABIEBZ1OKNDDBQXWZSC" KEY="3d" PLAYCOUNT="18" PLAYTIME="371" IMPORT_DATE="2015/2/18" LAST_PLAYED="2015/2/13" RELEASE_DATE="2011/1/1" FLAGS="12" FILESIZE="14879"></INFO>
24
+ <TEMPO BPM="131.999" BPM_QUALITY="100"></TEMPO>
25
+ <LOUDNESS PEAK_DB="-2.23595" PERCEIVED_DB="-4.46086" ANALYZED_DB="-4.46086"></LOUDNESS>
26
+ <MUSICAL_KEY VALUE="2"></MUSICAL_KEY>
27
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="483.713" LEN="0" REPEATS="-1" HOTCUE="0"></CUE_V2>
28
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="4" START="4119.93" LEN="0" REPEATS="-1" HOTCUE="1"></CUE_V2>
29
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="33211.1" LEN="0" REPEATS="-1" HOTCUE="2"></CUE_V2>
30
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="47756.6" LEN="0" REPEATS="-1" HOTCUE="3"></CUE_V2>
31
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="76847.6" LEN="0" REPEATS="-1" HOTCUE="4"></CUE_V2>
32
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="91393.2" LEN="0" REPEATS="-1" HOTCUE="5"></CUE_V2>
33
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="120484" LEN="0" REPEATS="-1" HOTCUE="6"></CUE_V2>
34
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="149576" LEN="0" REPEATS="-1" HOTCUE="7"></CUE_V2>
35
+ </ENTRY>
36
+ <ENTRY MODIFIED_DATE="2015/2/12" MODIFIED_TIME="60554" LOCK="0" LOCK_MODIFICATION_TIME="2013-08-13T09:23:12" AUDIO_ID="AWoDREVURERVVERERERFRERFVVRERVVmd3eJiYd3eKzd3czMzN3MzM3M3NzNzMzczNze7u3t3dzd3dzd6URFVUVVVmZmVoypmIiIiImYiInczLu7q6qXZURq7u7t7e7u7u7d7u7e7u3u7e7e3v7t7d7e3t3t3d7u3d3t3t7d3d3v7d3N3N3dzd3d7tzdzc3d3d3d3WQ0RERERFREQ0VmZmVWZVZlQ0RZmZmqqququ6qq3cupiHd2ZlVUau7u7e3u3u7t3e7u3t7t7u7u3t7+7u7e3u7t7e7e7u7t7e7e3u7t7+7u7u3u7t7u7u7u7t7e7u3u7u7Zh2VlVTNDIQAAAA==" TITLE="もしも星屑が泣いたとして" ARTIST="Calla Soiled"><LOCATION DIR="/:Music/:Calla Soiled/:Dirty Nucleus/:" FILE="07 もしも星屑が泣いたとして.mp3" VOLUME="G:" VOLUMEID="90556b77"></LOCATION>
37
+ <ALBUM OF_TRACKS="7" TRACK="7" TITLE="Dirty Nucleus"></ALBUM>
38
+ <MODIFICATION_INFO AUTHOR_TYPE="user"></MODIFICATION_INFO>
39
+ <INFO BITRATE="320000" COMMENT="0" KEY="11m" PLAYCOUNT="18" PLAYTIME="362" IMPORT_DATE="2015/2/18" LAST_PLAYED="2015/2/16" RELEASE_DATE="2010/1/1" FLAGS="12" FILESIZE="14224"></INFO>
40
+ <TEMPO BPM="139.005" BPM_QUALITY="100"></TEMPO>
41
+ <LOUDNESS PEAK_DB="-0.736086" PERCEIVED_DB="-1.41696" ANALYZED_DB="-1.41696"></LOUDNESS>
42
+ <MUSICAL_KEY VALUE="19"></MUSICAL_KEY>
43
+ <CUE_V2 NAME="Beat Marker" DISPL_ORDER="0" TYPE="4" START="434.042" LEN="0" REPEATS="-1" HOTCUE="-1"></CUE_V2>
44
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="4" START="434.042" LEN="0" REPEATS="-1" HOTCUE="0"></CUE_V2>
45
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="14246.2" LEN="0" REPEATS="-1" HOTCUE="1"></CUE_V2>
46
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="28058.7" LEN="0" REPEATS="-1" HOTCUE="2"></CUE_V2>
47
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="41871.4" LEN="0" REPEATS="-1" HOTCUE="3"></CUE_V2>
48
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="55683.6" LEN="0" REPEATS="-1" HOTCUE="4"></CUE_V2>
49
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="83308.5" LEN="0" REPEATS="-1" HOTCUE="5"></CUE_V2>
50
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="97121" LEN="0" REPEATS="-1" HOTCUE="6"></CUE_V2>
51
+ <CUE_V2 NAME="n.n." DISPL_ORDER="0" TYPE="0" START="124746" LEN="0" REPEATS="-1" HOTCUE="7"></CUE_V2>
52
+ </ENTRY>
53
+ </COLLECTION>
54
+ <SETS ENTRIES="0"></SETS>
55
+ <PLAYLISTS><NODE TYPE="FOLDER" NAME="$ROOT"><SUBNODES COUNT="1"><NODE TYPE="FOLDER" NAME="Sets"><SUBNODES COUNT="1"><NODE TYPE="PLAYLIST" NAME="traktor-nml-demo"><PLAYLIST ENTRIES="3" TYPE="LIST" UUID="f6b9287215f44c248fbf9c172b862388"><ENTRY><PRIMARYKEY TYPE="TRACK" KEY="G:/:Music/:fu_mou/:Green Night Parade EP/:06 Green Night Parade (PandaBoY Remi.mp3"></PRIMARYKEY>
56
+ </ENTRY>
57
+ <ENTRY><PRIMARYKEY TYPE="TRACK" KEY="G:/:Music/:Calla Soiled/:Sweet Tear EP/:02 Sweet Tear(Y calla K Cut Electro.mp3"></PRIMARYKEY>
58
+ </ENTRY>
59
+ <ENTRY><PRIMARYKEY TYPE="TRACK" KEY="G:/:Music/:Calla Soiled/:Dirty Nucleus/:07 もしも星屑が泣いたとして.mp3"></PRIMARYKEY>
60
+ </ENTRY>
61
+ </PLAYLIST>
62
+ </NODE>
63
+ </SUBNODES>
64
+ </NODE>
65
+ </SUBNODES>
66
+ </NODE>
67
+ </PLAYLISTS>
68
+ </NML>
data/traktor-nml.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "bundler", "~> 1.7"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "pry"
26
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traktor-nml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - polamjag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-13 00:00:00.000000000 Z
11
+ date: 2015-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oga
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Parse Native Instruments Traktor's nml playlist file
70
84
  email:
71
85
  - s@polamjag.info
@@ -81,13 +95,14 @@ files:
81
95
  - README.md
82
96
  - Rakefile
83
97
  - circle.yml
84
- - lib/traktor/collection.rb
85
98
  - lib/traktor/nml.rb
99
+ - lib/traktor/nml/collection.rb
100
+ - lib/traktor/nml/playlist.rb
86
101
  - lib/traktor/nml/version.rb
87
- - lib/traktor/playlist.rb
88
102
  - spec/spec_helper.rb
89
103
  - spec/traktor/nml_spec.rb
90
104
  - spec/traktor/osx.nml
105
+ - spec/traktor/traktor-nml-demo.nml
91
106
  - spec/traktor/win.nml
92
107
  - spec/traktor/win_in_folder.nml
93
108
  - traktor-nml.gemspec
@@ -119,6 +134,7 @@ test_files:
119
134
  - spec/spec_helper.rb
120
135
  - spec/traktor/nml_spec.rb
121
136
  - spec/traktor/osx.nml
137
+ - spec/traktor/traktor-nml-demo.nml
122
138
  - spec/traktor/win.nml
123
139
  - spec/traktor/win_in_folder.nml
124
140
  has_rdoc:
@@ -1,41 +0,0 @@
1
- require "oga"
2
-
3
- module Traktor
4
- module NML
5
- class Collection
6
- attr_reader :collection
7
-
8
- def initialize(node)
9
- @collection = node.map do |el|
10
- {
11
- title: try_text(el.attribute('TITLE')),
12
- artist: try_text(el.attribute('ARTIST')),
13
- album: el.xpath('ALBUM[@TITLE]').attribute('TITLE').map{ |e| e.text }.join(", "),
14
- primarykey: el.xpath('LOCATION').map do |loc|
15
- loc.attribute('VOLUME').text + loc.attribute('DIR').text + loc.attribute('FILE').text
16
- end.first,
17
- genre: el.xpath('INFO[@GENRE]').attribute('GENRE').map{ |e| e.text }.join(", "),
18
- label: el.xpath('INFO[@LABEL]').attribute('LABEL').map{ |e| e.text }.join(", "),
19
- playtime: el.xpath('INFO[@PLAYTIME]').attribute('PLAYTIME').map{ |e| e.text.to_f }.first,
20
- release_date: el.xpath('INFO[@RELEASE_DATE]').attribute('RELEASE_DATE').map{ |e| e.text }.join(", "),
21
- bpm: el.xpath('TEMPO[@BPM]').attribute('BPM').map{ |e| e.text.to_f }.first
22
- }
23
- end
24
- end
25
-
26
- def track_from_primarykey(primarykey)
27
- @collection.select do |track|
28
- track[:primarykey] == primarykey
29
- end.first
30
- end
31
-
32
- def try_text(elm)
33
- if elm.nil?
34
- ""
35
- else
36
- elm.text
37
- end
38
- end
39
- end
40
- end
41
- end