implement basic pruning based on dir name
This commit is contained in:
		
							parent
							
								
									a44d6f034a
								
							
						
					
					
						commit
						7fdb28d965
					
				|  | @ -1,13 +1,31 @@ | |||
| from pathlib import Path | ||||
| from log import Log | ||||
| from dir import Root | ||||
| from layer import Layer | ||||
| from . import Layer | ||||
| from dir import Artist | ||||
| 
 | ||||
| 
 | ||||
| class Dedupe(Layer): | ||||
|     def __init__(self, other: Root, log_path: Path): | ||||
|         super().__init__(log_path, "TCD") | ||||
|     def __init__(self, other: Root, log: Log): | ||||
|         super().__init__(log, "TCD") | ||||
|         self.other = other | ||||
| 
 | ||||
|     def _process(self, left: Root): | ||||
|         right = self.other | ||||
|         existing_artists = right.by_name() | ||||
|         for artist in left: | ||||
|             artist_name = artist.name | ||||
|             if artist_name in existing_artists: | ||||
|                 self.prune_artist(artist, right[artist_name]) | ||||
|                 if len(artist.contents) == 0: | ||||
|                     left.prune(artist_name) | ||||
|                     self.log.info('PRN', f"Pruned artist: {artist_name}") | ||||
|             else: | ||||
|                 continue # todo: fuzzy matching | ||||
| 
 | ||||
|     def __process(self, root: Root): | ||||
|         pass | ||||
|     def prune_artist(self, left: Artist, right: Artist): | ||||
|         existing_albums = right.by_name() | ||||
|         for album in left: | ||||
|             album_name = album.name | ||||
|             if album_name in existing_albums: | ||||
|                 left.prune(album_name) | ||||
|                 self.log.info('PRN', f"Pruned album: {album_name}") | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user