projects
/
rb-rip.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added locale_from_utf8, dropped the glib dependency.
[rb-rip.git]
/
rb-rip
diff --git
a/rb-rip
b/rb-rip
index 164d58187467ccd6b9dd09979181c7e50f214acb..58e3bc3fb2b3cb1cf6a223e9e836d776bc0d4cc5 100755
(executable)
--- a/
rb-rip
+++ b/
rb-rip
@@
-4,7
+4,7
@@
require 'fileutils'
require "musicbrainz"
require "yaml"
require "ostruct"
require "musicbrainz"
require "yaml"
require "ostruct"
-#require "glib2"
+require 'iconv'
require "tempfile"
class Track
require "tempfile"
class Track
@@
-176,6
+176,18
@@
class String
end
end
end
end
+def locale_from_utf8(s)
+ # FIXME: Encoding is only available in Ruby 1.9
+ to_charset = Encoding.locale_charmap
+ utf8 = 'UTF-8'.freeze
+
+ if to_charset == utf8
+ s.dup
+ else
+ Iconv.iconv to_charset, utf8, s
+ end
+end
+
cfg_file = ARGV.first || File.expand_path("~/.rbrip.yaml")
begin
cfg_file = ARGV.first || File.expand_path("~/.rbrip.yaml")
begin
@@
-230,8
+242,7
@@
puts "Disc info:\n
Tracks:\n"
album.tracks.each_with_index do |t, i|
Tracks:\n"
album.tracks.each_with_index do |t, i|
- #tmp = GLib.locale_from_utf8(t.name)
- tmp = t.name
+ tmp = locale_from_utf8 t.name
puts "%3s." % (i + 1) + " #{tmp}"
end
puts "%3s." % (i + 1) + " #{tmp}"
end
@@
-324,9
+335,8
@@
album.tracks.each_with_index do |t, i|
puts "Ripping: #{track_no}. #{t.name} => #{file + enc.suffix}"
`#{rip_cmd} | #{encode_cmd}`
puts "Ripping: #{track_no}. #{t.name} => #{file + enc.suffix}"
`#{rip_cmd} | #{encode_cmd}`
- apltags = enc.apply_tags(file + enc.suffix, metadata)
puts "Applying tags..."
puts "Applying tags..."
- `#{apltags} > /dev/null`
+ enc.apply_tags(file + enc.suffix, metadata)
end
rplgain_cmd = enc.compute_replaygain(files)
end
rplgain_cmd = enc.compute_replaygain(files)