bookbinder 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -5,8 +5,11 @@ class Bookbinder::Transform::MediaRipper_Spine < Bookbinder::Transform
|
|
5
5
|
package.map['spine'] = package.audio_paths.collect { |path|
|
6
6
|
{
|
7
7
|
'path' => path,
|
8
|
-
'media-type' =>
|
9
|
-
|
8
|
+
'media-type' => 'audio/mpeg'
|
9
|
+
}.tap { |cmpt|
|
10
|
+
break unless cmpt_info = audio_info(package, path)
|
11
|
+
cmpt.update('audio-duration' => cmpt_info.length)
|
12
|
+
cmpt.update('audio-bitrate' => cmpt_info.bitrate) unless cmpt_info.vbr
|
10
13
|
}
|
11
14
|
}
|
12
15
|
end
|
@@ -14,18 +17,18 @@ class Bookbinder::Transform::MediaRipper_Spine < Bookbinder::Transform
|
|
14
17
|
|
15
18
|
protected
|
16
19
|
|
17
|
-
def
|
18
|
-
|
20
|
+
def audio_info(package, path)
|
21
|
+
info = nil
|
19
22
|
begin
|
20
23
|
package.file_system.get_io(path) { |zip_io|
|
21
|
-
io = StringIO.new(zip_io.read
|
22
|
-
Mp3Info.open(io) { |
|
24
|
+
io = StringIO.new(zip_io.read)
|
25
|
+
Mp3Info.open(io) { |inf| info = inf }
|
23
26
|
}
|
24
27
|
rescue => e
|
25
28
|
# TODO - is there error handling to do here?
|
26
29
|
raise e
|
27
30
|
end
|
28
|
-
|
31
|
+
info
|
29
32
|
end
|
30
33
|
|
31
34
|
end
|
@@ -23,9 +23,15 @@ class Bookbinder::Transform::MP3Audiobook_NavToc < Bookbinder::Transform
|
|
23
23
|
next unless xml && xml.slice!(MEDIAMARKER_PREFIX_RE)
|
24
24
|
doc = Nokogiri::XML(xml)
|
25
25
|
doc.root.css('Marker').each { |marker_tag|
|
26
|
+
arr = toc
|
27
|
+
title = marker_tag.at_css('Name').content
|
28
|
+
if title.match(/^[[:space:]]+/)
|
29
|
+
arr = (toc.last['contents'] ||= [])
|
30
|
+
title.gsub!(/^[[:space:]]+|[[:space:]]+$/, '')
|
31
|
+
end
|
26
32
|
seconds = translate_time(marker_tag.at_css('Time').content)
|
27
|
-
|
28
|
-
'title' =>
|
33
|
+
arr << {
|
34
|
+
'title' => title,
|
29
35
|
'path' => "#{aud_path}#{seconds ? "##{seconds}" : ''}"
|
30
36
|
}
|
31
37
|
}
|
@@ -5,8 +5,11 @@ class Bookbinder::Transform::MP3Audiobook_Spine < Bookbinder::Transform
|
|
5
5
|
package.map['spine'] = package.audio_paths.collect { |path|
|
6
6
|
{
|
7
7
|
'path' => path,
|
8
|
-
'media-type' => 'audio/mpeg'
|
9
|
-
|
8
|
+
'media-type' => 'audio/mpeg'
|
9
|
+
}.tap { |cmpt|
|
10
|
+
break unless cmpt_info = audio_info(package, path)
|
11
|
+
cmpt.update('audio-duration' => cmpt_info.length)
|
12
|
+
cmpt.update('audio-bitrate' => cmpt_info.bitrate) unless cmpt_info.vbr
|
10
13
|
}
|
11
14
|
}
|
12
15
|
end
|
@@ -14,17 +17,17 @@ class Bookbinder::Transform::MP3Audiobook_Spine < Bookbinder::Transform
|
|
14
17
|
|
15
18
|
protected
|
16
19
|
|
17
|
-
def
|
18
|
-
|
20
|
+
def audio_info(package, path)
|
21
|
+
info = nil
|
19
22
|
begin
|
20
23
|
package.file(path).get_file { |mp3|
|
21
|
-
Mp3Info.open(mp3) { |
|
24
|
+
Mp3Info.open(mp3) { |inf| info = inf }
|
22
25
|
}
|
23
26
|
rescue => e
|
24
27
|
# TODO - is there error handling to do here?
|
25
28
|
raise e
|
26
29
|
end
|
27
|
-
|
30
|
+
info
|
28
31
|
end
|
29
32
|
|
30
33
|
end
|
@@ -11,7 +11,7 @@ class Bookbinder::Transform::MP3Audiobook_Subject < Bookbinder::Transform
|
|
11
11
|
def to_map(package)
|
12
12
|
return unless md = package.map['metadata']
|
13
13
|
return unless md[TAG] && md[TAG].first
|
14
|
-
package.map['subject'] =
|
14
|
+
package.map['subject'] = md[TAG].collect { |h| h['@'] }
|
15
15
|
md.delete(TAG)
|
16
16
|
end
|
17
17
|
|
data/lib/bookbinder/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bookbinder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement: &
|
16
|
+
requirement: &15331860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *15331860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rubyzip
|
27
|
-
requirement: &
|
27
|
+
requirement: &15331360 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *15331360
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mime-types
|
38
|
-
requirement: &
|
38
|
+
requirement: &15330940 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *15330940
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: ruby-mp3info
|
49
|
-
requirement: &
|
49
|
+
requirement: &15330460 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *15330460
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &15330040 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *15330040
|
69
69
|
description: Convert easily between common ebook formats.
|
70
70
|
email:
|
71
71
|
- jpearson@overdrive.com
|