playlist 0.1.1 → 0.1.2

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: ab6e547a9828f6e2039b5341e7f5dd44b82ffb88
4
- data.tar.gz: c702f580f913a2907dcb14a81721f05e3a657f2d
3
+ metadata.gz: 70f73534ba89b3e792e0ab18761584ba04ba6d3b
4
+ data.tar.gz: 192a4fbe4b8e9995b426608824207bd339c3bf54
5
5
  SHA512:
6
- metadata.gz: 0eb2e0c87173ed061c0ae69ed9d9dead42d72fcb0f2bffa037aafa35ea18d44d58d1ae1dd2d37a8a051a5802cf27b0d161f64d22b0aa424a3ed0b1069711f982
7
- data.tar.gz: 3097b9ebc71bbae24aa26701558617fd7cf429f45427e03fbd3da90ac0d3cccd262e54a5bdf95e0d4ee04eadab9a474b31285a54ce1735505097b673b8c922c1
6
+ metadata.gz: 027c61567a8142920be50a97bc2cb5112971474a47a0f5fd2c9abe1c6655557f7205e2cbc67ef86fe71e8330ae6f5699ee737852e72bed7446a3d8120f33fbd3
7
+ data.tar.gz: 6b298e207b4b7345bfa6de7a26b6caf53a559be7e7dc39ee9545a06fa00c76eb28dd505f1ecf9c1228066b87f8810f737fc91984006b5c5fb7e3f3a7c15403b8
data/README.md CHANGED
@@ -9,6 +9,7 @@ It supports parsing and generating playlists in the following formats:
9
9
  * M3U
10
10
  * XSPF
11
11
  * A simple human readable format
12
+ * SciSys dira XML
12
13
 
13
14
  ## Installation
14
15
 
@@ -1,5 +1,6 @@
1
1
  # Base module for the various playlist formats
2
2
  module Playlist::Format
3
+ autoload :Dira, 'playlist/format/dira'
3
4
  autoload :M3U, 'playlist/format/m3u'
4
5
  autoload :SimpleText, 'playlist/format/simple_text'
5
6
  autoload :XSPF, 'playlist/format/xspf'
@@ -0,0 +1,57 @@
1
+ require 'nokogiri'
2
+
3
+ unless Nokogiri::XML::Node.respond_to?(:content_at)
4
+ require 'playlist/ext/content_at.rb'
5
+ end
6
+
7
+ # Module to parse Scisys dira XML genealogy files
8
+ module Playlist::Format::Dira
9
+ class << self
10
+ # Parse a Dira XML document into a new Playlist object
11
+ # @param input [String, IO] the source of the Dira XML
12
+ # @return [Playlist] a new Playlist object
13
+ def parse(input)
14
+ Playlist.new do |playlist|
15
+ doc = Nokogiri::XML(input)
16
+ playlist.title = doc.content_at(
17
+ '//TAKE/GENERIC/GENE_MULTIMEDIA_TITLE'
18
+ ) || doc.content_at(
19
+ '//TAKE/GENERIC/GENE_TITLE'
20
+ )
21
+ doc.xpath('//TAKE/GENEALOGY/GENEALOGY_ITEM').each do |item|
22
+ playlist.tracks << parse_genealogy_item(item)
23
+ end
24
+ end
25
+ end
26
+
27
+ protected
28
+
29
+ # Parse a single Genealogy Item from a Dira XML document
30
+ def parse_genealogy_item(doc)
31
+ Playlist::Track.new do |track|
32
+ track.title = doc.content_at('./CLIP/CLIP_INFO/GENE_TITLE')
33
+ track.album = doc.content_at('./CLIP/CLIP_INFO/GENE_ALBUM')
34
+ track.track_number = doc.content_at('./CLIP/CLIP_INFO/GENE_TRACK')
35
+ track.side = doc.content_at('./CLIP/CLIP_INFO/GENE_SIDE')
36
+ track.record_label = doc.content_at('./CLIP/CLIP_INFO/GENE_LABEL')
37
+ track.publisher = doc.content_at('./CLIP/CLIP_INFO/GENE_PUBLISHER')
38
+ if (duration = doc.content_at('./GENY_CLIP_LENGTH'))
39
+ track.duration = duration.to_f / 1000
40
+ end
41
+ doc.xpath('./CLIP/CLIP_PERSONS/PERSON').each do |person|
42
+ track.contributors << parse_person(person)
43
+ end
44
+ end
45
+ end
46
+
47
+ # Parse a single Person from a dira XML document
48
+ def parse_person(doc)
49
+ Playlist::Contributor.new do |c|
50
+ c.name = doc.content_at('PERSON_NAME')
51
+ if doc.content_at('PMAP_FUNC') =~ /^PERSON_FUNC\$(.+)\#(.*)$/
52
+ c.role = Regexp.last_match(1).downcase.to_sym
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,4 +1,4 @@
1
1
  class Playlist
2
2
  # The version number of the Playlist Ruby gem
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playlist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Humfrey
@@ -140,6 +140,7 @@ files:
140
140
  - lib/playlist/contributor.rb
141
141
  - lib/playlist/ext/content_at.rb
142
142
  - lib/playlist/format.rb
143
+ - lib/playlist/format/dira.rb
143
144
  - lib/playlist/format/m3u.rb
144
145
  - lib/playlist/format/simple_text.rb
145
146
  - lib/playlist/format/xspf.rb