spfy 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,24 +3,27 @@
3
3
  ##Overview
4
4
  **Spfy** is a command-line tool for generating [XSPF](http://xspf.org/) playlists from metadata stored in several popular audio formats, and is developed entirely in [Ruby](http://www.ruby-lang.org/). It takes one or more local directory paths as input, extracts metadata tags from any audio files that it encounters, and generates a valid XSPF playlist.
5
5
 
6
- ##Installation
7
- [TagLib](http://developer.kde.org/~wheeler/taglib.html) is required for spfy to work. Follow the steps below (taken from the [taglib-ruby installation guide](http://robinst.github.com/taglib-ruby/)) to install the necessary files for your respective system type:
6
+ ##Prerequisites
7
+ A working Ruby installation version 1.9 or greater is assumed for Spfy to work, but this is outside the scope of this guide. For more information refer to the [official installation procedure](http://www.ruby-lang.org/en/downloads/).
8
+
9
+ [TagLib](http://developer.kde.org/~wheeler/taglib.html) is also required for Spfy to function. Follow the steps below (taken from the [taglib-ruby installation guide](http://robinst.github.com/taglib-ruby/)) to install the necessary files for your respective system type:
8
10
 
9
- > | System: | Command: |
10
- > |---------------|------------------------------------|
11
- > | Debian/Ubuntu | `sudo apt-get install libtag1-dev` |
12
- > | Fedora/RHEL | `sudo yum install taglib-devel` |
13
- > | Brew | `brew install taglib` |
14
- > | MacPorts | `sudo port install taglib` |
11
+ | System: | Command: |
12
+ |---------------|------------------------------------|
13
+ | Debian/Ubuntu | `sudo apt-get install libtag1-dev` |
14
+ | Fedora/RHEL | `sudo yum install taglib-devel` |
15
+ | Brew | `brew install taglib` |
16
+ | MacPorts | `sudo port install taglib` |
15
17
 
16
- Spfy can then be installed with the following command:
18
+ ##Installation
19
+ With the prerequisites above taken care of Spfy can be installed with the following command:
17
20
 
18
21
  gem install spfy
19
-
20
- ##Using spfy
21
- By default, spfy will output a formatted XSPF playlist to the standard output stream that will include _location_, _title_, _artist_, and _album_ elements for each audio file where available.
22
22
 
23
- The general syntax for spfy is `spfy [options] dir1 ... dirN`, where _dir1 ... dirN_ is one or more paths to directories containing audio files.
23
+ ##Using Spfy
24
+ By default, Spfy will output a formatted XSPF playlist to the standard output stream that will include _location_, _title_, _artist_, and _album_ elements for each audio file where available.
25
+
26
+ The general syntax for Spfy is `spfy [options] dir1 ... dirN`, where _dir1 ... dirN_ is one or more paths to directories containing audio files.
24
27
 
25
28
  For example:
26
29
 
@@ -42,7 +45,7 @@ For example:
42
45
 
43
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 spfy's output.
44
47
 
45
- Command-line arguments allow you to control which elements spfy outputs:
48
+ Command-line arguments allow you to control which elements Spfy outputs:
46
49
 
47
50
  -f, --no-location Suppress file location output
48
51
  -t, --no-title Suppress track title in output
@@ -52,7 +55,7 @@ Command-line arguments allow you to control which elements spfy outputs:
52
55
  For additional options use `spfy --help`.
53
56
 
54
57
  ##License
55
- Spfy is licensed under the [GNU General Public License v3.0](http://www.gnu.org/licenses/gpl.html).
58
+ This 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.
56
59
 
57
60
  ##Acknowledgments
58
61
  Spfy uses the following third party software components:
@@ -60,6 +63,4 @@ Spfy uses the following third party software components:
60
63
  * [taglib-ruby](http://robinst.github.com/taglib-ruby/) by Robin Stocker
61
64
 
62
65
  ##Comments or suggestions?
63
- Feel free to contact me with bug reports, feature requests and general comments by emailing [marc.ransome@fidgetbox.co.uk](marc.ransome@fidgetbox.co.uk).
64
-
65
- Follow [@marcransome](http://www.twitter.com/marcransome) on Twitter for the latest news.
66
+ Email me at [marc.ransome@fidgetbox.co.uk](marc.ransome@fidgetbox.co.uk) with bug reports, feature requests or general comments and follow [@marcransome](http://www.twitter.com/marcransome) for updates.
data/lib/spfy.rb CHANGED
@@ -26,7 +26,7 @@ require "taglib"
26
26
  require 'find'
27
27
  require 'uri'
28
28
 
29
- $version = "0.1.7"
29
+ $version = "0.1.8"
30
30
  $dirs = []
31
31
 
32
32
  # The main Spfy class
@@ -72,6 +72,7 @@ class Spfy
72
72
  # start processing source paths
73
73
  begin
74
74
  if options.output.any?
75
+ # source path(s) provided, output should be to disk
75
76
 
76
77
  xmlFile = File.open(options.output[0], "w")
77
78
 
@@ -94,12 +95,13 @@ class Spfy
94
95
  tag = fileref.tag
95
96
 
96
97
  # skip files with no tags
97
- next if tag.title.empty? and tag.artist.empty? and tag.album.empty?
98
+ next if tag.nil?
98
99
 
99
100
  # write track metadata
100
101
  xmlFile.write("\t\t<track>\n")
101
102
 
102
103
  if !options.hide_location
104
+ # generate a percent encoded string from the local path
103
105
  encoded_path = URI.escape(path)
104
106
  xmlFile.write("\t\t\t<location>file://#{encoded_path}</location>\n")
105
107
  end
@@ -107,6 +109,13 @@ class Spfy
107
109
  xmlFile.write("\t\t\t<title>#{tag.title}</title>\n") if !options.hide_title and !tag.title.nil?
108
110
  xmlFile.write("\t\t\t<creator>#{tag.artist}</creator>\n") if !options.hide_artist and !tag.artist.nil?
109
111
  xmlFile.write("\t\t\t<album>#{tag.album}</album>\n") if !options.hide_album and !tag.album.nil?
112
+
113
+ if !options.hide_tracknum and !tag.track.nil?
114
+ if tag.track > 0
115
+ xmlFile.write("\t\t\t<trackNum>#{tag.track}</trackNum>\n")
116
+ end
117
+ end
118
+
110
119
  xmlFile.write("\t\t</track>\n")
111
120
  end
112
121
  rescue Exception => e
@@ -123,7 +132,10 @@ class Spfy
123
132
 
124
133
  print " success\n"
125
134
 
126
- else
135
+ else
136
+ # no source path(s) provided, output to stdout
137
+
138
+ # write XSPF header
127
139
  puts "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
128
140
  puts "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n"
129
141
  puts "\t<trackList>\n"
@@ -140,8 +152,8 @@ class Spfy
140
152
  tag = fileref.tag
141
153
 
142
154
  # skip files with no tags
143
- next if tag.title.empty? and tag.artist.empty? and tag.album.empty?
144
-
155
+ next if tag.nil?
156
+
145
157
  # output track metadata
146
158
  puts "\t\t<track>\n"
147
159
 
@@ -153,10 +165,15 @@ class Spfy
153
165
  puts "\t\t\t<title>#{tag.title}</title>\n" if !options.hide_title and !tag.title.nil?
154
166
  puts "\t\t\t<creator>#{tag.artist}</creator>\n" if !options.hide_artist and !tag.artist.nil?
155
167
  puts "\t\t\t<album>#{tag.album}</album>\n" if !options.hide_album and !tag.album.nil?
168
+
169
+ if !options.hide_tracknum and !tag.track.nil?
170
+ if tag.track > 0
171
+ puts "\t\t\t<trackNum>#{tag.track}</trackNum>\n"
172
+ end
173
+ end
174
+
156
175
  puts "\t\t</track>\n"
157
176
  end
158
- rescue SystemExit, Interrupt
159
- # allow user interrupt
160
177
  rescue Exception => e
161
178
  next
162
179
  end
@@ -30,6 +30,7 @@ class OptionReader
30
30
  options.hide_artist = false
31
31
  options.hide_album = false
32
32
  options.hide_location = false
33
+ options.hide_tracknum = false
33
34
 
34
35
  opts = OptionParser.new do |opts|
35
36
  opts.banner = "Usage: #{File.basename($0)} [options] dir1 ... dirN"
@@ -62,6 +63,10 @@ class OptionReader
62
63
  options.hide_album = true
63
64
  end
64
65
 
66
+ opts.on("-n", "--no-tracknum", "Suppress track number in output") do
67
+ options.hide_tracknum = true
68
+ end
69
+
65
70
  opts.separator ""
66
71
  opts.separator "Misc options:"
67
72
 
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.1.7'
24
+ s.version = '0.1.8'
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.'
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.7
4
+ version: 0.1.8
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