@@ -58,6 +58,13 @@ def commands(self):
58
58
dest = "write" ,
59
59
help = "don't write updated metadata to files" ,
60
60
)
61
+ cmd .parser .add_option (
62
+ "-t" ,
63
+ "--timid" ,
64
+ dest = "timid" ,
65
+ action = "store_true" ,
66
+ help = "always confirm all actions" ,
67
+ )
61
68
cmd .parser .add_format_option ()
62
69
cmd .func = self .func
63
70
return [cmd ]
@@ -66,13 +73,14 @@ def func(self, lib, opts, args):
66
73
"""Command handler for the mbsync function."""
67
74
move = ui .should_move (opts .move )
68
75
pretend = opts .pretend
76
+ timid = opts .timid
69
77
write = ui .should_write (opts .write )
70
78
query = ui .decargs (args )
71
79
72
- self .singletons (lib , query , move , pretend , write )
73
- self .albums (lib , query , move , pretend , write )
80
+ self .singletons (lib , query , move , pretend , write , timid )
81
+ self .albums (lib , query , move , pretend , write , timid )
74
82
75
- def singletons (self , lib , query , move , pretend , write ):
83
+ def singletons (self , lib , query , move , pretend , write , timid ):
76
84
"""Retrieve and apply info from the autotagger for items matched by
77
85
query.
78
86
"""
@@ -102,12 +110,26 @@ def singletons(self, lib, query, move, pretend, write):
102
110
)
103
111
continue
104
112
113
+ item_old = item .copy ()
114
+ autotag .apply_item_metadata (item , track_info )
115
+ if not ui .show_model_changes (item , item_old ):
116
+ continue
117
+
118
+ if timid :
119
+ print ()
120
+ choice = ui .input_options (("Apply" , "cancel" , "skip" ))
121
+ if choice == "a" : # Apply.
122
+ pass
123
+ elif choice == "c" : # Cancel.
124
+ return
125
+ elif choice == "s" : # Skip.
126
+ continue
127
+
105
128
# Apply.
106
129
with lib .transaction ():
107
- autotag .apply_item_metadata (item , track_info )
108
130
apply_item_changes (lib , item , move , pretend , write )
109
131
110
- def albums (self , lib , query , move , pretend , write ):
132
+ def albums (self , lib , query , move , pretend , write , timid ):
111
133
"""Retrieve and apply info from the autotagger for albums matched by
112
134
query and their items.
113
135
"""
@@ -174,28 +196,37 @@ def albums(self, lib, query, move, pretend, write):
174
196
mapping [item ] = c
175
197
break
176
198
199
+ # Gather changes.
200
+ changed = []
201
+ items_old = [item .copy () for item in items ]
202
+ autotag .apply_metadata (album_info , mapping )
203
+ for item , item_old in zip (items , items_old ):
204
+ if ui .show_model_changes (item , item_old ):
205
+ changed .append (item )
206
+
207
+ if len (changed ) == 0 :
208
+ continue
209
+
210
+ if timid :
211
+ print ()
212
+ choice = ui .input_options (("Apply" , "cancel" , "skip" ))
213
+ if choice == "a" : # Apply.
214
+ pass
215
+ elif choice == "c" : # Cancel.
216
+ return
217
+ elif choice == "s" : # Skip.
218
+ continue
219
+
177
220
# Apply.
178
221
self ._log .debug ("applying changes to {}" , album_formatted )
179
222
with lib .transaction ():
180
- autotag .apply_metadata (album_info , mapping )
181
- changed = False
182
- # Find any changed item to apply MusicBrainz changes to album.
183
- any_changed_item = items [0 ]
184
- for item in items :
185
- item_changed = ui .show_model_changes (item )
186
- changed |= item_changed
187
- if item_changed :
188
- any_changed_item = item
189
- apply_item_changes (lib , item , move , pretend , write )
190
-
191
- if not changed :
192
- # No change to any item.
193
- continue
223
+ for item in changed :
224
+ apply_item_changes (lib , item , move , pretend , write )
194
225
195
226
if not pretend :
196
227
# Update album structure to reflect an item in it.
197
228
for key in library .Album .item_keys :
198
- a [key ] = any_changed_item [key ]
229
+ a [key ] = changed [ 0 ] [key ]
199
230
a .store ()
200
231
201
232
# Move album art (and any inconsistent items).
0 commit comments