@@ -74,8 +74,21 @@ export interface AdditionalTrackInfoResponse extends AdditionalTrackInfo {
7474 recording_msid ?: string
7575}
7676
77+ // using submit-listens example from openapi https://rain0r.github.io/listenbrainz-openapi/index.html#/lbCore/submitListens
78+ // which is documented in official docs https://listenbrainz.readthedocs.io/en/latest/users/api/index.html#openapi-specification
79+ // and based on this LZ developer comment https://github.com/lyarenei/jellyfin-plugin-listenbrainz/issues/10#issuecomment-1253867941
80+ export interface SubmitListenAdditionalTrackInfo extends AdditionalTrackInfo {
81+ artist_names ?: string [ ]
82+ release_artist_name ?: string
83+ release_artist_names ?: string [ ]
84+ spotify_album_id ?: string
85+ spotify_album_artist_ids ?: string [ ]
86+ spotify_artist_ids ?: string [ ]
87+ albumartist ?: string
88+ }
89+
7790export interface TrackPayload extends MinimumTrack {
78- additional_info ?: AdditionalTrackInfo
91+ additional_info ?: SubmitListenAdditionalTrackInfo
7992}
8093
8194export interface ListenPayload {
@@ -339,22 +352,49 @@ export class ListenbrainzApiClient extends AbstractApiClient {
339352 track,
340353 duration,
341354 meta : {
342- brainz = { }
355+ brainz = { } ,
356+ spotify = { }
343357 } = { }
344358 }
345359 } = play ;
360+ // using submit-listens exmaple from openapi https://rain0r.github.io/listenbrainz-openapi/index.html#/lbCore/submitListens
361+ // which is documented in official docs https://listenbrainz.readthedocs.io/en/latest/users/api/index.html#openapi-specification
362+ // and based on this LZ developer comment https://github.com/lyarenei/jellyfin-plugin-listenbrainz/issues/10#issuecomment-1253867941
363+
364+ const addInfo : SubmitListenAdditionalTrackInfo = {
365+ // all artists
366+ artist_names : Array . from ( new Set ( [ ...artists , ...albumArtists ] ) ) ,
367+ // primary artist
368+ release_artist_name : artists [ 0 ] ,
369+ release_artist_names : [ artists [ 0 ] ] ,
370+ } ;
371+
372+ if ( spotify . track !== undefined ) {
373+ addInfo . spotify_id = spotify . track ;
374+ }
375+ if ( spotify . album !== undefined ) {
376+ addInfo . spotify_album_id = spotify . album ;
377+ }
378+ if ( spotify . albumArtist !== undefined && spotify . albumArtist . length > 0 ) {
379+ addInfo . spotify_album_artist_ids = spotify . albumArtist ;
380+ }
381+ if ( spotify . artist !== undefined ) {
382+ addInfo . spotify_artist_ids = spotify . artist ;
383+ }
384+
346385 return {
347386 listened_at : getScrobbleTsSOCDate ( play ) . unix ( ) ,
348387 track_metadata : {
349- artist_name : artists [ 0 ] ,
388+ artist_name : Array . from ( new Set ( [ ... artists , ... albumArtists ] ) ) . join ( ', ' ) ,
350389 track_name : track ,
351390 release_name : album ,
352391 additional_info : {
353392 duration : play . data . duration !== undefined ? Math . round ( duration ) : undefined ,
354393 track_mbid : brainz . track ,
355394 artist_mbids : brainz . artist ,
356395 release_mbid : brainz . album ,
357- release_group_mbid : brainz . releaseGroup
396+ release_group_mbid : brainz . releaseGroup ,
397+ ...addInfo
358398 }
359399 }
360400 }
0 commit comments