tagomatic 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.
- data/.gitignore +5 -2
- data/.idea/inspectionProfiles/profiles_settings.xml +2 -3
- data/Rakefile +3 -0
- data/VERSION +1 -1
- data/lib/monkey/string.rb +5 -2
- data/lib/tagomatic/options.rb +1 -0
- data/lib/tagomatic/options_parser.rb +3 -0
- data/lib/tagomatic/scanner.rb +7 -2
- data/lib/tagomatic/tagger.rb +19 -18
- data/lib/tasks/test_data.rb +40 -0
- data/test/data/mp3_template_file +0 -0
- data/test/data/sorted/80s/Peter_Schilling/1982 Fehler im System/album.dat +11 -0
- metadata +4 -3
- data/test/data/sorted/80s/Peter_Schilling/Fast_alles_konstruiert/01-Fast_alles_konstruiert.mp3 +0 -0
- data/test/data/sorted/80s/Peter_Schilling/Fast_alles_konstruiert/02-Dann_truegt_der_schein.mp3 +0 -0
data/.gitignore
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
<component name="InspectionProjectProfileManager">
|
2
2
|
<settings>
|
3
3
|
<option name="PROJECT_PROFILE" value="Project Default" />
|
4
|
-
<option name="
|
5
|
-
<
|
6
|
-
<list size="0" />
|
4
|
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
5
|
+
<version value="1.0" />
|
7
6
|
</settings>
|
8
7
|
</component>
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/monkey/string.rb
CHANGED
@@ -2,9 +2,12 @@ class String
|
|
2
2
|
|
3
3
|
def starts_with?(prefix)
|
4
4
|
pattern = Regexp.new "^#{Regexp.escape(prefix)}"
|
5
|
-
( pattern =~ self )
|
5
|
+
not ( pattern =~ self ).nil?
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
def ends_with?(suffix)
|
9
|
+
pattern = Regexp.new "#{Regexp.escape(suffix)}$"
|
10
|
+
not ( pattern =~ self ).nil?
|
11
|
+
end
|
9
12
|
|
10
13
|
end
|
data/lib/tagomatic/options.rb
CHANGED
@@ -71,6 +71,9 @@ module Tagomatic
|
|
71
71
|
opts.on("-w", "--showtags", "Show the resulting tags.") do |showtags|
|
72
72
|
@options[:showtags] = showtags
|
73
73
|
end
|
74
|
+
opts.on("-u", "--underscores", "Replace underscores with spaces before processing a file name.") do |underscores|
|
75
|
+
@options[:underscores] = underscores
|
76
|
+
end
|
74
77
|
|
75
78
|
opts.separator ""
|
76
79
|
opts.separator "Common options:"
|
data/lib/tagomatic/scanner.rb
CHANGED
@@ -33,10 +33,13 @@ module Tagomatic
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def enter_scannable_folder(&block)
|
36
|
+
folder_path = @file_path
|
37
|
+
@logger.verbose "entering #{folder_path}"
|
36
38
|
save_current_options
|
37
39
|
apply_local_options if has_local_options?
|
38
|
-
do_scan_folder(
|
40
|
+
do_scan_folder(folder_path, &block)
|
39
41
|
pop_local_options
|
42
|
+
@logger.verbose "leaving #{folder_path}"
|
40
43
|
end
|
41
44
|
|
42
45
|
def save_current_options
|
@@ -55,6 +58,7 @@ module Tagomatic
|
|
55
58
|
|
56
59
|
def apply_local_options
|
57
60
|
local_options = read_local_options
|
61
|
+
@logger.verbose "applying local options: #{local_options}"
|
58
62
|
@parser.parse!(local_options)
|
59
63
|
end
|
60
64
|
|
@@ -71,7 +75,7 @@ module Tagomatic
|
|
71
75
|
|
72
76
|
def do_scan_folder(folder_path, &block)
|
73
77
|
@logger.verbose "scanning #{folder_path}"
|
74
|
-
entries = Dir.entries(folder_path)
|
78
|
+
entries = Dir.entries(folder_path).sort
|
75
79
|
|
76
80
|
local_formats = entries.select { |entry| entry.starts_with?('.format=') }
|
77
81
|
apply_local_formats(local_formats)
|
@@ -83,6 +87,7 @@ module Tagomatic
|
|
83
87
|
end
|
84
88
|
|
85
89
|
def apply_local_formats(list_of_local_format_file_names)
|
90
|
+
@logger.verbose "applying local formats: #{list_of_local_format_file_names}"
|
86
91
|
local_formats = list_of_local_format_file_names.map do |file_name|
|
87
92
|
format = file_name.sub('.format=', '')
|
88
93
|
format.gsub!('|', '/')
|
data/lib/tagomatic/tagger.rb
CHANGED
@@ -14,25 +14,24 @@ module Tagomatic
|
|
14
14
|
FORMAT_ID_YEAR = 'y'
|
15
15
|
|
16
16
|
KNOWN_FORMATS = [
|
17
|
-
"%g/%a/%
|
18
|
-
"%g/%a/%y %b/%n_%t.mp3",
|
19
|
-
"%g/%a/%y %b/%n-%t.mp3",
|
17
|
+
"%g/%a/%b [%y]/%n - %t.mp3",
|
20
18
|
"%g/%a/%b [%y]/%n-%t.mp3",
|
19
|
+
"%g/%a/%b [%y]/%n %t.mp3",
|
20
|
+
|
21
|
+
"%g/%a/%b (%y)/%n - %t.mp3",
|
22
|
+
"%g/%a/%b (%y)/%n-%t.mp3",
|
23
|
+
"%g/%a/%b (%y)/%n %t.mp3",
|
24
|
+
|
25
|
+
"%g/%a/(%y) %b/%n - %t.mp3",
|
26
|
+
"%g/%a/(%y) %b/%n %t.mp3",
|
27
|
+
"%g/%a/(%y) %b/%n-%t.mp3",
|
21
28
|
|
22
|
-
"%g/%a/%a_%b_%y/%n_%t.mp3",
|
23
|
-
"%g/%a/%b [%y]/%n - %t.mp3",
|
24
|
-
"%g/%a/%b/%a - %n - %t.mp3",
|
25
29
|
"%g/%a/%b/%n - %t.mp3",
|
26
|
-
"%g/%a/%b/%n-%t.mp3",
|
27
|
-
"%g/%a/%b/%n_%t.mp3",
|
28
30
|
"%g/%a/%b/%n %t.mp3",
|
29
|
-
"%g/%a/%
|
30
|
-
|
31
|
-
"%
|
32
|
-
"%
|
33
|
-
"%a/%b/%n - %t.mp3",
|
34
|
-
"%a - %y - %b/%n - %t.mp3",
|
35
|
-
"%a - %b/%n - %t.mp3",
|
31
|
+
"%g/%a/%b/%n-%t.mp3",
|
32
|
+
|
33
|
+
"%a - %n - %t.mp3",
|
34
|
+
"%n - %a - %t.mp3",
|
36
35
|
]
|
37
36
|
|
38
37
|
def initialize(options, compiler, mp3info, info_updater_factory, logger)
|
@@ -44,6 +43,8 @@ module Tagomatic
|
|
44
43
|
end
|
45
44
|
|
46
45
|
def process!(file_path)
|
46
|
+
file_path.gsub '_', ' ' if @options[:underscores]
|
47
|
+
|
47
48
|
@logger.verbose "tagging #{file_path}"
|
48
49
|
|
49
50
|
prepare_for_current_file(file_path)
|
@@ -70,11 +71,11 @@ module Tagomatic
|
|
70
71
|
|
71
72
|
def apply_custom_formats
|
72
73
|
@tags = guess_tags_using(@options[:formats])
|
73
|
-
show_error("no custom format matched #{@file_path}") unless @tags
|
74
|
+
show_error("no custom format matched #{@file_path} using #{@options[:formats]}") unless @tags
|
74
75
|
end
|
75
76
|
|
76
77
|
def show_error(message, optional_exception = nil)
|
77
|
-
@logger.error(
|
78
|
+
@logger.error(message, optional_exception)
|
78
79
|
exit 10 if @options[:errorstops]
|
79
80
|
end
|
80
81
|
|
@@ -118,7 +119,7 @@ module Tagomatic
|
|
118
119
|
def try_updating_mp3file
|
119
120
|
update_mp3file
|
120
121
|
rescue
|
121
|
-
show_error "failed updating #{@file_path}",
|
122
|
+
show_error "failed updating #{@file_path}", $!
|
122
123
|
end
|
123
124
|
|
124
125
|
def update_mp3file
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'monkey/string'
|
2
|
+
|
3
|
+
namespace :test do
|
4
|
+
|
5
|
+
desc 'Create the test data mp3 files from their album.dat files.'
|
6
|
+
task :data do
|
7
|
+
Dir.glob('test/data/**/album.dat') do |album_dat_file_path|
|
8
|
+
puts "auto-generating album files for #{album_dat_file_path}"
|
9
|
+
album_folder = File.dirname(album_dat_file_path)
|
10
|
+
album_file_list = File.readlines(album_dat_file_path).map {|l| l.chomp}
|
11
|
+
album_file_list.each do |file_name|
|
12
|
+
puts "auto-generating album file #{file_name}"
|
13
|
+
file_name = file_name.chomp
|
14
|
+
file_path = File.join(album_folder, file_name)
|
15
|
+
create_fake_file file_path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_fake_file(file_path)
|
21
|
+
if is_mp3_file?(file_path)
|
22
|
+
create_mp3_fake_file file_path
|
23
|
+
else
|
24
|
+
create_empty_fake_file file_path
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def is_mp3_file?(file_path)
|
29
|
+
file_path.ends_with?('.mp3')
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_empty_fake_file(file_path)
|
33
|
+
system %Q[touch "#{file_path}"]
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_mp3_fake_file(file_path)
|
37
|
+
system %Q[cp test/data/mp3_template_file "#{file_path}"]
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
Binary file
|
@@ -0,0 +1,11 @@
|
|
1
|
+
album.id
|
2
|
+
Fehler Im System.jpg
|
3
|
+
Peter Schilling - 01 - ...Dann truegt der Schein.mp3
|
4
|
+
Peter Schilling - 02 - Fast alles konstruiert.mp3
|
5
|
+
Peter Schilling - 03 - Die Wueste lebt.mp3
|
6
|
+
Peter Schilling - 04 - Fehler im System.mp3
|
7
|
+
Peter Schilling - 05 - Major Tom (Voellig losgeloest).mp3
|
8
|
+
Peter Schilling - 06 - Major Tom.mp3
|
9
|
+
Peter Schilling - 07 - U.S.A..mp3
|
10
|
+
Peter Schilling - 08 - Ich hab keine Lust.mp3
|
11
|
+
Peter Schilling - 09 - Stille Nacht, heilige Nacht.mp3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tagomatic
|
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
|
- Daniel Lukic
|
@@ -104,8 +104,9 @@ files:
|
|
104
104
|
- lib/tagomatic/scanner.rb
|
105
105
|
- lib/tagomatic/system_configuration.rb
|
106
106
|
- lib/tagomatic/tagger.rb
|
107
|
-
-
|
108
|
-
- test/data/
|
107
|
+
- lib/tasks/test_data.rb
|
108
|
+
- test/data/mp3_template_file
|
109
|
+
- test/data/sorted/80s/Peter_Schilling/1982 Fehler im System/album.dat
|
109
110
|
- test/helper.rb
|
110
111
|
- test/test_tagomatic.rb
|
111
112
|
has_rdoc: true
|