Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mopidy tracks are not being scrobbled correctly to Maloja #110

Closed
disi33 opened this issue Nov 29, 2023 · 8 comments
Closed

Mopidy tracks are not being scrobbled correctly to Maloja #110

disi33 opened this issue Nov 29, 2023 · 8 comments

Comments

@disi33
Copy link

disi33 commented Nov 29, 2023

Describe the bug
I just created the following setup:

  • A Multi-Scrobbler instance with 3 sources {Mopidy, Spotify, Subsonic (via Navidrome)} and configured to be a client for my Maloja instance.
  • A Maloja instance to send the scrobble events to.

Now when I listen to a song via Mopidy, I do see the multi-scrobbler Mopidy integration kicking in and attempting to scrobble the track, however, it is failing with an Internal Server Error at Maloja.

This is the error log from my multi-scrobbler instance:

2023-11-29T14:16:27-08:00 error   : [Scrobblers] [Maloja - unnamed-mlj] Error occurred while trying to scrobble
ErrorWithCause: 
    at f.doProcessing (CWD/build/server.js:1:45384)
    at async f.startScrobbling (CWD/build/server.js:1:42180)
    at async f.initScrobbleMonitoring (CWD/build/server.js:1:41708)

caused by: Error: Internal Server Error
    at Request.callback (CWD/node_modules/superagent/lib/node/index.js:845:17)
    at CWD/node_modules/superagent/lib/node/index.js:1070:18
    at IncomingMessage.<anonymous> (CWD/node_modules/superagent/lib/node/parsers/json.js:21:7)
    at IncomingMessage.emit (node:events:529:35)
    at endReadableNT (node:internal/streams/readable:1368:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
2023-11-29T14:16:27-08:00 error   : [Scrobblers] [Maloja - unnamed-mlj] Scrobble processing interrupted
2023-11-29T14:16:27-08:00 error   : [Scrobblers] [Maloja - unnamed-mlj] Scrobble Error (New) {"payload":{"album":"Stonehenge","albumartists":[{"__model__":"Artist","name":"<artistname>","uri":"spotify:artist:ABCDEFG123456"}],"artists":["<artistname>"],"duration":231,"key":"OvT2rbda3YjgRrGb4cjm0CcX7BPiATiU9TrYYoeOTiCs6Aqe4bYPyCtAlUy5jn","length":234,"time":1701294125,"title":"<title>"},"playInfo":"<artistname> - <title>@ 2023-11-29T13:42:05-08:00"}
2023-11-29T14:16:27-08:00 error   : [Scrobblers] [Maloja - unnamed-mlj] API Call failed: Server Response => Internal Server Error {"response":{"error":{"desc":"The server has encountered an exception.","type":"unknown_error","value":"AttributeError(\"'dict' object has no attribute 'strip'\")"},"status":"failure"},"status":500}

This is the error log from my Maloja instance:

[database] Incoming scrobble [Client: multi-scrobbler | API: native/v1]: {'track_artists': ['<artistname>'], 'track_title': '<trackname>', 'album_title': '<albumname>', 'album_artists': [{'__model__': 'Artist', 'uri': 'spotify:artist:ABCDEFG123456', 'name': '<artistname>'}], 'scrobble_duration': 231, 'track_length': 234, 'scrobble_time': 1701294125}
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/maloja/apis/native_v1.py", line 109, in protector
    return func(*args,**kwargs)
  File "/usr/lib/python3.10/site-packages/maloja/apis/native_v1.py", line 614, in post_scrobble
    result = database.incoming_scrobble(
  File "/usr/lib/python3.10/site-packages/maloja/database/__init__.py", line 110, in incoming_scrobble
    scrobbledict = rawscrobble_to_scrobbledict(rawscrobble, fix, client)
  File "/usr/lib/python3.10/site-packages/maloja/database/__init__.py", line 157, in rawscrobble_to_scrobbledict
    scrobbleinfo['album_artists'] = cla.parseArtists(scrobbleinfo['album_artists'])
  File "/usr/lib/python3.10/site-packages/maloja/cleanup.py", line 87, in parseArtists
    res = [self.parseArtists(art) for art in a]
  File "/usr/lib/python3.10/site-packages/maloja/cleanup.py", line 87, in <listcomp>
    res = [self.parseArtists(art) for art in a]
  File "/usr/lib/python3.10/site-packages/maloja/cleanup.py", line 90, in parseArtists
    if a.strip() in malojaconfig["INVALID_ARTISTS"]:
AttributeError: 'dict' object has no attribute 'strip'

I believe the issue lies within the formatting of the payload that multi-scrobbler is sending to Maloja.
Notice how the data of the album_artists property seems to be a list of dicts:
"albumartists":[{"__model__":"Artist","name":"<artistname>","uri":"spotify:artist:ABCDEFG123456"}]

The respective code within Maloja that is responsible for parsing/sanitizing this data does not seem to be equipped to handle this case:
cleanup.py

multi-scrobbler version used: v0.6.2
Maloja version used: v3.2.1

To Reproduce
Set up an environment as described above.

Expected behavior
I would expect this data to be properly sanitized into a format that Maloja is expecting. The Maloja API specification is defined here,

Logs
See log snippets above.

Versions (please complete the following information):
Provide version information for any related sources/clients.

  • multi-scrobbler: v0.6.2 on docker via Unraid
  • maloja: v3.2.1 on docker via Unraid
  • Mopidy: 3.69.2 running bare metal on a separate machine

Additional context
Additionally, during my I noticed that even when I try to blacklist spotify URIs from being scrobbled through Mopidy using the configuration below, multi-scrobbler still attempts to scrobble any track listened to via the Mopidy-Spotify integration. Not sure if this issue is related.

[
  {
    "name": "MyMopidy",
    "enable": true,
    "data": {
      "url": "ws://mopidy.local:6680/mopidy/ws",
      "uriBlacklist": ["spotify"],
      "uriWhitelist": [],
      "albumBlacklist": []
    }
  }
]
@FoxxMD
Copy link
Owner

FoxxMD commented Nov 30, 2023

Thanks for the detailed info.

{"payload":{"album":"Stonehenge","albumartists":[{"__model__":"Artist","name":"<artistname>","uri":"spotify:artist:ABCDEFG123456"}],"artists":["<artistname>"],"duration":231,"key":"OvT2rbda3YjgRrGb4cjm0CcX7BPiATiU9TrYYoeOTiCs6Aqe4bYPyCtAlUy5jn","length":234,"time":1701294125,"title":"<title>"},"playInfo":"<artistname> - <title>@ 2023-11-29T13:42:05-08:00"}

Did you replace any of this info (EX substituting <artistname> for a real artist?) or is this exactly as it was in the log?

@disi33
Copy link
Author

disi33 commented Nov 30, 2023

I replaced that information, I just didn't want for the exact details what I was listening to to distract from the issue at hand 😂
In the logs themselves that data shows as the actual track/artist/album name and track URL, etc.

@disi33 disi33 changed the title Spotify tracks are not being scrobbled correctly to Maloja Mopidy tracks are not being scrobbled correctly to Maloja Nov 30, 2023
@disi33
Copy link
Author

disi33 commented Nov 30, 2023

Also, to avoid confusion, I noticed the issue title says "Spotify tracks", when it should actually day "Mopidy tracks". It was already late at night fore when I created it andust have gotten it wrong.

I edited the title to reflect the correct service.

FoxxMD added a commit that referenced this issue Nov 30, 2023
Should be using mapped artist string name rather than model but cannot test due to mopidy being difficult. Hopefully this works?
@FoxxMD
Copy link
Owner

FoxxMD commented Nov 30, 2023

I'll be honest mopidy has been the most infuriating application to setup I've ever had the displeasure of working with. I run arch linux, docker, virtual machines, the works. I've debugged esoteric java webapplets that were easier to figure out than mopidy. So far mopidy, native, has failed to work with pulseaudio or pipewire. It doesn't work in docker with three different iris/built-in implementations I've tried. It worked at some point in the past but I spent the last 3 hours trying to get anything to play with constant errors.

I'm using the official mopidy js implementation and have made a change that may fix your issue but i cannot test it myself. Please use foxxmd/multi-scrobbler:develop docker image and let me know if that resolves things for you .

@FoxxMD
Copy link
Owner

FoxxMD commented Dec 6, 2023

@disi33 have you had a chance to test this?

@disi33
Copy link
Author

disi33 commented Dec 6, 2023

Thank you for addressing this, very much appreciated!
Apologies, life kind of got in the way, I will try to confirm the fix in the next few days!

@disi33
Copy link
Author

disi33 commented Dec 18, 2023

hey @FoxxMD apologies again for the long wait - of course my homelab server died!
I was just recently able to recover the server and I can confirm with your fix in the :develop image everything works like a charm!

Thanks for looking into this - very much appreciated! And sorry again for leaving you hanging there for a while!

@FoxxMD
Copy link
Owner

FoxxMD commented Jan 10, 2024

Fixed in 0.6.3

@FoxxMD FoxxMD closed this as completed Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants