spfy 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +5 -3
- data/lib/spfy/optionreader.rb +9 -2
- data/lib/spfy.rb +41 -13
- data/spfy.gemspec +3 -2
- metadata +3 -2
data/README.md
CHANGED
@@ -21,7 +21,7 @@ With the prerequisites above taken care of Spfy can be installed with the follow
|
|
21
21
|
gem install spfy
|
22
22
|
|
23
23
|
##Using Spfy
|
24
|
-
By default, Spfy will output a formatted XSPF playlist to the standard output stream that will include _location_, _title_,
|
24
|
+
By default, Spfy will output a formatted XSPF playlist to the standard output stream that will include _location_, _title_, _creator_, _album_, and _trackNum_ elements for each audio file where available.
|
25
25
|
|
26
26
|
The general syntax for Spfy is `spfy [options] dir1 ... dirN`, where _dir1 ... dirN_ is one or more paths to directories containing audio files.
|
27
27
|
|
@@ -39,11 +39,12 @@ For example:
|
|
39
39
|
<title>A Stitch In Time</title>
|
40
40
|
<creator>The Smashing Pumpkins</creator>
|
41
41
|
<album>Teargarden by Kaleidyscope</album>
|
42
|
+
<trackNum>3</trackNum>
|
42
43
|
</track>
|
43
44
|
</trackList>
|
44
45
|
</playlist>
|
45
46
|
|
46
|
-
Spfy supports multiple directory paths (e.g. `spfy /dir1 /dir2`) and traverses each directory recursively by default. Unsupported files and empty directories in a directory tree are silently ignored and will not impact
|
47
|
+
Spfy supports multiple directory paths (e.g. `spfy /dir1 /dir2`) and traverses each directory recursively by default. Unsupported files and empty directories in a directory tree are silently ignored and will not impact Spfy's output.
|
47
48
|
|
48
49
|
Command-line arguments allow you to control which elements Spfy outputs:
|
49
50
|
|
@@ -51,11 +52,12 @@ Command-line arguments allow you to control which elements Spfy outputs:
|
|
51
52
|
-t, --no-title Suppress track title in output
|
52
53
|
-a, --no-artist Suppress artist name in output
|
53
54
|
-l, --no-album Suppress album name in output
|
55
|
+
-n, --no-tracknum Suppress track number in output
|
54
56
|
|
55
57
|
For additional options use `spfy --help`.
|
56
58
|
|
57
59
|
##License
|
58
|
-
|
60
|
+
Spfy is free software, and you are welcome to redistribute it under certain conditions. See the [GNU General Public License](http://www.gnu.org/licenses/gpl.html) for more details.
|
59
61
|
|
60
62
|
##Acknowledgments
|
61
63
|
Spfy uses the following third party software components:
|
data/lib/spfy/optionreader.rb
CHANGED
@@ -31,6 +31,8 @@ class OptionReader
|
|
31
31
|
options.hide_album = false
|
32
32
|
options.hide_location = false
|
33
33
|
options.hide_tracknum = false
|
34
|
+
options.dirs = []
|
35
|
+
options.tracks_to_process = []
|
34
36
|
|
35
37
|
opts = OptionParser.new do |opts|
|
36
38
|
opts.banner = "Usage: #{File.basename($0)} [options] dir1 ... dirN"
|
@@ -67,11 +69,16 @@ class OptionReader
|
|
67
69
|
options.hide_tracknum = true
|
68
70
|
end
|
69
71
|
|
72
|
+
opts.on("-m", "--max-tracks NUM", "Limit the output to NUM tracks") do |num|
|
73
|
+
options.tracks_to_process << num
|
74
|
+
options.track_limit = true
|
75
|
+
end
|
76
|
+
|
70
77
|
opts.separator ""
|
71
78
|
opts.separator "Misc options:"
|
72
79
|
|
73
80
|
opts.on("-v", "--version", "Display version information") do
|
74
|
-
puts "#{File.basename($0).capitalize} #{$
|
81
|
+
puts "#{File.basename($0).capitalize} #{$spfy_version} Copyright (c) 2012 Marc Ransome <marc.ransome@fidgetbox.co.uk>"
|
75
82
|
puts "This program comes with ABSOLUTELY NO WARRANTY, use it at your own risk."
|
76
83
|
puts "This is free software, and you are welcome to redistribute it under"
|
77
84
|
puts "certain conditions; type `#{File.basename($0)} --license' for details."
|
@@ -92,7 +99,7 @@ class OptionReader
|
|
92
99
|
|
93
100
|
# add path to global dirs variable
|
94
101
|
if File.directory?(dir)
|
95
|
-
|
102
|
+
options.dirs << dir
|
96
103
|
end
|
97
104
|
|
98
105
|
end
|
data/lib/spfy.rb
CHANGED
@@ -26,8 +26,7 @@ require "taglib"
|
|
26
26
|
require 'find'
|
27
27
|
require 'uri'
|
28
28
|
|
29
|
-
$
|
30
|
-
$dirs = []
|
29
|
+
$spfy_version = "0.2.0"
|
31
30
|
|
32
31
|
# The main Spfy class
|
33
32
|
class Spfy
|
@@ -52,8 +51,11 @@ class Spfy
|
|
52
51
|
# parse command-line arguments
|
53
52
|
options = OptionReader.parse(ARGV)
|
54
53
|
|
54
|
+
# dirs for traversing
|
55
|
+
dirs = options.dirs
|
56
|
+
|
55
57
|
# test for zero source paths
|
56
|
-
if
|
58
|
+
if dirs.empty?
|
57
59
|
puts "No source path specified."
|
58
60
|
puts simple_usage
|
59
61
|
exit
|
@@ -89,8 +91,11 @@ class Spfy
|
|
89
91
|
xmlFile.write("<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n")
|
90
92
|
xmlFile.write("\t<trackList>\n")
|
91
93
|
|
94
|
+
# track count for track limit option
|
95
|
+
tracks_processed = 0
|
96
|
+
|
92
97
|
# repeat for each source dir argument
|
93
|
-
|
98
|
+
dirs.each do |dir|
|
94
99
|
|
95
100
|
begin
|
96
101
|
|
@@ -124,14 +129,25 @@ class Spfy
|
|
124
129
|
end
|
125
130
|
|
126
131
|
xmlFile.write("\t\t</track>\n")
|
132
|
+
|
133
|
+
# increment our track processed count
|
134
|
+
tracks_processed += 1
|
135
|
+
|
136
|
+
# if a maximum number track numbe has been set, test whether we have reached the limit
|
137
|
+
if options.tracks_to_process[0].to_i > 0 and tracks_processed == options.tracks_to_process[0].to_i
|
138
|
+
# write XSPF footer
|
139
|
+
xmlFile.write("\t</trackList>\n")
|
140
|
+
xmlFile.write("</playlist>\n")
|
141
|
+
xmlFile.close
|
142
|
+
print " success\n"
|
143
|
+
exit
|
144
|
+
end
|
127
145
|
end
|
128
146
|
end
|
129
|
-
rescue
|
147
|
+
rescue Interrupt
|
130
148
|
abort("\nCancelled, exiting..")
|
131
|
-
rescue Exception => e
|
132
|
-
next
|
133
149
|
end # begin
|
134
|
-
end #
|
150
|
+
end # dirs.each do |dir|
|
135
151
|
|
136
152
|
# write XSPF footer
|
137
153
|
xmlFile.write("\t</trackList>\n")
|
@@ -149,8 +165,11 @@ class Spfy
|
|
149
165
|
puts "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n"
|
150
166
|
puts "\t<trackList>\n"
|
151
167
|
|
168
|
+
# track count for track limit option
|
169
|
+
tracks_processed = 0
|
170
|
+
|
152
171
|
# repeat for each source dir argument
|
153
|
-
|
172
|
+
dirs.each do |dir|
|
154
173
|
|
155
174
|
begin
|
156
175
|
|
@@ -183,14 +202,23 @@ class Spfy
|
|
183
202
|
end
|
184
203
|
|
185
204
|
puts "\t\t</track>\n"
|
205
|
+
|
206
|
+
# increment our track processed count
|
207
|
+
tracks_processed += 1
|
208
|
+
|
209
|
+
# if a maximum number track numbe has been set, test whether we have reached the limit
|
210
|
+
if options.tracks_to_process[0].to_i > 0 and tracks_processed == options.tracks_to_process[0].to_i
|
211
|
+
# output XSPF footer
|
212
|
+
puts "\t</trackList>\n"
|
213
|
+
puts "</playlist>\n"
|
214
|
+
exit
|
215
|
+
end
|
186
216
|
end
|
187
217
|
end
|
188
|
-
rescue
|
218
|
+
rescue Interrupt
|
189
219
|
abort("\nCancelled, exiting..")
|
190
|
-
rescue Exception => e
|
191
|
-
next
|
192
220
|
end # begin
|
193
|
-
end #
|
221
|
+
end # dirs.each do |dir|
|
194
222
|
|
195
223
|
# write XSPF footer
|
196
224
|
puts "\t</trackList>\n"
|
data/spfy.gemspec
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
|
22
22
|
Gem::Specification.new do |s|
|
23
23
|
s.name = 'spfy'
|
24
|
-
s.version = '0.
|
24
|
+
s.version = '0.2.0'
|
25
25
|
s.date = '2012-05-06'
|
26
26
|
s.summary = 'XSPF playlist generator'
|
27
27
|
s.description = 'Spfy is a simple command-line tool for generating XSPF playlists from metadata stored in several popular audio formats.'
|
@@ -31,4 +31,5 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.executables << 'spfy'
|
32
32
|
s.add_runtime_dependency 'taglib-ruby', '>= 0.5.0'
|
33
33
|
s.homepage = 'http://marcransome.github.com/spfy'
|
34
|
-
|
34
|
+
s.license = 'GPL-3'
|
35
|
+
end
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -42,7 +42,8 @@ files:
|
|
42
42
|
- license.txt
|
43
43
|
- spfy.gemspec
|
44
44
|
homepage: http://marcransome.github.com/spfy
|
45
|
-
licenses:
|
45
|
+
licenses:
|
46
|
+
- GPL-3
|
46
47
|
post_install_message:
|
47
48
|
rdoc_options: []
|
48
49
|
require_paths:
|