spfy 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/spfy.rb +20 -24
  2. data/spfy.gemspec +1 -1
  3. metadata +2 -2
@@ -23,8 +23,9 @@ require "spfy/optionreader"
23
23
  require "optparse"
24
24
  require "ostruct"
25
25
  require "taglib"
26
+ require 'find'
26
27
 
27
- $version = "0.1.2"
28
+ $version = "0.1.3"
28
29
  $dirs = []
29
30
 
30
31
  # The main Spfy class
@@ -80,16 +81,14 @@ class Spfy
80
81
  xmlFile.write("<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n")
81
82
  xmlFile.write("\t<trackList>\n")
82
83
 
83
- # repeat for each source path specified
84
- $dirs.each do |path|
84
+ # repeat for each source dir argument
85
+ $dirs.each do |dir|
86
+
87
+ # repeat for each file recursively
88
+ Find.find(dir) do |path|
85
89
 
86
- # repeat for each file
87
- Dir.foreach(path).sort.each do |file|
88
- next if file == '.' or file == '..' or
89
- next if file.start_with? '.'
90
-
91
90
  begin
92
- TagLib::FileRef.open(path + "/" + file) do |fileref|
91
+ TagLib::FileRef.open(path) do |fileref|
93
92
 
94
93
  tag = fileref.tag
95
94
 
@@ -122,29 +121,26 @@ class Spfy
122
121
  puts "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n"
123
122
  puts "\t<trackList>\n"
124
123
 
125
- # repeat for each source path
126
- $dirs.each do |path|
124
+ # repeat for each source dir argument
125
+ $dirs.each do |dir|
127
126
 
128
- # repeat for each file
129
- Dir.foreach(path).sort.each do |file|
130
- next if file == '.' or file == '..' or
131
- next if file.start_with? '.'
132
-
127
+ # repeat for each file recursively
128
+ Find.find(dir) do |path|
129
+
133
130
  begin
134
- TagLib::FileRef.open(path + "/" + file) do |fileref|
131
+ TagLib::FileRef.open(path) do |fileref|
135
132
 
136
133
  tag = fileref.tag
137
134
 
138
135
  # skip files with no tags
139
136
  next if tag.title.empty? and tag.artist.empty? and tag.album.empty?
140
137
 
141
- # write track metadata
138
+ # output track metadata
142
139
  puts "\t\t<track>\n"
143
- puts "\t\t\t<title>#{tag.title}</title>\n"
144
- puts "\t\t\t<creator>#{tag.artist}</creator>\n"
145
- puts "\t\t\t<album>#{tag.album}</album>\n"
140
+ puts "\t\t\t<title>#{tag.title}</title>\n" if !options.hide_title and !tag.title.empty?
141
+ puts "\t\t\t<creator>#{tag.artist}</creator>\n" if !options.hide_artist and !tag.artist.empty?
142
+ puts "\t\t\t<album>#{tag.album}</album>\n" if !options.hide_album and !tag.album.empty?
146
143
  puts "\t\t</track>\n"
147
-
148
144
  end
149
145
  rescue Exception => e
150
146
  next
@@ -152,6 +148,7 @@ class Spfy
152
148
  end
153
149
  end
154
150
 
151
+ # write XSPF footer
155
152
  puts "\t</trackList>\n"
156
153
  puts "</playlist>\n"
157
154
  end
@@ -163,6 +160,5 @@ class Spfy
163
160
  end
164
161
 
165
162
  end # def self.generate
166
-
167
- end # class Spyf
168
163
 
164
+ end # class Spyf
@@ -21,7 +21,7 @@
21
21
 
22
22
  Gem::Specification.new do |s|
23
23
  s.name = 'spfy'
24
- s.version = '0.1.2'
24
+ s.version = '0.1.3'
25
25
  s.date = '2012-05-06'
26
26
  s.summary = 'XSPF playlist generator'
27
27
  s.description = 'Spfy is a simple command-line ruby tool for generating XSPF playlists from metadata stored in several popular audio formats.'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spfy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  requirements: []
63
63
  rubyforge_project:
64
- rubygems_version: 1.8.24
64
+ rubygems_version: 1.8.23
65
65
  signing_key:
66
66
  specification_version: 3
67
67
  summary: XSPF playlist generator