beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.92k stars 1.82k forks source link

Option to remove leftover files from import #2961

Closed varac closed 6 years ago

varac commented 6 years ago

Problem

I'd like to have an option to remove leftover files from an import. i.e. I have an album that have additional text-files like this:


/tmp  » beet -vv import Sing_Along_With_Blue_Wave_Theory 
user configuration: /home/varac/.config/beets/config.yaml
data directory: /home/varac/.config/beets
plugin paths: 
Sending event: pluginload
library database: /home/varac/Media/Audio/beets/musiclibrary.db
library directory: /home/varac/Music
Sending event: library_opened
Sending event: import_begin
Sending event: import_task_created
Sending event: import_task_start
chroma: chroma: fingerprinted b'/tmp/Sing_Along_With_Blue_Wave_Theory/Blue_Wave_Theory_-_01_-_Living_Nightmare_Snowflake_Mix.mp3'
chroma: no match found
chroma: chroma: fingerprinted b'/tmp/Sing_Along_With_Blue_Wave_Theory/Blue_Wave_Theory_-_05_-_Hang_Loose_Spinningmerkaba_Mix_feat_DJ_Vadim_Kara_Square.mp3'
chroma: no match found
chroma: chroma: fingerprinted b'/tmp/Sing_Along_With_Blue_Wave_Theory/Blue_Wave_Theory_-_10_-_Mermaids_in_Japan_Spinmeister_Mix.mp3'
chroma: no match found
chroma: chroma: fingerprinted b'/tmp/Sing_Along_With_Blue_Wave_Theory/Blue_Wave_Theory_-_18_-_Hanging_Eleven_Kara_Square_Mix.mp3'
chroma: no match found
Looking up: /tmp/Sing_Along_With_Blue_Wave_Theory
Tagging Blue Wave Theory - Sing Along With Blue Wave Theory
No album ID found.
Search terms: Blue Wave Theory - Sing Along With Blue Wave Theory
Album might be VA: False
Searching for MusicBrainz releases with: {'release': 'sing along with blue wave theory', 'artist': 'blue wave theory', 'tracks': '4'}
Requesting MusicBrainz release 8c8a7108-a193-4a91-80e1-07d950cf4b92
primary MB release type: ep
secondary MB release type(s): demo
Sending event: albuminfo_received
Candidate: Inanimus Theory - Inanimus Theory (8c8a7108-a193-4a91-80e1-07d950cf4b92)
Computing track assignment...
...done.
Success. Distance: 0.70
Requesting MusicBrainz release c596bc74-b950-4d69-b76e-7aad3c3147bb
primary MB release type: ep
Sending event: albuminfo_received
Candidate: Tree Wave - Tree Wave (c596bc74-b950-4d69-b76e-7aad3c3147bb)
Computing track assignment...
...done.
Success. Distance: 0.74
Requesting MusicBrainz release d7354e98-1d90-4d38-ba13-42d8a6b76edf
Sending event: albuminfo_received
Candidate: Twin Wave - Twin Wave (d7354e98-1d90-4d38-ba13-42d8a6b76edf)
Computing track assignment...
...done.
Success. Distance: 0.80
Requesting MusicBrainz release 7829b196-ba83-4599-9cc2-82d01e406736
primary MB release type: ep
Sending event: albuminfo_received
Candidate: Medium Wave - The Medium Wave EP (7829b196-ba83-4599-9cc2-82d01e406736)
Computing track assignment...
...done.
Success. Distance: 0.79
Requesting MusicBrainz release e4f38eac-e66d-46cc-9f86-076e859a10ee
primary MB release type: ep
secondary MB release type(s): demo
Sending event: albuminfo_received
Candidate: The Cherry Wave - The Cherry Wave (e4f38eac-e66d-46cc-9f86-076e859a10ee)
Computing track assignment...
...done.
Success. Distance: 0.83
chroma: acoustid album candidates: 0
Evaluating 5 candidates.

/tmp/Sing_Along_With_Blue_Wave_Theory (4 items)
Sending event: before_choose_candidate
Finding tags for album "Blue Wave Theory - Sing Along With Blue Wave Theory".
Candidates:
1. Inanimus Theory - Inanimus Theory (29.9%) (tracks, artist, album, ...) (CD-R, 2011, GB)
2. Tree Wave - Tree Wave (26.4%) (tracks, album, artist, ...) (2009, US)
3. Medium Wave - The Medium Wave EP (21.1%) (tracks, artist, album, ...) (CD, 2015, GB)
4. Twin Wave - Twin Wave (20.3%) (tracks, album, artist, ...) (Digital Media, 2013)
5. The Cherry Wave - The Cherry Wave (17.4%) (tracks, artist, album, ...) (Digital Media, 2012, XW)
# selection (default 1), Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort, eDit, edit Candidates? U
Sending event: import_task_choice
0 of 4 items replaced
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
fetchart: trying source filesystem for album Blue Wave Theory - Sing Along With Blue Wave Theory
Sending event: before_item_moved
Sending event: item_moved
Sending event: database_change
Sending event: database_change
Sending event: before_item_moved
Sending event: item_moved
Sending event: database_change
Sending event: database_change
Sending event: before_item_moved
Sending event: item_moved
Sending event: database_change
Sending event: database_change
Sending event: before_item_moved
Sending event: item_moved
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: import_task_files
Sending event: album_imported
Sending event: import
Sending event: cli_exit

⏻  /tmp  » ls -al Sing_Along_With_Blue_Wave_Theory 
total 276
drwxr-x---  2 varac varac   4096 Jun 18 11:47 .
drwxrwxrwt 23 root  root  270336 Jun 18 11:47 ..
-rw-r-----  1 varac varac      3 Jun 18 11:43 leftover-file.txt

Maybe add a --remove-leftover-files parameter ?

Setup

My configuration (output of beet config) is:

directory: ~/Music
library: ~/Media/Audio/beets/musiclibrary.db
import:
    move: yes
plugins: acousticbrainz chroma edit embedart fetchart fromfilename info missing
sampsyo commented 6 years ago

Have you seen the clutter configuration option? It lets you describe which extra filenames are OK to delete when cleaning up. That might be somewhat safer than deleting all the unimported files.

If you really want to delete everything, maybe defining a very permissive pattern in clutter to match most/all files. This, of course, will need to be done carefully to avoid deleting too many files—it seems super important to have a backup if you try that (and probably test it out on a copy first).

varac commented 6 years ago

@sampsyo Thx, I wasn't aware of this config option. I'll try with this one!