beetbox / beets

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

info: Select specific fields #1287

Closed randybias closed 9 years ago

randybias commented 9 years ago

Right now beet info spews all tags, but it should have an option for pulling a single key/value, like so:

$ beet info -k acoustid_id "05 Le Freak.aiff" 616e1881-cb7e-4d9f-9988-fa2b546c7085

This is useful if you wanted to do a multi-step operation cleanly from the command line.

Here is the bash script I am using to get around this right now:

!/usr/bin/env bash

FILE=$1

if [ -z "$FILE" ]; then echo "need filename" exit 0 fi

beet info "$FILE" | grep acoustid_id | sed -e 's/^ *acoustid_id: //g'

sampsyo commented 9 years ago

How about:

$ beet ls -f '$acoustid_id' './05 Le Freak.aiff'

Unless, of course, you're interested in inspecting files that aren't in your library. In that case, sure, this seems like a fine addition.

randybias commented 9 years ago

OK, that works. A bit unwieldy, but doable. Seems like this should exist in the info plugin though, not in ls. Although arguably those two should be collapsed. beet info is more like a verbose ls.

randybias commented 9 years ago

and yes, using it on something not in the library is definitely useful. I didn't know I could do that, but now that I know, I'm definitely going to use the hell out of that feature. I think this is the first CLI tool I've seen that cleanly reads a bunch of different file formats for tags...

sampsyo commented 9 years ago

OK, sounds good. Let's make this a feature request.

Somehow merging info's functionality with list is an interesting long-term goal (but is not part of this ticket).

randybias commented 9 years ago

Makes sense to me.

Freso commented 9 years ago

I think a mix of grep and beet ls is sufficient for this. Let's not go into unnecessary feature/option bloating when it's already perfectly doable with standard tools. :/

I think this is the first CLI tool I've seen that cleanly reads a bunch of different file formats for tags...

I've taken to using mutagen-inspect (which should be shipped with Mutagen that is the library powering beets (and MusicBrainz Picard and others), so you should have it) for this. Mostly because it is more likely to be on all my machines.

sampsyo commented 9 years ago

Yeah, beet info | grep field should work fine for most cases. We do have a solid implementation already available, though, so I don't think there's too much harm in adding it.

geigerzaehler commented 9 years ago

I think a mix of grep and beet ls is sufficient for this. Let's not go into unnecessary feature/option bloating when it's already perfectly doable with standard tools. :/

If this was an isolated use-case I would agree. But I think that, over time, info should evolve into a flexible tool that produces easily consumable data—JSON for example. With that in mind the feature is, in my oppinion, elementary.