autogg 0.2.4 → 0.2.5
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.textile +20 -1
- data/autogg-0.2.4.gem +0 -0
- data/autogg.gemspec +1 -1
- data/lib/autogg/encoder.rb +7 -9
- data/lib/autogg/parser.rb +41 -34
- data/lib/autogg/utils.rb +20 -3
- metadata +2 -1
data/README.textile
CHANGED
@@ -4,10 +4,29 @@ h2. Summary
|
|
4
4
|
|
5
5
|
Encodes all flac files in a given directory to ogg in another given directory while preserving the directory structure.
|
6
6
|
|
7
|
+
h2. Installation
|
8
|
+
|
9
|
+
bc. $ gem install autogg
|
10
|
+
|
11
|
+
h2. Usage
|
12
|
+
|
13
|
+
bc. man autogg
|
14
|
+
|
15
|
+
h2. Logfile utilization
|
16
|
+
|
17
|
+
The top of each autogg.log (in oggpath) should read:
|
18
|
+
"This is the log of excluded files for the most recently run autogg".
|
19
|
+
|
20
|
+
Each line follows the pattern:
|
21
|
+
@"#{parent(path)} -- #{File.basename(path)}"@
|
22
|
+
|
23
|
+
For optimal viewing pleasure, I recommend doing:
|
24
|
+
@$ cat autogg.log | sort | less@
|
25
|
+
|
7
26
|
h2. Adding as a cronjob
|
8
27
|
|
9
28
|
*Example:*
|
10
29
|
|
11
30
|
bc. $ echo '@hourly ID=autogg autogg /media/tb/rt/wt/ /media/tb/ogg/ -o -q8' | crontab -
|
12
31
|
|
13
|
-
_keep in mind this replaces
|
32
|
+
_keep in mind this replaces your current crontab_
|
data/autogg-0.2.4.gem
ADDED
Binary file
|
data/autogg.gemspec
CHANGED
@@ -2,7 +2,7 @@ spec = Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'autogg'
|
3
3
|
s.summary = 'converts a folder of flacs to ogg, preserving directory structure'
|
4
4
|
s.requirements << 'oggenc must be installed on the base system'
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.5"
|
6
6
|
s.author = 'Evan Simmons'
|
7
7
|
s.email = 'esims89@gmail.com'
|
8
8
|
s.homepage = 'https://github.com/estk/autogg'
|
data/lib/autogg/encoder.rb
CHANGED
@@ -7,13 +7,13 @@ module OggEncode
|
|
7
7
|
|
8
8
|
def oggencdir
|
9
9
|
@pbar = ProgressBar.new( "Progress", ( count_flacs - count_oggs ) )
|
10
|
-
Find.find( @paths.flac ) do |path|
|
10
|
+
Find.find( @options.paths.flac ) do |path|
|
11
11
|
if FileTest.directory?( path )
|
12
12
|
Find.prune if File.basename( path )[0] == ?.
|
13
13
|
elsif Flac.exists?( path ) and not Ogg.exists?( getoutpath(path) )
|
14
14
|
encfile( path )
|
15
15
|
else
|
16
|
-
@log <<
|
16
|
+
@log << path
|
17
17
|
end
|
18
18
|
end
|
19
19
|
Process.waitall ; @ps_hash = {} ; @pbar.finish
|
@@ -22,25 +22,25 @@ module OggEncode
|
|
22
22
|
def encfile( inpath )
|
23
23
|
outpath = getoutpath( inpath )
|
24
24
|
@ps_hash.store( nil, outpath ) do
|
25
|
-
ps = IO.popen %Q{oggenc #{@oggargs.join(' ')} "#{inpath}" -o "#{outpath}"}
|
25
|
+
ps = IO.popen %Q{oggenc #{@options.oggargs.join(' ')} "#{inpath}" -o "#{outpath}"}
|
26
26
|
end
|
27
27
|
@pbar.inc
|
28
28
|
end
|
29
29
|
|
30
30
|
def getoutpath( inpath )
|
31
|
-
outpath = inpath.gsub( @paths.flac, @paths.ogg )
|
31
|
+
outpath = inpath.gsub( @options.paths.flac, @options.paths.ogg )
|
32
32
|
outpath.gsub!( /\.flac/, '.ogg' )
|
33
33
|
end
|
34
34
|
|
35
35
|
def count_flacs
|
36
36
|
c = 0
|
37
|
-
Find.find( @paths.flac ) {|p| c += 1 if Flac.exists?( p ) }
|
37
|
+
Find.find( @options.paths.flac ) {|p| c += 1 if Flac.exists?( p ) }
|
38
38
|
c
|
39
39
|
end
|
40
40
|
|
41
41
|
def count_oggs
|
42
42
|
c = 0
|
43
|
-
Find.find( @paths.ogg ) {|p| c += 1 if Ogg.exists?( p ) }
|
43
|
+
Find.find( @options.paths.ogg ) {|p| c += 1 if Ogg.exists?( p ) }
|
44
44
|
c
|
45
45
|
end
|
46
46
|
|
@@ -54,10 +54,8 @@ module OggEncode
|
|
54
54
|
|
55
55
|
def encode( options )
|
56
56
|
@options = options
|
57
|
-
@paths = options.paths
|
58
|
-
@oggargs = options.oggargs
|
59
57
|
@ps_hash = SizedPsHash.new( options.max_procs )
|
60
|
-
@log = Logger.new(@paths.ogg)
|
58
|
+
@log = Logger.new(@options.paths.ogg)
|
61
59
|
oggencdir
|
62
60
|
ensure
|
63
61
|
@log.close
|
data/lib/autogg/parser.rb
CHANGED
@@ -3,46 +3,53 @@ require 'ostruct'
|
|
3
3
|
|
4
4
|
module OggEncode
|
5
5
|
class Parser
|
6
|
-
|
6
|
+
class << self
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
options.oggargs = ['-Q']
|
12
|
-
|
13
|
-
op = OptionParser.new do |opts|
|
14
|
-
opts.banner = "Usage: autogg.rb [options] flacpath oggpath [ -o oggenc args ... ]\n" +
|
15
|
-
"Example: #{script_name} ~/music/flac/ ~/music/ogg/ --oggenc-args -q8\n" +
|
16
|
-
" Ex2: #{script_name} ~/music/flac/ ~/music/ogg/ -o -q8,-Q,--utf8"
|
17
|
-
|
18
|
-
opts.on( '-m', '--max-processes n', "Maximum number of encoding processes running at once" ) do |n|
|
19
|
-
options.max_procs = n.to_i
|
20
|
-
end
|
8
|
+
def make_path(folder)
|
9
|
+
folder =~ /\/$/ ? folder : folder + '/'
|
10
|
+
end
|
21
11
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
12
|
+
def parse(args)
|
13
|
+
|
14
|
+
script_name = File.basename( $0 )
|
15
|
+
options = OpenStruct.new
|
16
|
+
options.max_procs = 4
|
17
|
+
options.oggargs = ['-Q']
|
18
|
+
|
19
|
+
op = OptionParser.new do |opts|
|
20
|
+
opts.banner = "Usage: autogg.rb [options] flacpath oggpath [ -o oggenc args ... ]\n" +
|
21
|
+
"Example: #{script_name} ~/music/flac/ ~/music/ogg/ --oggenc-args -q8\n" +
|
22
|
+
" Ex2: #{script_name} ~/music/flac/ ~/music/ogg/ -o -q8,-Q,--utf8"
|
23
|
+
|
24
|
+
opts.on( '-m', '--max-processes n', "Maximum number of encoding processes running at once" ) do |n|
|
25
|
+
options.max_procs = n.to_i
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on( '-o', '--oggenc-args arglist', Array,
|
29
|
+
"Specify arguments to me be passed through to oggenc" ) do |ary|
|
30
|
+
options.oggargs << ary
|
31
|
+
options.oggargs.flatten!
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
35
|
+
puts opts
|
36
|
+
puts dirinfo
|
37
|
+
exit
|
38
|
+
end
|
26
39
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
40
|
+
op.parse!
|
41
|
+
|
42
|
+
if ( ARGV.length == 2 ) and ARGV.all? { |a| File.directory?( a )}
|
43
|
+
paths = OpenStruct.new
|
44
|
+
paths.flac = make_path(ARGV[0]) ; paths.ogg = make_path(ARGV[1])
|
45
|
+
options.paths = paths
|
46
|
+
else
|
47
|
+
puts op
|
31
48
|
exit
|
32
49
|
end
|
33
|
-
end
|
34
|
-
op.parse!
|
35
|
-
|
36
|
-
if ( ARGV.length == 2 ) and ARGV.all? { |a| File.directory?( a )}
|
37
|
-
paths = OpenStruct.new
|
38
|
-
paths.flac = ARGV[0] ; paths.ogg = ARGV[1]
|
39
|
-
options.paths = paths
|
40
|
-
else
|
41
|
-
puts op
|
42
|
-
exit
|
43
|
-
end
|
44
50
|
|
45
|
-
|
51
|
+
options
|
52
|
+
end
|
46
53
|
end
|
47
54
|
end
|
48
55
|
end
|
data/lib/autogg/utils.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
module OggEncode
|
3
|
+
|
2
4
|
class Flac < File
|
3
5
|
def self.exists?( path )
|
4
6
|
file?( path ) and basename( path ) =~ /\.flac$/
|
@@ -30,12 +32,27 @@ module OggEncode
|
|
30
32
|
|
31
33
|
class Logger
|
32
34
|
|
35
|
+
def parent(path)
|
36
|
+
n = 0
|
37
|
+
result = ""
|
38
|
+
path.reverse.each_char do |c|
|
39
|
+
n += 1 if c == '/'
|
40
|
+
if n == 1
|
41
|
+
result << c
|
42
|
+
elsif n >= 2
|
43
|
+
break
|
44
|
+
end
|
45
|
+
end
|
46
|
+
return result.reverse
|
47
|
+
end
|
48
|
+
|
33
49
|
def initialize(location)
|
34
|
-
@log = File.new("#{location}log
|
50
|
+
@log = File.new("#{location}autogg.log", "w+")
|
51
|
+
@log.puts "This is the log of excluded files for the most recently run autogg \n\n"
|
35
52
|
end
|
36
53
|
|
37
|
-
def <<(
|
38
|
-
@log.puts "#{
|
54
|
+
def <<(path)
|
55
|
+
@log.puts "#{parent(path)} -- #{File.basename(path)}"
|
39
56
|
end
|
40
57
|
|
41
58
|
def close
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: autogg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Evan Simmons
|
@@ -24,6 +24,7 @@ extra_rdoc_files: []
|
|
24
24
|
files:
|
25
25
|
- README.textile
|
26
26
|
- autogg.gemspec
|
27
|
+
- autogg-0.2.4.gem
|
27
28
|
- LICENCE
|
28
29
|
- autogg-0.2.3.gem
|
29
30
|
- bin/autogg
|