24
24
log = logging .getLogger ('beets' )
25
25
26
26
27
- def _print_and_apply_changes (lib , item , move , pretend , write ):
27
+ def _print_and_apply_changes (lib , item , old_data , move , pretend , write ):
28
28
"""Apply changes to an Item and preview them in the console. Return
29
29
a boolean indicating whether any changes were made.
30
30
"""
31
31
changes = {}
32
32
for key in library .ITEM_KEYS_META :
33
- if ' key' in item ._dirty :
34
- changes [key ] = item . old_data [key ], getattr (item , key )
33
+ if key in item ._dirty :
34
+ changes [key ] = old_data [key ], getattr (item , key )
35
35
if not changes :
36
36
return False
37
37
@@ -69,7 +69,7 @@ def mbsync_singletons(lib, query, move, pretend, write):
69
69
.format (s .title ))
70
70
continue
71
71
72
- s . old_data = dict (s )
72
+ old_data = dict (s )
73
73
74
74
# Get the MusicBrainz recording info.
75
75
track_info = hooks .track_for_mbid (s .mb_trackid )
@@ -80,7 +80,7 @@ def mbsync_singletons(lib, query, move, pretend, write):
80
80
# Apply.
81
81
with lib .transaction ():
82
82
autotag .apply_item_metadata (s , track_info )
83
- _print_and_apply_changes (lib , s , move , pretend , write )
83
+ _print_and_apply_changes (lib , s , old_data , move , pretend , write )
84
84
85
85
86
86
def mbsync_albums (lib , query , move , pretend , write ):
@@ -93,8 +93,7 @@ def mbsync_albums(lib, query, move, pretend, write):
93
93
continue
94
94
95
95
items = list (a .items ())
96
- for item in items :
97
- item .old_data = dict (item )
96
+ old_data = {item : dict (item ) for item in items }
98
97
99
98
# Get the MusicBrainz album information.
100
99
album_info = hooks .album_for_mbid (a .mb_albumid )
@@ -116,8 +115,8 @@ def mbsync_albums(lib, query, move, pretend, write):
116
115
autotag .apply_metadata (album_info , mapping )
117
116
changed = False
118
117
for item in items :
119
- changed = _print_and_apply_changes (lib , item , move , pretend ,
120
- write ) or changed
118
+ changed | = _print_and_apply_changes (lib , item , old_data [ item ] ,
119
+ move , pretend , write )
121
120
if not changed :
122
121
# No change to any item.
123
122
continue
0 commit comments