mediafile 0.0.3 → 0.1.0
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/bin/music_cp +50 -18
- data/lib/mediafile/mediafile.rb +3 -1
- data/lib/mediafile/version.rb +1 -1
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fc4745ca61d0c560a088540bdc2c915883595f8
|
4
|
+
data.tar.gz: 6513da12413d7191bf965d6221ba262ef21f9498
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ccbebb876f2dfa7335dddb456635475cc725614be46e8a351eb7c086122d087104eec53bd3e68ed17096dc20f07e99eb11b580adb9b7523c594c2af966e7e40
|
7
|
+
data.tar.gz: b3922fbb97e6fc38d076dc89a337e2d1a2a969f3eb2ee0847fb99f5a5ddf9911de08cd38d1a91ddc7c7ea79e8049fcd4eba426095b2599f6bb6da47f34124971
|
data/bin/music_cp
CHANGED
@@ -2,10 +2,7 @@
|
|
2
2
|
# vim:et sw=2 ts=2
|
3
3
|
#
|
4
4
|
|
5
|
-
require 'fileutils'
|
6
5
|
require 'optparse'
|
7
|
-
require 'digest/md5'
|
8
|
-
require 'timeout'
|
9
6
|
require 'mediafile'
|
10
7
|
|
11
8
|
PROGNAME = File.basename($0)
|
@@ -16,6 +13,10 @@ end
|
|
16
13
|
|
17
14
|
kill = me = now = false
|
18
15
|
files = []
|
16
|
+
opt_files = {
|
17
|
+
flat: [],
|
18
|
+
recurse: []
|
19
|
+
}
|
19
20
|
dest = "."
|
20
21
|
verbose = false
|
21
22
|
progress = true
|
@@ -23,23 +24,15 @@ count = `grep -c '^processor' /proc/cpuinfo`.strip.to_i/2|1
|
|
23
24
|
transcode = { flac: :mp3, wav: :mp3 }
|
24
25
|
exclude_patterns = []
|
25
26
|
file_types = "{flac,mp3,MP3,FLAC,wav,WAV,m4a,M4A}"
|
27
|
+
|
26
28
|
opts = OptionParser.new do |opt|
|
27
29
|
|
28
30
|
opt.on("-f", "--file FILE|DIR", "File or directory to copy.",
|
29
31
|
"If given a directory, will grab all files within non-recursively") do |e|
|
30
|
-
e.split(
|
31
|
-
if File.file? f
|
32
|
-
files << f
|
33
|
-
elsif File.directory? f
|
34
|
-
files.concat Dir.glob( f + "/*.#{file_types}")
|
35
|
-
else
|
36
|
-
warn "#{f} is not a file or a directory!"
|
37
|
-
end
|
38
|
-
end
|
32
|
+
opt_files[:flat].concat e.split(',')
|
39
33
|
end
|
40
34
|
opt.on("-r", "--recursive DIR", "Directory to recursively scan and copy") do |r|
|
41
|
-
|
42
|
-
files.concat Dir.glob( r + "/**/*.#{file_types}")
|
35
|
+
opt_files[:recurse].concat r.split(',')
|
43
36
|
end
|
44
37
|
opt.on("-d", "--destination PATH", "Where to copy file to. Default: '#{dest}'",
|
45
38
|
"Will be created if it doesn't exist.") do |d|
|
@@ -59,7 +52,7 @@ opts = OptionParser.new do |opt|
|
|
59
52
|
end
|
60
53
|
opt.on("--exclude PATTERN", "-x PATTERN", String, "Exclude files that match the given pattern.",
|
61
54
|
"Can specify more than once, file is excluded if any pattern matches") do |p|
|
62
|
-
exclude_patterns
|
55
|
+
exclude_patterns.concat p.split(',')
|
63
56
|
end
|
64
57
|
opt.on("-v", "--[no-]verbose", "Be verbose") do |v|
|
65
58
|
verbose = v
|
@@ -83,13 +76,46 @@ opts = OptionParser.new do |opt|
|
|
83
76
|
end
|
84
77
|
end
|
85
78
|
|
79
|
+
# resolve flat dirs
|
80
|
+
opt_files[:flat].each do |f|
|
81
|
+
if File.file? f
|
82
|
+
files << f
|
83
|
+
elsif File.directory? f
|
84
|
+
files.concat Dir.glob( f + "/*.#{file_types}")
|
85
|
+
else
|
86
|
+
warn "#{f} is not a file or a directory!"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# resolve recurse dirs
|
91
|
+
opt_files[:recurse].each do |r|
|
92
|
+
if File.directory? r
|
93
|
+
files.concat Dir.glob( r + "/**/*.#{file_types}")
|
94
|
+
else
|
95
|
+
warn "#{r} is not a file or a directory!"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
86
99
|
files = files.uniq.sort
|
87
100
|
if exclude_patterns.any?
|
88
|
-
|
101
|
+
is_a_regexp = /\/?(.+?)(?:\/([imxouesn]*))?$/
|
102
|
+
pattern = Regexp.union(
|
103
|
+
exclude_patterns.map{ |pat|
|
104
|
+
m = pat.match(is_a_regexp)
|
105
|
+
if m
|
106
|
+
Regexp.new(*m.captures)
|
107
|
+
else
|
108
|
+
raise "Bag pattern: '#{pat}'"
|
109
|
+
end
|
110
|
+
}.compact
|
111
|
+
)
|
112
|
+
puts "Using exclude pattern: #{pattern}" if verbose
|
89
113
|
files.delete_if { |el| pattern.match el }
|
90
114
|
end
|
115
|
+
|
91
116
|
if files.empty?
|
92
117
|
warn "No file specified, exiting"
|
118
|
+
warn "Perhaps you excluded too many? '#{pattern}'" if exclude_patterns.any?
|
93
119
|
warn opts
|
94
120
|
exit
|
95
121
|
end
|
@@ -98,14 +124,20 @@ files.each { |l| puts "\t"+l }
|
|
98
124
|
puts "#{files.count} files total"
|
99
125
|
puts "The following transcode table will be used:"
|
100
126
|
puts transcode.any? ? transcode : 'none'
|
101
|
-
puts "Do you wish
|
127
|
+
puts "Do you wish proceed? (Y/n)"
|
102
128
|
y = gets
|
103
129
|
if /n/i.match(y)
|
104
130
|
puts "User cancel."
|
105
131
|
exit
|
106
132
|
end
|
107
133
|
puts "Begin copy to #{dest}"
|
108
|
-
copier = MediaFile::BulkMediaCopy.new(
|
134
|
+
copier = MediaFile::BulkMediaCopy.new(
|
135
|
+
files,
|
136
|
+
destination_root: dest,
|
137
|
+
verbose: verbose,
|
138
|
+
transcode: transcode,
|
139
|
+
progress: progress
|
140
|
+
)
|
109
141
|
|
110
142
|
copier.run count
|
111
143
|
|
data/lib/mediafile/mediafile.rb
CHANGED
@@ -63,7 +63,9 @@ module MediaFile; class MediaFile
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
tags :album, :artist, :album_artist,
|
66
|
+
tags :album, :artist, :album_artist,
|
67
|
+
:title, :genre, :year, :track,
|
68
|
+
:comment, :disc_number, :disc_total
|
67
69
|
|
68
70
|
private
|
69
71
|
|
data/lib/mediafile/version.rb
CHANGED
metadata
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mediafile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
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: 2014-
|
11
|
+
date: 2014-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: taglib-ruby
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.6'
|
20
|
-
- -
|
20
|
+
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 0.6.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - ~>
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0.6'
|
30
|
-
- -
|
30
|
+
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.6.0
|
33
33
|
description: Parse media file metadata, copy or transcode mediafiles.
|
@@ -38,11 +38,11 @@ executables:
|
|
38
38
|
extensions: []
|
39
39
|
extra_rdoc_files: []
|
40
40
|
files:
|
41
|
-
- ./
|
42
|
-
- ./lib/mediafile.rb
|
43
|
-
- ./lib/mediafile/bulkmediacopy.rb
|
44
|
-
- ./lib/mediafile
|
45
|
-
- ./
|
41
|
+
- "./lib/mediafile/mediafile.rb"
|
42
|
+
- "./lib/mediafile/version.rb"
|
43
|
+
- "./lib/mediafile/bulkmediacopy.rb"
|
44
|
+
- "./lib/mediafile.rb"
|
45
|
+
- "./bin/music_cp"
|
46
46
|
- bin/music_cp
|
47
47
|
homepage: https://github.com/seginoviax/mediafile
|
48
48
|
licenses:
|
@@ -54,17 +54,17 @@ require_paths:
|
|
54
54
|
- lib
|
55
55
|
required_ruby_version: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - ~>
|
57
|
+
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '2'
|
60
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
|
-
- -
|
62
|
+
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
66
|
rubyforge_project:
|
67
|
-
rubygems_version: 2.
|
67
|
+
rubygems_version: 2.0.14
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: Parse media file metadata.
|