aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAdam Vandenberg2013-06-13 11:34:52 -0700
committerAdam Vandenberg2013-06-13 11:35:27 -0700
commit69d97981318e1d138f8885f4e3072f26a9c34caf (patch)
treee7435feb812d47ce337ba6ae1da5857a7e4a0f79 /Library
parent4ad56e95bd9dac2f97c5151b276001a80fc8c6bc (diff)
downloadhomebrew-69d97981318e1d138f8885f4e3072f26a9c34caf.tar.bz2
flac: inline flac2mp3 script
Closes #20448.
Diffstat (limited to 'Library')
-rw-r--r--Library/Formula/flac.rb36
1 files changed, 29 insertions, 7 deletions
diff --git a/Library/Formula/flac.rb b/Library/Formula/flac.rb
index 64ef0c64d..b12686b59 100644
--- a/Library/Formula/flac.rb
+++ b/Library/Formula/flac.rb
@@ -1,10 +1,5 @@
require 'formula'
-class Flac2Mp3 < Formula
- url 'https://github.com/rmndk/flac2mp3/archive/v1.0.tar.gz'
- sha1 '1fe176c715a6cd780179126d6aa95cf1f15e7ad8'
-end
-
class Flac < Formula
homepage 'http://xiph.org/flac/'
url 'http://downloads.xiph.org/releases/flac/flac-1.3.0.tar.xz'
@@ -40,7 +35,34 @@ class Flac < Formula
end
system "make install"
-
- Flac2Mp3.new.brew {|f| bin.install 'flac2mp3'}
+ (bin/'flac2mp3').write DATA.read
end
end
+
+__END__
+#!/usr/bin/env ruby
+# http://gist.github.com/gists/2998853/
+# Forked from http://gist.github.com/gists/124242
+
+filename, quality = ARGV[0], ARGV[1]
+abort "Usage: flac2mp3 FLACFILE [V2|V1|V0|320]\nDefault (and recommended) quality is V0." if filename.nil?
+
+qualarg = case quality
+ when "V0","V1","V2" then quality
+ when "320" then "b 320"
+ else "V0"
+end
+
+map = {"TITLE" => "--tt", "ARTIST" => "--ta", "ALBUM" => "--tl", "TRACKNUMBER" => "--tn", "GENRE" => "--tg", "DATE" => "--ty"}
+args = ""
+
+`metaflac --export-tags-to=- "#{filename}"`.each_line do |line|
+ key, value = line.strip.split('=', 2)
+ key.upcase!
+ args << %Q{#{map[key]} "#{value.gsub('"', '\"')}" } if map[key]
+end
+
+basename = File.basename(filename, File.extname(filename))
+
+puts "Encoding #{basename}.mp3"
+exec %Q[flac -sdc "#{filename}" | lame -#{qualarg} #{args} - "#{basename}.mp3"]