mediafile 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/lib/mediafile.rb +13 -0
- data/lib/mediafile/bulkmediacopy.rb +2 -1
- data/lib/mediafile/mediafile.rb +18 -14
- data/lib/mediafile/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 307185529981f4c30a6c4b5f0d0b62eafce6b6d7
|
4
|
+
data.tar.gz: 452c79b918f2497ee19d1bb65879fe4610323ae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7decae2949b7f13e4d158f4bb1ff02954859328030e6142514b8efd37a3dd28c57e00a261ffb965c7681712e3e752be840b0240c2c84248dc6e1081a39324033
|
7
|
+
data.tar.gz: 5ef40fe3ec1e51688fe6e9c1ba7ca3e4bb41cd165ce42a7aa25293fdb8cd9f7fd9d18fcb7ee02a42baf4b4475326a56f6eb6e5b78a83e3d0a64af168bbdeed9c
|
data/lib/mediafile.rb
CHANGED
@@ -2,14 +2,27 @@
|
|
2
2
|
# vim:et sw=2 ts=2
|
3
3
|
|
4
4
|
require 'fileutils'
|
5
|
+
require 'mkmf'
|
5
6
|
require 'digest/md5'
|
6
7
|
require 'timeout'
|
7
8
|
require 'taglib'
|
8
9
|
require 'mediafile/version'
|
9
10
|
|
11
|
+
module MakeMakefile::Logging
|
12
|
+
@logfile = File::NULL
|
13
|
+
end
|
14
|
+
|
10
15
|
module MediaFile
|
11
16
|
|
12
17
|
autoload :MediaFile, 'mediafile/mediafile.rb'
|
13
18
|
autoload :BulkMediaCopy, 'mediafile/bulkmediacopy.rb'
|
14
19
|
|
20
|
+
missing = %i{ sox flac ffmpeg lame }.select do |cmd|
|
21
|
+
!find_executable("#{cmd}")
|
22
|
+
end
|
23
|
+
if missing && missing.any?
|
24
|
+
warn "The following executables weren't found in your $PATH: #{missing}\n" +
|
25
|
+
"Transcoding may not work in all cases."
|
26
|
+
end
|
27
|
+
|
15
28
|
end
|
@@ -121,7 +121,8 @@ module MediaFile; class BulkMediaCopy
|
|
121
121
|
c = cur_perc == 100
|
122
122
|
finished = @count.to_f / @work.count * 100
|
123
123
|
f = finished == 100.0
|
124
|
-
puts "%#{@width}d (%4.1f%%), %#{@width}d (%4.#{c ? 0 : 1}f%%),
|
124
|
+
puts ("%#{@width}d (%4.1f%%), %#{@width}d (%4.#{c ? 0 : 1}f%%), " +
|
125
|
+
"%#{@width}d (%4.#{f ? 0 : 1}f%%) %-#{@name_width}s => %-s") % [
|
125
126
|
left,
|
126
127
|
left_perc,
|
127
128
|
cur,
|
data/lib/mediafile/mediafile.rb
CHANGED
@@ -100,7 +100,7 @@ module MediaFile; class MediaFile
|
|
100
100
|
(@disc_number ? ["-T", "discnumber=#{@disc_number}"] : [] ) +
|
101
101
|
["-"]
|
102
102
|
when :mp3
|
103
|
-
%W{
|
103
|
+
%W{lame --quiet --preset extreme -h --add-id3v2 --id3v2-only} +
|
104
104
|
(@title ? ["--tt", @title] : [] ) +
|
105
105
|
(@artist ? ["--ta", @artist]: [] ) +
|
106
106
|
(@album ? ["--tl", @album] : [] ) +
|
@@ -120,7 +120,9 @@ module MediaFile; class MediaFile
|
|
120
120
|
|
121
121
|
def transcode(trans , destination)
|
122
122
|
to = trans[@type]
|
123
|
-
|
123
|
+
if to == @type
|
124
|
+
printit "Attempting to transcode to the same format #{@source} from #{@type} to #{to}"
|
125
|
+
end
|
124
126
|
FileUtils.mkdir_p File.dirname destination
|
125
127
|
|
126
128
|
decoder = set_decoder
|
@@ -166,7 +168,8 @@ module MediaFile; class MediaFile
|
|
166
168
|
raise
|
167
169
|
end
|
168
170
|
if err.any?
|
169
|
-
printit "###\nError transcoding #{@source}: #{err.map{|it,stat|
|
171
|
+
printit "###\nError transcoding #{@source}: #{err.map{ |it,stat|
|
172
|
+
"#{it} EOT:#{stat.exitstatus} #{stat}" }.join(" and ") }\n###\n"
|
170
173
|
exit 1
|
171
174
|
end
|
172
175
|
end
|
@@ -175,17 +178,18 @@ module MediaFile; class MediaFile
|
|
175
178
|
# it breaks windows (really!)
|
176
179
|
|
177
180
|
def relative_path
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
181
|
+
@relpath ||= (
|
182
|
+
read_tags
|
183
|
+
dest = File.join(
|
184
|
+
[(@album_artist||"UNKNOWN"), (@album||"UNKNOWN")].map { |word|
|
185
|
+
word.gsub(/^\.+|\.+$/,"").gsub(/\//,"_")
|
186
|
+
}
|
187
|
+
)
|
188
|
+
bool=true
|
189
|
+
dest.gsub(/\s/,"_").gsub(/[,:)\]\[('"@$^*<>?!]/,"").gsub(/_[&]_/,"_and_").split('').map{ |c|
|
190
|
+
b = bool; bool = c.match('/|_'); b ? c.capitalize : c
|
191
|
+
}.join('').gsub(/__+/,'_')
|
184
192
|
)
|
185
|
-
bool=true
|
186
|
-
@relpath = dest.gsub(/\s/,"_").gsub(/[,:)\]\[('"@$^*<>?!]/,"").gsub(/_[&]_/,"_and_").split('').map{ |c|
|
187
|
-
b = bool; bool = c.match('/|_'); b ? c.capitalize : c
|
188
|
-
}.join('').gsub(/__+/,'_')
|
189
193
|
end
|
190
194
|
|
191
195
|
def new_file_name
|
@@ -216,7 +220,7 @@ module MediaFile; class MediaFile
|
|
216
220
|
/_[&]_/,"_and_"
|
217
221
|
).split('').map{ |c|
|
218
222
|
b = bool; bool = c.match('/|_'); b ? c.capitalize : c
|
219
|
-
}.join('')
|
223
|
+
}.join('').gsub(/__+/,'_')
|
220
224
|
)
|
221
225
|
end
|
222
226
|
|
data/lib/mediafile/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mediafile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Harvey-Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: taglib-ruby
|
@@ -64,9 +64,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
66
|
rubyforge_project:
|
67
|
-
rubygems_version: 2.
|
67
|
+
rubygems_version: 2.6.2
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: Parse media file metadata.
|
71
71
|
test_files: []
|
72
|
-
has_rdoc:
|