(self, lib: library.Library)
| 258 | return duplicate_items |
| 259 | |
| 260 | def remove_duplicates(self, lib: library.Library) -> None: |
| 261 | duplicate_albums = self.find_duplicates(lib) |
| 262 | log.debug("removing {} old duplicate albums", len(duplicate_albums)) |
| 263 | |
| 264 | for album in duplicate_albums: |
| 265 | artpath = album.artpath |
| 266 | |
| 267 | for item in album.items(): |
| 268 | item.remove(with_album=False) |
| 269 | if lib.directory in util.ancestry(item.path): |
| 270 | log.debug("deleting duplicate {.filepath}", item) |
| 271 | util.remove(item.path) |
| 272 | util.prune_dirs( |
| 273 | os.path.dirname(item.path), |
| 274 | lib.directory, |
| 275 | clutter=config["clutter"].as_str_seq(), |
| 276 | ) |
| 277 | |
| 278 | album.remove(with_items=False) |
| 279 | |
| 280 | if artpath and lib.directory in util.ancestry(artpath): |
| 281 | log.debug("deleting duplicate album art {}", artpath) |
| 282 | util.remove(artpath) |
| 283 | util.prune_dirs( |
| 284 | os.path.dirname(artpath), |
| 285 | lib.directory, |
| 286 | clutter=config["clutter"].as_str_seq(), |
| 287 | ) |
| 288 | |
| 289 | def set_fields(self, lib: library.Library) -> None: |
| 290 | """Sets the fields given at CLI or configuration to the specified |
no test coverage detected