Uploaded image for project: 'ListenBrainz'
  1. ListenBrainz
  2. LB-1689

LastFM loved tracks imports does not import all tracks

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Normal Normal
    • None
    • None
    • None

      This was reported by a user on the forum: https://community.metabrainz.org/t/incomplete-last-fm-import-and-wrong-last-import-timestamp/602464/14

      Running the manual loved tracks import from LFM, only 23 out of 50 loved tracks are imported in LB, consistently across multiple tries, with no message explaining why the others are not.

      Reading the code and testing with real data from one of those users, it looks like LastFM will send indiscriminately either a track mbid or a recording mbid or null in the `mbid` field for each track.

      We currently only check if that value corresponds to a track mbid (the way LastFM used to do it) but do not check if it is potentially a valid recording MBID.

      Not sure when LastFM changed which data they send, but we should support both track and recording MBIDs in https://github.com/metabrainz/listenbrainz-server/blob/e633229ce3cc08da8b53134fa988fd3e51d9bfb0/listenbrainz/domain/lastfm.py#L38C5-L53

      Example two first tracks of a real LastFM API response for a real user's loved tracks:

      Note the mbids `3a27a9b9-970a-4380-8f6a-26d50ca15b94` and `5d4fe2b2-76e2-4dc4-8ade-63d8e9adeac2`, one for a track (https://musicbrainz.org/track/3a27a9b9-970a-4380-8f6a-26d50ca15b94) and the other for a recording (https://musicbrainz.org/recording/5d4fe2b2-76e2-4dc4-8ade-63d8e9adeac2)

      {
        "artist": {
          "url": "https://www.last.fm/music/Black+Honey",
          "name": "Black Honey",
          "mbid": "73b97be0-b449-4de7-ab40-959791974dc1"
        },
        "date": {
          "uts": "1614802764",
          "#text": "03 Mar 2021, 20:19"
        },
        "mbid": "3a27a9b9-970a-4380-8f6a-26d50ca15b94",
        "url": "https://www.last.fm/music/Black+Honey/_/Madonna",
        "name": "Madonna",
        "image": [
          {
            "size": "small",
            "#text": "https://lastfm.freetls.fastly.net/i/u/34s/2a96cbd8b46e442fc41c2b86b821562f.png"
          },
          {
            "size": "medium",
            "#text": "https://lastfm.freetls.fastly.net/i/u/64s/2a96cbd8b46e442fc41c2b86b821562f.png"
          },
          {
            "size": "large",
            "#text": "https://lastfm.freetls.fastly.net/i/u/174s/2a96cbd8b46e442fc41c2b86b821562f.png"
          },
          {
            "size": "extralarge",
            "#text": "https://lastfm.freetls.fastly.net/i/u/300x300/2a96cbd8b46e442fc41c2b86b821562f.png"
          }
        ],
        "streamable": {
          "fulltrack": "0",
          "#text": "0"
        }
      },
      {
        "artist": {
          "url": "https://www.last.fm/music/Placebo",
          "name": "Placebo",
          "mbid": ""
        },
        "date": {
          "uts": "1603725067",
          "#text": "26 Oct 2020, 15:11"
        },
        "mbid": "5d4fe2b2-76e2-4dc4-8ade-63d8e9adeac2",
        "url": "https://www.last.fm/music/Placebo/_/The+Bitter+End",
        "name": "The Bitter End",
        "image": [
          {
            "size": "small",
            "#text": "https://lastfm.freetls.fastly.net/i/u/34s/2a96cbd8b46e442fc41c2b86b821562f.png"
          },
          {
            "size": "medium",
            "#text": "https://lastfm.freetls.fastly.net/i/u/64s/2a96cbd8b46e442fc41c2b86b821562f.png"
          },
          {
            "size": "large",
            "#text": "https://lastfm.freetls.fastly.net/i/u/174s/2a96cbd8b46e442fc41c2b86b821562f.png"
          },
          {
            "size": "extralarge",
            "#text": "https://lastfm.freetls.fastly.net/i/u/300x300/2a96cbd8b46e442fc41c2b86b821562f.png"
          }
        ],
        "streamable": {
          "fulltrack": "0",
          "#text": "0"
        }
      }, 

            kartik1712 amCap1712
            mr_monkey Monkey
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Version Package