Module: UnitF::Tag
- Defined in:
- lib/unitf/tag.rb,
lib/unitf/tag/mp3.rb,
lib/unitf/tag/file.rb,
lib/unitf/tag/flac.rb,
lib/unitf/tag/fileset.rb,
lib/unitf/tag/helpers.rb,
lib/unitf/tag/auto_tags.rb,
lib/unitf/tag/export/exporter.rb
Defined Under Namespace
Modules: Helpers
Classes: AutoTags, Error, Exporter, FLAC, File, FileSet, MP3, MissingCover
Class Method Summary
collapse
Class Method Details
.auto_track(dir) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/unitf/tag.rb', line 45
def auto_track(dir)
raise Error, "Invalid directory #{dir}" unless ::Dir.exist?(dir)
UnitF::Log.info("Auto track #{dir}")
track = 1
Dir.glob("#{dir}/*.mp3").sort.each do |file_path|
if ::File.basename(file_path).match?(/^\d+(\s|\.|-)/)
UnitF::Log.warn("Skipping #{file_path}")
next
end
UnitF::Tag.open(file_path) do |file|
if file.tag.track != track
UnitF::Log.info("Setting track to #{track} #{file_path}")
file.tag.track = track
file.save
end
end
track += 1
end
end
|
.list(files, format: :json) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/unitf/tag.rb', line 28
def list(files, format: :json)
buff = []
files.each do |file|
file.open do |o|
case format
when :json
buff << o.info
when :line
puts o.format_line
else
o.print
end
end
end
puts JSON.pretty_generate(buff) if format == :json
end
|
.open(file_path) ⇒ Object
22
23
24
25
26
|
# File 'lib/unitf/tag.rb', line 22
def open(file_path)
UnitF::Tag::File.new(file_path).open do |file|
yield file
end
end
|
.update(file_path) ⇒ Object
16
17
18
19
20
|
# File 'lib/unitf/tag.rb', line 16
def update(file_path)
UnitF::Tag::File.new(file_path).update do |file|
yield file
end
end
|