mirror of
https://github.com/FoxxMD/multi-scrobbler.git
synced 2026-09-03 05:10:00 +03:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cdf779d87 | ||
|
|
44f2a295ff |
+16
-3
@@ -1,7 +1,7 @@
|
||||
import { stringSameness } from '@foxxmd/string-sameness';
|
||||
import dayjs from "dayjs";
|
||||
import request, { Request, Response } from 'superagent';
|
||||
import { BrainzMeta, PlayObject, URLData } from "../../../core/Atomic.js";
|
||||
import { BrainzMeta, PlayObject, SCROBBLE_TS_SOC_START, URLData } from "../../../core/Atomic.js";
|
||||
import { combinePartsToString, slice } from "../../../core/StringUtils.js";
|
||||
import {
|
||||
findDelimiters,
|
||||
@@ -263,7 +263,10 @@ export class ListenbrainzApiClient extends AbstractApiClient {
|
||||
release_mbid,
|
||||
release_group_mbid,
|
||||
release_artist_name,
|
||||
release_artist_names = []
|
||||
release_artist_names = [],
|
||||
scrobble_ts_soc = SCROBBLE_TS_SOC_START,
|
||||
listened_for,
|
||||
listened_at_completed
|
||||
} = {}
|
||||
} = {},
|
||||
} = payload;
|
||||
@@ -276,7 +279,7 @@ export class ListenbrainzApiClient extends AbstractApiClient {
|
||||
albumArtists = unique([...(albumArtists ?? []), ...release_artist_names])
|
||||
}
|
||||
|
||||
return {
|
||||
const play: PlayObject = {
|
||||
data: {
|
||||
playDate: typeof listened_at === 'number' ? dayjs.unix(listened_at) : dayjs(listened_at),
|
||||
track: track_name,
|
||||
@@ -295,8 +298,18 @@ export class ListenbrainzApiClient extends AbstractApiClient {
|
||||
},
|
||||
meta: {
|
||||
nowPlaying,
|
||||
scrobbleTsSOC: scrobble_ts_soc
|
||||
}
|
||||
}
|
||||
|
||||
if(listened_at_completed !== undefined) {
|
||||
play.data.playDateCompleted = dayjs.unix(listened_at_completed);
|
||||
}
|
||||
if(listened_for !== undefined) {
|
||||
play.data.listenedFor = listened_for;
|
||||
}
|
||||
|
||||
return play;
|
||||
}
|
||||
|
||||
static listenResponseToPlay(listen: ListenResponse): PlayObject {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* https://musicbrainz.org/doc/MusicBrainz_Database/Schema#Overview
|
||||
*/
|
||||
|
||||
import { ScrobbleTsSOC } from "../../../../core/Atomic.js";
|
||||
|
||||
/** A unique product a Recording is issued on.
|
||||
*
|
||||
* This is like an album (release group) but is specific to the type, year, catalog, etc... for this release
|
||||
@@ -123,6 +125,21 @@ export interface SubmitListenAdditionalTrackInfo extends AdditionalTrackInfo {
|
||||
spotify_album_artist_ids?: string[];
|
||||
spotify_artist_ids?: string[];
|
||||
albumartist?: string;
|
||||
/** Is the timestamp (listened_at) from when the user started listening or when they stopped listening?
|
||||
*
|
||||
* Specific to multi-scrobbler
|
||||
*/
|
||||
scrobble_ts_soc?: ScrobbleTsSOC
|
||||
/** Unix timestamp for when the user stopped listening
|
||||
*
|
||||
* Specific to multi-scrobbler
|
||||
*/
|
||||
listened_at_completed?: number
|
||||
/** Number of seconds track was listened to
|
||||
*
|
||||
* Specific to multi-scrobbler
|
||||
*/
|
||||
listened_for?: number
|
||||
}
|
||||
export interface TrackPayload extends MinimumTrack {
|
||||
additional_info?: SubmitListenAdditionalTrackInfo;
|
||||
|
||||
Reference in New Issue
Block a user