Skip to content

Instantly share code, notes, and snippets.

@aszlig
Created October 5, 2019 10:41
Show Gist options
  • Save aszlig/93f571056041ccf7bbd3bbd0fd020809 to your computer and use it in GitHub Desktop.
Save aszlig/93f571056041ccf7bbd3bbd0fd020809 to your computer and use it in GitHub Desktop.
item_fields:
has_albums: |
import gc
from beets import library
from beetsplug.convert import _fs_lock # Abuse the lock for our purpose
with _fs_lock:
if not hasattr(library, '_artists_with_albums'):
libs = [l for l in gc.get_objects()
if isinstance(l, library.Library)]
if len(libs) != 1:
raise Exception('No unique global Library instance found.')
library._artists_with_albums = set()
for result in libs[0].albums('album:'):
artist_value = result.get('albumartist')
if artist_value:
library._artists_with_albums.add(artist_value)
return artist in library._artists_with_albums
paths:
default: $albumartist/$album%aunique{}/$track. $title
singleton: %if{$has_albums,$artist/Non-Album/$title,Non-Album/$artist/$title}
comp: Compilations/$album%aunique{}/$track. $title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment