MCPcopy
hub / github.com/beetbox/beets / remove_duplicates

Method remove_duplicates

beets/importer/tasks.py:260–287  ·  view source on GitHub ↗
(self, lib: library.Library)

Source from the content-addressed store, hash-verified

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

Callers 1

manipulate_filesFunction · 0.45

Calls 4

find_duplicatesMethod · 0.95
debugMethod · 0.45
itemsMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected