krateng / maloja

Self-hosted music scrobble database to create personal listening statistics and charts
https://maloja.krateng.ch
GNU General Public License v3.0
1.12k stars 63 forks source link

Maloja always treats same artist and same title as the same track? #362

Open m7a opened 3 months ago

m7a commented 3 months ago

In #301, a user asked about the behaviour in case of the same track appearing on multiple recordings of the same artist. @krateng explained the intended behaviour as follows:

The logic is that scrobbles don't have an album at all. Scrobbles are only of a track - a track can belong to an album. So my intention is that people set up 'canonical' albums for their tracks

I think there may be cases where this is not entirely applicable. I was trying to debug what seemed to be a bug in my application and came across the following situation:

In my music collection, I have two songs called Intro both by artist Within Temptation but from different albums:

$ metaflac --list --block-type=VORBIS_COMMENT ./within_temptation_the_silent_force/01_01_intro.flac
METADATA block #2
  type: 4 (VORBIS_COMMENT)
  is last: false
  length: 425
  vendor string: reference libFLAC 1.4.2 20221022
  comments: 14
    comment[0]: ALBUM=The Silent Force
    comment[1]: ARTIST=Within Temptation
    comment[2]: CDDB=960ada0b
    comment[3]: DATE=2004
    comment[4]: REPLAYGAIN_ALBUM_GAIN=-10.42 dB
    comment[5]: REPLAYGAIN_ALBUM_PEAK=1.244907
    comment[6]: REPLAYGAIN_ALBUM_RANGE=9.68 dB
    comment[7]: REPLAYGAIN_REFERENCE_LOUDNESS=-18.00 LUFS
    comment[8]: REPLAYGAIN_TRACK_GAIN=-8.35 dB
    comment[9]: REPLAYGAIN_TRACK_PEAK=0.997551
    comment[10]: REPLAYGAIN_TRACK_RANGE=10.07 dB
    comment[11]: TITLE=Intro
    comment[12]: TRACKNUMBER=01
    comment[13]: TRACKTOTAL=11
$ metaflac --list --block-type=VORBIS_COMMENT within_temptation_mother_earth/01_08_intro.flac 
METADATA block #2
  type: 4 (VORBIS_COMMENT)
  is last: false
  length: 420
  vendor string: reference libFLAC 1.4.2 20221022
  comments: 14
    comment[0]: ALBUM=Mother Earth
    comment[1]: ARTIST=Within Temptation
    comment[2]: CDDB=ba11370e
    comment[3]: DATE=2003
    comment[4]: REPLAYGAIN_ALBUM_GAIN=-8.20 dB
    comment[5]: REPLAYGAIN_ALBUM_PEAK=1.075621
    comment[6]: REPLAYGAIN_ALBUM_RANGE=10.56 dB
    comment[7]: REPLAYGAIN_REFERENCE_LOUDNESS=-18.00 LUFS
    comment[8]: REPLAYGAIN_TRACK_GAIN=-5.18 dB
    comment[9]: REPLAYGAIN_TRACK_PEAK=0.887518
    comment[10]: REPLAYGAIN_TRACK_RANGE=1.87 dB
    comment[11]: TITLE=Intro
    comment[12]: TRACKNUMBER=08
    comment[13]: TRACKTOTAL=14

Unlike the case of “best of” or album/EP cases where the same song may appear on different recordings, in this case the track has equal title and artist but is actually entirely different.

In such cases, the correct behaviour would probably be to keep two independent counters. It would also require that it be possible to add album information to trackinfo queries via the API as to distinguish the scrobbles for the different tracks of the same name.

However, as far as I understand, there is basically no way to distinguish between these cases automatically. Could this be annotated manually somehow and Maloja extended to allow querying the distinct play counts for the different tracks? Or would it make more sense for me to edit the metadata of the songs to force them to different titles?

Currently, the following is reported when trying to query the play count (scrobbles: 6 is returned which is basically the sum of all scrobbles which have that artist/title and also it is indeed all assigned to the "first album info it has received" as indicated in your comment):

$ curl "http://127.0.0.1:42010/apis/mlj_1/trackinfo?key=NKPC[...]ZFDrQK&trackartist=Within%20Temptation&title=Intro"
{"track": {"artists": ["Within Temptation"], "title": "Intro", "album": {"artists": ["Within Temptation"], "albumtitle": "Mother Earth"}, "length": null}, "scrobbles": 6, "position": 32, "medals": {"gold": [], "silver": [], "bronze": []}, "certification": null, "topweeks": 1, "id": 4614}

related issues: #301, #320, #329

If in this case, the workaround with changing the metadata is the best course of action, I can of course live with that. Thank you very much for this program, I use it almost on a daily basis and it works quite well for me :smile:

ComicMango commented 1 week ago

I hope we can get some form of album distinction eventually. I have another use case: this band I listen to just released a commemoration EP with new arrangements of some old songs, so they have the same titles but sound vastly different. I'll like to be able to track the new EP and the original album as separate counts. I also modify the database as a workaround at the moment, but it seems that play counts cannot be separate even if after modifying.