Serene-Arc / listenbrainz-playlist-uploader

A program to upload playlists to Listenbrainz and give feedback in bulk
MIT License
4 stars 0 forks source link

wrong tracks are added to playlist due to beets tagging being weird #5

Open quantenzitrone opened 2 weeks ago

quantenzitrone commented 2 weeks ago

I have this track in my playlist: https://musicbrainz.org/recording/aba4484f-1bc3-498f-a6c3-61a470954b27 but listenbrainz-playlist-uploader added this track: https://musicbrainz.org/recording/6547a8bd-3347-4335-9ccc-a5df930ac02f

now the tags on that tracks are a bit weird, but thats how beets tagged it:

$ mid3v2 Billie\ Eilish/Tracks/Limbo.mp3
IDv2 tag info for Billie Eilish/Tracks/Limbo.mp3
COMM=iTunNORM=eng= 000006E2 000006E2 00001135 00001135 00000000 00000000 00008000 00008000 00000000 00000000
TALB=Unreleased
TBPM=0
TCMP=0
TDOR=0000
TDRC=0000
TIPL=[unrepresentable data]
TIT2=Limbo
TPE1=Billie Eilish
TPE2=Billie Eilish
TPOS=0/0
TRCK=0/0
TSOP=Eilish, Billie
TXXX=ARTISTS=Billie Eilish
TXXX=ARTISTS_CREDIT=Billie Eilish
TXXX=ARTISTS_SORT=Eilish, Billie
TXXX=Acoustid Fingerprint=[...]
TXXX=Acoustid Id=0bdb2916-304b-4a0a-bd87-be9c475a54ad
TXXX=Artist Credit=Billie Eilish
TXXX=MusicBrainz Artist Id=f4abc0b5-3f7a-4eff-8f78-ac078dbce533
TXXX=REPLAYGAIN_ALBUM_GAIN=-2.46 dB
TXXX=REPLAYGAIN_ALBUM_PEAK=1.000000
TXXX=REPLAYGAIN_TRACK_GAIN=-2.46 dB
TXXX=REPLAYGAIN_TRACK_PEAK=1.000000
UFID=http://musicbrainz.org=b'aba4484f-1bc3-498f-a6c3-61a470954b27'
USLT==XXX=[...]

as you see for whatever reason beets stored the musicbrainz recording id like this:

UFID=http://musicbrainz.org=b'aba4484f-1bc3-498f-a6c3-61a470954b27'

I'm not sure if this is a beets bug, but beets seems to save the recording id like that on all mp3 files:

$ mid3v2 "./Alasen/Singles/abyss (vip) [2015].mp3"
IDv2 tag info for ./Alasen/Singles/abyss (vip) [2015].mp3
APIC=cover front,  (image/jpeg, 81507 bytes)
TALB=abyss (vip)
TBPM=0
TCMP=0
TDOR=2015-09-22
TDRC=2015-09-22
TIPL=[unrepresentable data]
TIT2=abyss (vip)
TLAN=eng
TMED=Digital Media
TPE1=Alasen
TPE2=Alasen
TPOS=1/1
TRCK=1/1
TSOP=Alasen
TXXX=ALBUMARTISTS=Alasen
TXXX=ALBUMARTISTSORT=Alasen
TXXX=ALBUMARTISTS_CREDIT=Alasen
TXXX=ALBUMARTISTS_SORT=Alasen
TXXX=ALBUM_ARTISTS=Alasen
TXXX=ARTISTS=Alasen
TXXX=ARTISTS_CREDIT=alasen
TXXX=ARTISTS_SORT=Alasen
TXXX=Acoustid Fingerprint=[...]
TXXX=Acoustid Id=e44f23c5-cf6d-4455-9834-40a94995496e
TXXX=Album Artist Credit=Alasen
TXXX=Artist Credit=alasen
TXXX=MusicBrainz Album Artist Id=b4ee0784-41fe-4055-944d-c62dd4b52e2c
TXXX=MusicBrainz Album Id=5554f9a1-83fe-4be1-8fbb-c708816ab164
TXXX=MusicBrainz Album Release Country=XW
TXXX=MusicBrainz Album Status=Official
TXXX=MusicBrainz Album Type=single
TXXX=MusicBrainz Artist Id=b4ee0784-41fe-4055-944d-c62dd4b52e2c
TXXX=MusicBrainz Release Group Id=804732af-3628-4b76-8b4e-bda7b95077b5
TXXX=MusicBrainz Release Track Id=7007e11c-81b9-4b8b-b7f1-2f5c9e546d9b
TXXX=Script=Latn
UFID=http://musicbrainz.org=b'dd56694b-e4a6-4021-acce-2a662fb44ff2'
USLT==XXX=
Serene-Arc commented 2 weeks ago

I'm a maintainer on beets so if you think there's a bug in beets, please do submit a bug report! We'll get to it sooner or later. I don't think this one is related to this tool, or something we can fix here. There's no other way to find out what the song is without resorting to looking up the song via artist and song. Maybe we could add a CLI option to disable the MBID lookup?

Actually the UFID isn't a field I recognise here. My tool reads, and beets writes to, this part:

TXXX=MusicBrainz Release Track Id=7007e11c-81b9-4b8b-b7f1-2f5c9e546d9b

It's possible that the UFID field isn't what beets is writing, it might be left over from your source files. I'm not sure.

quantenzitrone commented 1 week ago

beets is definitely writing UFID, and it seems to happen in the mediafile library:

https://github.com/beetbox/mediafile/blob/6accdc4c4a7fe4d808b674a97fb5474e12621504/mediafile.py#L866-L877

class MP3UFIDStorageStyle(MP3StorageStyle):
    """Store string data in a UFID ID3 frame with a particular owner.
    """
    def __init__(self, owner, **kwargs):
        self.owner = owner
        super(MP3UFIDStorageStyle, self).__init__('UFID:' + owner, **kwargs)

    def fetch(self, mutagen_file):
        try:
            return mutagen_file[self.key].data
        except KeyError:
            return None

https://github.com/beetbox/mediafile/blob/6accdc4c4a7fe4d808b674a97fb5474e12621504/mediafile.py#L2139-L2145

# MusicBrainz IDs.
mb_trackid = MediaField(
    MP3UFIDStorageStyle(owner='http://musicbrainz.org'),
    MP4StorageStyle('----:com.apple.iTunes:MusicBrainz Track Id'),
    StorageStyle('MUSICBRAINZ_TRACKID'),
    ASFStorageStyle('MusicBrainz/Track Id'),
)

this seems intentional to me

quantenzitrone commented 1 week ago
TXXX=MusicBrainz Release Track Id=7007e11c-81b9-4b8b-b7f1-2f5c9e546d9b

Release Track ID (ID of track in release e.g.) is not the same as Track ID (ID of Recording e.g.)

Serene-Arc commented 1 week ago

Sorry, I got that wrong.

https://github.com/Serene-Arc/listenbrainz-playlist-uploader/blob/bc8deac64321ad2f5e989131df98bffe5d840402/src/audio_data.rs#L160

This is the line that I use to search for the MBID in the metadata, so based on the sample you've provided, it's not actually reading the metadata at all for the MBID. What my tool is doing is searching for the artist and song title and then matching it to the first result, which is likely to be wrong!

This is something that can be fixed by looking for another tag. ~Also, could you make a bug report in mediafile? That URL is malformed regardless so that's a bug we (the beets maintainers) should fix in that project.~ EDIT: nevermind you already did! Thank you :)