Compare commits

..

No commits in common. "bde4972a7f0fb55f684e2b290e0fb67932b7f09d" and "875ed7a6688a5d41858caecab3a91a1db6876c21" have entirely different histories.

View File

@ -12,27 +12,20 @@ class Dedupe(Layer):
def _process(self, left: Root): def _process(self, left: Root):
right = self.other right = self.other
existing_artists = right.by_name() existing_artists = right.by_name()
pruned_artists = list()
for artist in left: for artist in left:
artist_name = artist.name artist_name = artist.name
if artist_name in existing_artists: if artist_name in existing_artists:
pruned_albums = self.prune_artist(artist, right[artist_name]) self.prune_artist(artist, right[artist_name])
if len(artist.contents) == 0: if len(artist.contents) == 0:
pruned_artists.append(artist_name) left.prune(artist_name)
self.log.info('PRN', f"Pruned artist: {artist_name}") self.log.info('PRN', f"Pruned artist: {artist_name}")
else:
for album_name in pruned_albums:
self.log.info('PRN', f"Pruned album: {album_name}")
else: else:
continue # todo: fuzzy matching continue # todo: fuzzy matching
[left.prune(artist) for artist in pruned_artists]
@staticmethod def prune_artist(self, left: Artist, right: Artist):
def prune_artist(left: Artist, right: Artist):
existing_albums = right.by_name() existing_albums = right.by_name()
pruned_albums = list() for album in left:
for album_name in existing_albums: album_name = album.name
if album_name in left.by_name(): if album_name in existing_albums:
left.prune(album_name) left.prune(album_name)
pruned_albums.append(album_name) self.log.info('PRN', f"Pruned album: {album_name}")
return pruned_albums