beetbox / beetbox/beets

Refactor ImportTask

Open
#704 3 comments 0 reactions 0 assignees View on GitHub
refactor
Dominant language
Python
Stars
15.7k
Forks
2.1k
Avg merge
4d 21h
Merged PRs (30d)
31

Description

Following a discussion with @geigerzaehler regarding #690:

Some refactoring in the importer that delegates some more responsibility to the `ImportTask` class would help simplify the code. As an example, this block from `apply_choices`:

```
if task.is_album:
autotag.apply_metadata(
task.match.info, task.match.mapping
)
else:
autotag.apply_item_metadata(task.item, task.match.info)
```

could be wrapped up in a `task.apply()` call.

We could also consider dividing an `AlbumImportTask` class from a `SingletonImportTask`. Then `apply()` could be overridden to do the right thing for the kind of import.

If all goes well, we could eventually consider removing the distinction between album and singleton pipeline stages. The pipeline stages would just make calls to the appropriate ImportTask instance, which would handle the two kinds of imports differently. That would make, for example, the "as Tracks" interactive option more elegant since it could simply break the current `AlbumImportTask` into several `SingletonImportTask`s and send them down the pipeline.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.