beetbox/beets

Beet list path not returning all files

Closed this issue · 4 comments

Running beet list with a path query sometimes returns zero results, or only a subset of tracks present under that directory.

Problem

Listing tracks in the ~/Music/AC_DC/ directory:

$ beet -vv list -p path:~/Music/AC_DC/

Returned this output:

user configuration: /var/home/berwyn/.config/beets/config.yaml
data directory: /var/home/berwyn/.config/beets
plugin paths: 
Sending event: pluginload
library database: /var/home/berwyn/Documents/Music/musiclibrary.db
library directory: /var/home/berwyn/Music
Sending event: library_opened
/var/home/berwyn/Music/AC_DC/The Razors Edge/01 Thunderstruck.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/02 Fire Your Guns.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/03 Moneytalks.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/04 The Razors Edge.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/05 Mistress for Christmas.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/06 Rock Your Heart Out.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/07 Are You Ready.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/08 Got You by the Balls.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/09 Shot of Love.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/10 Let's Make It.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/11 Goodbye & Good Riddance to Bad Luck.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/12 If You Dare.flac
Sending event: cli_exit

Whereas, searching for AC/DC:

$ beet -vv list -p AC/DC

Returned:

user configuration: /var/home/berwyn/.config/beets/config.yaml
data directory: /var/home/berwyn/.config/beets
plugin paths: 
Sending event: pluginload
library database: /var/home/berwyn/Documents/Music/musiclibrary.db
library directory: /var/home/berwyn/Music
Sending event: library_opened
/home/berwyn/Music/AC_DC/Back in Black/01 Hells Bells.flac
/home/berwyn/Music/AC_DC/Back in Black/02 Shoot to Thrill.flac
/home/berwyn/Music/AC_DC/Back in Black/03 What Do You Do for Money Honey.flac
/home/berwyn/Music/AC_DC/Back in Black/04 Given the Dog a Bone.flac
/home/berwyn/Music/AC_DC/Back in Black/05 Let Me Put My Love Into You.flac
/home/berwyn/Music/AC_DC/Back in Black/06 Back in Black.flac
/home/berwyn/Music/AC_DC/Back in Black/07 You Shook Me All Night Long.flac
/home/berwyn/Music/AC_DC/Back in Black/08 Have a Drink on Me.flac
/home/berwyn/Music/AC_DC/Back in Black/09 Shake a Leg.flac
/home/berwyn/Music/AC_DC/Back in Black/10 Rock and Roll Ain’t Noise Pollution.flac
/home/berwyn/Music/AC_DC/High Voltage/01 It’s a Long Way to the Top (If You Wanna Rock ’n’ Roll).flac
/home/berwyn/Music/AC_DC/High Voltage/02 Rock ’n’ Roll Singer.flac
/home/berwyn/Music/AC_DC/High Voltage/03 The Jack.flac
/home/berwyn/Music/AC_DC/High Voltage/04 Live Wire.flac
/home/berwyn/Music/AC_DC/High Voltage/05 T.N.T_.flac
/home/berwyn/Music/AC_DC/High Voltage/06 Can I Sit Next to You Girl.flac
/home/berwyn/Music/AC_DC/High Voltage/07 Little Lover.flac
/home/berwyn/Music/AC_DC/High Voltage/08 She’s Got Balls.flac
/home/berwyn/Music/AC_DC/High Voltage/09 High Voltage.flac
/home/berwyn/Music/AC_DC/Highway to Hell/01 Highway to Hell.flac
/home/berwyn/Music/AC_DC/Highway to Hell/02 Girls Got Rhythm.flac
/home/berwyn/Music/AC_DC/Highway to Hell/03 Walk All Over You.flac
/home/berwyn/Music/AC_DC/Highway to Hell/04 Touch Too Much.flac
/home/berwyn/Music/AC_DC/Highway to Hell/05 Beating Around the Bush.flac
/home/berwyn/Music/AC_DC/Highway to Hell/06 Shot Down in Flames.flac
/home/berwyn/Music/AC_DC/Highway to Hell/07 Get It Hot.flac
/home/berwyn/Music/AC_DC/Highway to Hell/08 If You Want Blood (You've Got It).flac
/home/berwyn/Music/AC_DC/Highway to Hell/09 Love Hungry Man.flac
/home/berwyn/Music/AC_DC/Highway to Hell/10 Night Prowler.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/01 Thunderstruck.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/02 Fire Your Guns.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/03 Moneytalks.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/04 The Razors Edge.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/05 Mistress for Christmas.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/06 Rock Your Heart Out.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/07 Are You Ready.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/08 Got You by the Balls.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/09 Shot of Love.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/10 Let's Make It.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/11 Goodbye & Good Riddance to Bad Luck.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/12 If You Dare.flac
Sending event: cli_exit

Similarly, trying an artist with a space in their directory name returns no results:

$ beet -vv list -p path:~/Music/Eternal\ Champion/
user configuration: /var/home/berwyn/.config/beets/config.yaml
data directory: /var/home/berwyn/.config/beets
plugin paths: 
Sending event: pluginload
library database: /var/home/berwyn/Documents/Music/musiclibrary.db
library directory: /var/home/berwyn/Music
Sending event: library_opened
Sending event: cli_exit

Whereas, searching via the artist name returns all of their tracks in my library:

$ beet -vv list -p Eternal Champion
user configuration: /var/home/berwyn/.config/beets/config.yaml
data directory: /var/home/berwyn/.config/beets
plugin paths: 
Sending event: pluginload
library database: /var/home/berwyn/Documents/Music/musiclibrary.db
library directory: /var/home/berwyn/Music
Sending event: library_opened
/home/berwyn/Music/Eternal Champion/Ravening Iron/01 A Face in the Glare.flac
/home/berwyn/Music/Eternal Champion/Ravening Iron/02 Ravening Iron.flac
/home/berwyn/Music/Eternal Champion/Ravening Iron/03 Skullseeker.flac
/home/berwyn/Music/Eternal Champion/Ravening Iron/04 War at the Edge of the End.flac
/home/berwyn/Music/Eternal Champion/Ravening Iron/05 Coward’s Keep.flac
/home/berwyn/Music/Eternal Champion/Ravening Iron/06 Worms of the Earth.flac
/home/berwyn/Music/Eternal Champion/Ravening Iron/07 The Godblade.flac
/home/berwyn/Music/Eternal Champion/Ravening Iron/08 Banners of Arhai.flac
/home/berwyn/Music/Eternal Champion/Ride for Revenge _ Retaliator/01 Ride for Revenge _ Retaliator.flac
/home/berwyn/Music/Compilations/Swords of Steel Sampler/04 The Last King of Pictdom.flac
/home/berwyn/Music/Eternal Champion/Terminus Est/01 Court of the Autarch.flac
/home/berwyn/Music/Eternal Champion/Terminus Est/02 Flight Over the Battle at Orythia.flac
/home/berwyn/Music/Eternal Champion/The Armor of Ire/01 I Am the Hammer.flac
/home/berwyn/Music/Eternal Champion/The Armor of Ire/02 The Armor of Ire.flac
/home/berwyn/Music/Eternal Champion/The Armor of Ire/03 The Last King of Pictdom.flac
/home/berwyn/Music/Eternal Champion/The Armor of Ire/04 Blood Ice.flac
/home/berwyn/Music/Eternal Champion/The Armor of Ire/05 The Cold Sword.flac
/home/berwyn/Music/Eternal Champion/The Armor of Ire/06 Invoker.flac
/home/berwyn/Music/Eternal Champion/The Armor of Ire/07 Sing a Last Song of Valdese.flac
/home/berwyn/Music/Eternal Champion/The Armor of Ire/08 Shade Gate.flac
Sending event: cli_exit

Setup

  • OS: Fedora Silverblue 39
  • Python version: 3.12.6
  • beets version: 1.6.0
  • Turning off plugins made problem go away (yes/no): No

My configuration (output of beet config) is:

directory: ~/Music
library: ~/Documents/Music/musiclibrary.db

import:
    move: yes

plugins:
- mbsync
- replaygain
- check
- extrafiles
- scrub
replaygain:
    backend: ffmpeg
    overwrite: yes
    auto: yes
    per_disc: yes
    threads: 16
    parallel_on_import: no
    peak: 'true'
    targetlevel: 89
    r128: [Opus]
    r128_targetlevel: 84
extrafiles:
    patterns:
        all: '*.*'

    paths: {}
threaded: yes

check:

    import: yes
    write-check: yes
    write-update: yes
    integrity: yes
    convert-update: yes
    threads: 16
    external:
        mp3val:
            cmdline: mp3val {0}
            formats: MP3
            error: '^WARNING: .* \(offset 0x[0-9a-f]+\): (.*)$'
            fix: mp3val -nb -f {0}
        flac:
            cmdline: flac --test --silent {0}
            formats: FLAC
            error: '^.*: ERROR,? (.*)$'
        oggz-validate:
            cmdline: oggz-validate {0}
            formats: OGG
scrub:
    auto: yes

/home/berwyn/Music/AC_DC/Back in Black/01 Hells Bells.flac
/home/berwyn/Music/AC_DC/Back in Black/02 Shoot to Thrill.flac
/home/berwyn/Music/AC_DC/Back in Black/03 What Do You Do for Money Honey.flac
/home/berwyn/Music/AC_DC/Back in Black/04 Given the Dog a Bone.flac
/home/berwyn/Music/AC_DC/Back in Black/05 Let Me Put My Love Into You.flac
/home/berwyn/Music/AC_DC/Back in Black/06 Back in Black.flac
/home/berwyn/Music/AC_DC/Back in Black/07 You Shook Me All Night Long.flac
/home/berwyn/Music/AC_DC/Back in Black/08 Have a Drink on Me.flac
/home/berwyn/Music/AC_DC/Back in Black/09 Shake a Leg.flac
/home/berwyn/Music/AC_DC/Back in Black/10 Rock and Roll Ain’t Noise Pollution.flac
/home/berwyn/Music/AC_DC/High Voltage/01 It’s a Long Way to the Top (If You Wanna Rock ’n’ Roll).flac
/home/berwyn/Music/AC_DC/High Voltage/02 Rock ’n’ Roll Singer.flac
/home/berwyn/Music/AC_DC/High Voltage/03 The Jack.flac
/home/berwyn/Music/AC_DC/High Voltage/04 Live Wire.flac
/home/berwyn/Music/AC_DC/High Voltage/05 T.N.T_.flac
/home/berwyn/Music/AC_DC/High Voltage/06 Can I Sit Next to You Girl.flac
/home/berwyn/Music/AC_DC/High Voltage/07 Little Lover.flac
/home/berwyn/Music/AC_DC/High Voltage/08 She’s Got Balls.flac
/home/berwyn/Music/AC_DC/High Voltage/09 High Voltage.flac
/home/berwyn/Music/AC_DC/Highway to Hell/01 Highway to Hell.flac
/home/berwyn/Music/AC_DC/Highway to Hell/02 Girls Got Rhythm.flac
/home/berwyn/Music/AC_DC/Highway to Hell/03 Walk All Over You.flac
/home/berwyn/Music/AC_DC/Highway to Hell/04 Touch Too Much.flac
/home/berwyn/Music/AC_DC/Highway to Hell/05 Beating Around the Bush.flac
/home/berwyn/Music/AC_DC/Highway to Hell/06 Shot Down in Flames.flac
/home/berwyn/Music/AC_DC/Highway to Hell/07 Get It Hot.flac
/home/berwyn/Music/AC_DC/Highway to Hell/08 If You Want Blood (You've Got It).flac
/home/berwyn/Music/AC_DC/Highway to Hell/09 Love Hungry Man.flac
/home/berwyn/Music/AC_DC/Highway to Hell/10 Night Prowler.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/01 Thunderstruck.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/02 Fire Your Guns.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/03 Moneytalks.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/04 The Razors Edge.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/05 Mistress for Christmas.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/06 Rock Your Heart Out.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/07 Are You Ready.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/08 Got You by the Balls.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/09 Shot of Love.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/10 Let's Make It.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/11 Goodbye & Good Riddance to Bad Luck.flac
/var/home/berwyn/Music/AC_DC/The Razors Edge/12 If You Dare.flac
Sending event: cli_exit

I noticed you've got two different root paths for the files in your library:

/home/berwyn/Music/ AC_DC/Highway to Hell/10 Night Prowler.flac
/var/home/berwyn/Music/ AC_DC/The Razors Edge/01 Thunderstruck.flac

How come? For some reason it seems like your commands only return paths that start with /var/home/berwyn/Music.

Oh, a brilliant catch!

Fedora Silverblue houses the home directory at /var/home instead of /home. I started using beets years ago on a Linux distribution with standard paths, but moved over to Silverblue some time later, probably why there's a mix of paths. I always pass paths to beets as ~/Music, so hadn't spotted the difference.

Judging by that, I assume that beets is actually checking file paths from its database, rather than where they're physically located on the filesystem? All of those files are currently stored under /var/home, regardless of where they're reported as being by beet list.

How would I go about rectifying that in beets? Would updating paths in the SQLite database directly work, or is there a command that I could run?

Thank you for the help!

How would I go about rectifying that in beets? Would updating paths in the SQLite database directly work, or is there a command that I could run?

The paths are stored as BLOBs in the database, which makes direct modifications somewhat challenging to perform correctly.

You may want to try to do something like this in Python:

import os
from beets.library import Library


l = Library(path=os.path.expanduser(b"~/.music/beets/library.db"))

# filter out items that have the correct root path
for item in l.items("-path::/var/home"):
    # add the correct prefix
    item.path = b"/var" + item.path
    # save
    item.store()

The paths are stored as BLOBs in the database, which makes direct modifications somewhat challenging to perform correctly.

You may want to try to do something like this in Python:

That script seems to have done it, thank you so much! I've never done any programming in Python before, so would have been stuck without your suggestion; at least for quite some time.

I'll close this now as the problem is obviously not in beets, but with my particular circumstances.