summaryrefslogtreecommitdiff
path: root/omptagger
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2010-10-09 00:28:54 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2010-10-09 00:28:54 -0700
commit9304b6dbf9701bd32548ff128379da634cbf130f (patch)
tree271bf673f008d6dc3f5159ed60c9e09b89fd3a4c /omptagger
parent144054558ff849b204eefc57d30c00e182270660 (diff)
downloadomptagger-9304b6dbf9701bd32548ff128379da634cbf130f.tar.gz
omptagger-9304b6dbf9701bd32548ff128379da634cbf130f.tar.xz
Use libmagic to identify file type.
Diffstat (limited to 'omptagger')
-rwxr-xr-xomptagger18
1 files changed, 11 insertions, 7 deletions
diff --git a/omptagger b/omptagger
index 3d33675..a9b6525 100755
--- a/omptagger
+++ b/omptagger
@@ -10,19 +10,20 @@
require 'getoptlong'
require 'rubygems'
+require 'filemagic'
require 'TagLib'
class Hash
def longest_key_length
- self.keys.inject(0) do |length, key|
- key.length > length ? key.length : length
+ self.keys.inject(0) do |longest, key|
+ key.length > longest ? key.length : longest
end
end
end
class Metadata
- def output(tag, val, spacing = 2)
- puts ' ' + tag + ' ' * spacing + val
+ def output(tag, val, padding = 0)
+ puts ' ' + tag + ' ' * (2 + padding) + val
end
private :output
@@ -52,7 +53,7 @@ class VorbisComment < Metadata
@tags.sort.each do |tag, val|
val.each do |val|
- output(tag, val, 2 + @tags.longest_key_length - tag.length)
+ output(tag, val, @tags.longest_key_length - tag.length)
end
end
end
@@ -161,12 +162,15 @@ if ARGV.empty?
exit
end
+mime = FileMagic.mime
+mime.simplified = true
+
ARGV.each do |file|
begin
raise 'File does not exist.' unless File.exist?(file)
- case File.extname(file).downcase
- when '.flac'
+ case mime.file(file)
+ when 'audio/x-flac'
track = FLAC.new(file)
else
raise 'File extension not recognised.'