diff --git a/src/backend/sources/KoitoSource.ts b/src/backend/sources/KoitoSource.ts index cc2cb940..000bcc45 100644 --- a/src/backend/sources/KoitoSource.ts +++ b/src/backend/sources/KoitoSource.ts @@ -1,5 +1,5 @@ import type EventEmitter from "events"; -import { COMPONENT_AUTH_TYPE, type ComponentAuthType, type PlayObject, SOURCE_SOT } from "../../core/Atomic.ts"; +import { COMPONENT_AUTH_TYPE, type ComponentAuthType, PARSED_FROM, type PlayObject, SOURCE_SOT } from "../../core/Atomic.ts"; import { isNodeNetworkException } from "../common/errors/NodeErrors.ts"; import type {FormatPlayObjectOptions, InternalConfig, TimeRangeListensFetcher} from "../common/infrastructure/Atomic.ts"; import type {RecentlyPlayedOptions} from "./AbstractSource.ts"; @@ -64,7 +64,7 @@ export default class KoitoSource extends MemorySource { this.setStatus('Checking for new Plays'); await this.processRecentPlays([]); const resp = await this.getScrobblesForTimeRange({limit, cursor: 0 }); - return resp; + return resp.map((x) => ({...x, meta: {...x.meta, parsedFrom: PARSED_FROM.history}})); } getUpstreamRecentlyPlayed = async (options: RecentlyPlayedOptions = {}): Promise => { diff --git a/src/backend/sources/LastfmSource.ts b/src/backend/sources/LastfmSource.ts index acf6b729..15a37f51 100644 --- a/src/backend/sources/LastfmSource.ts +++ b/src/backend/sources/LastfmSource.ts @@ -1,5 +1,5 @@ import type EventEmitter from "events"; -import { COMPONENT_AUTH_TYPE, type PlayObject, SOURCE_SOT } from "../../core/Atomic.ts"; +import { COMPONENT_AUTH_TYPE, PARSED_FROM, type PlayObject, SOURCE_SOT } from "../../core/Atomic.ts"; import type {FormatPlayObjectOptions, InternalConfig, TimeRangeListensFetcher} from "../common/infrastructure/Atomic.ts"; import type {ComponentAuthType, PlayPlatformId} from '../../core/Atomic.ts'; import type {SourceType} from "../../core/Atomic.ts"; @@ -102,7 +102,7 @@ export default class LastfmSource extends MemorySource { getUpstreamRecentlyPlayed = async (options: RecentlyPlayedOptions = {}): Promise => { try { const [history, now] = await this.getLastfmRecentTrack(options); - return history; + return history.map((x) => ({...x, meta: {...x.meta, parsedFrom: PARSED_FROM.history}})); } catch (e) { throw e; } diff --git a/src/backend/sources/LibrefmSource.ts b/src/backend/sources/LibrefmSource.ts index e1a862f0..f8f57686 100644 --- a/src/backend/sources/LibrefmSource.ts +++ b/src/backend/sources/LibrefmSource.ts @@ -9,7 +9,7 @@ import type {LastfmSourceConfig} from "../common/infrastructure/config/source/la export default class LibrefmSource extends LastfmSource { - // @ts-expect-error + // @ts-expect-error its fine declare config: LibrefmSourceConfig; constructor(name: any, config: LibrefmSourceConfig, internal: InternalConfig, emitter: EventEmitter) { diff --git a/src/backend/sources/ListenbrainzSource.ts b/src/backend/sources/ListenbrainzSource.ts index 059f13af..dee79a44 100644 --- a/src/backend/sources/ListenbrainzSource.ts +++ b/src/backend/sources/ListenbrainzSource.ts @@ -1,5 +1,5 @@ import type EventEmitter from "events"; -import { COMPONENT_AUTH_TYPE, type PlayObject, SOURCE_SOT } from "../../core/Atomic.ts"; +import { COMPONENT_AUTH_TYPE, PARSED_FROM, type PlayObject, SOURCE_SOT } from "../../core/Atomic.ts"; import { isNodeNetworkException } from "../common/errors/NodeErrors.ts"; import type {FormatPlayObjectOptions, InternalConfig, TimeRangeListensFetcher} from "../common/infrastructure/Atomic.ts"; import type {ComponentAuthType, PlayPlatformId} from '../../core/Atomic.ts'; @@ -86,7 +86,7 @@ export default class ListenbrainzSource extends MemorySource { const {limit = 20} = options; const now = await this.api.getPlayingNow(); await this.processRecentPlays(now.listens.map(x => ListenbrainzSource.formatPlayObj(x))); - return await this.getScrobblesForTimeRange({limit}); + return (await this.getScrobblesForTimeRange({limit})).map((x) => ({...x, meta: {...x.meta, parsedFrom: PARSED_FROM.history}})); } getUpstreamRecentlyPlayed = async (options: RecentlyPlayedOptions = {}): Promise => { diff --git a/src/backend/sources/MalojaSource.ts b/src/backend/sources/MalojaSource.ts index 750553ec..28debeac 100644 --- a/src/backend/sources/MalojaSource.ts +++ b/src/backend/sources/MalojaSource.ts @@ -1,5 +1,5 @@ import type EventEmitter from "events"; -import { COMPONENT_AUTH_TYPE, type ComponentAuthType, type PlayObject, SOURCE_SOT } from "../../core/Atomic.ts"; +import { COMPONENT_AUTH_TYPE, type ComponentAuthType, PARSED_FROM, type PlayObject, SOURCE_SOT } from "../../core/Atomic.ts"; import { isNodeNetworkException } from "../common/errors/NodeErrors.ts"; import type {InternalConfig} from "../common/infrastructure/Atomic.ts"; import type {RecentlyPlayedOptions} from "./AbstractSource.ts"; @@ -59,7 +59,7 @@ export default class MalojaSource extends MemorySource { this.setStatus('Checking for new Plays'); await this.processRecentPlays([]); const resp = await this.api.getPaginatedTimeRangeListens({limit, cursor: 0}); - return resp.data; + return resp.data.map((x) => ({...x, meta: {...x.meta, parsedFrom: PARSED_FROM.history}})); } getUpstreamRecentlyPlayed = async (options: RecentlyPlayedOptions = {}): Promise => { diff --git a/src/backend/sources/MemorySource.ts b/src/backend/sources/MemorySource.ts index e7e04d7f..bbcdf075 100644 --- a/src/backend/sources/MemorySource.ts +++ b/src/backend/sources/MemorySource.ts @@ -2,7 +2,7 @@ import type {Logger} from "@foxxmd/logging"; import dayjs, { type Dayjs } from "dayjs"; import type { EventEmitter } from "events"; import { AsyncTask, SimpleIntervalJob, ToadScheduler } from "toad-scheduler"; -import { type PlayObject, SOURCE_SOT, type SOURCE_SOT_TYPES, type SourcePlayerJson, type SourcePlayerObj } from "../../core/Atomic.ts"; +import { PARSED_FROM, type PlayObject, SOURCE_SOT, type SOURCE_SOT_TYPES, type SourcePlayerJson, type SourcePlayerObj } from "../../core/Atomic.ts"; import { buildTrackString } from "../../core/StringUtils.ts"; import { asPlayerStateDataMaybePlay, @@ -350,7 +350,7 @@ export default class MemorySource extends AbstractSource { } } - return newStatefulPlays; + return newStatefulPlays.map((x) => ({...x, meta: {...x.meta, parsedFrom: PARSED_FROM.player}})); } protected isListenedPlayDiscoverable = async (candidate: PlayObject): Promise<[boolean, string]> => { diff --git a/src/backend/sources/RockskySource.ts b/src/backend/sources/RockskySource.ts index 8af75e86..25aab92e 100644 --- a/src/backend/sources/RockskySource.ts +++ b/src/backend/sources/RockskySource.ts @@ -1,5 +1,5 @@ import type EventEmitter from "events"; -import { COMPONENT_AUTH_TYPE, type ComponentAuthType, type PlayObject, SOURCE_SOT } from "../../core/Atomic.ts"; +import { COMPONENT_AUTH_TYPE, type ComponentAuthType, PARSED_FROM, type PlayObject, SOURCE_SOT } from "../../core/Atomic.ts"; import { isNodeNetworkException } from "../common/errors/NodeErrors.ts"; import type {FormatPlayObjectOptions, InternalConfig} from "../common/infrastructure/Atomic.ts"; import type {RecentlyPlayedOptions} from "./AbstractSource.ts"; @@ -71,7 +71,7 @@ export default class RockskySource extends MemorySource { getRecentlyPlayed = async(options: RecentlyPlayedOptions = {}) => { const {limit = 20} = options; this.setStatus('Checking for new Plays'); - return await this.api.getRecentlyPlayed(limit); + return (await this.api.getRecentlyPlayed(limit)).map((x) => ({...x, meta: {...x.meta, parsedFrom: PARSED_FROM.history}})); } getUpstreamRecentlyPlayed = async (options: RecentlyPlayedOptions = {}): Promise => { diff --git a/src/backend/sources/TealfmSource.ts b/src/backend/sources/TealfmSource.ts index 37da3902..1599554a 100644 --- a/src/backend/sources/TealfmSource.ts +++ b/src/backend/sources/TealfmSource.ts @@ -1,5 +1,5 @@ import type EventEmitter from "events"; -import { COMPONENT_AUTH_TYPE, type ComponentAuthType, type PlayObject, SOURCE_SOT } from "../../core/Atomic.ts"; +import { COMPONENT_AUTH_TYPE, type ComponentAuthType, PARSED_FROM, type PlayObject, SOURCE_SOT } from "../../core/Atomic.ts"; import { isNodeNetworkException } from "../common/errors/NodeErrors.ts"; import type {FormatPlayObjectOptions, InternalConfig} from "../common/infrastructure/Atomic.ts"; import type {RecentlyPlayedOptions} from "./AbstractSource.ts"; @@ -120,7 +120,7 @@ export default class TealfmSource extends MemorySource { || (x.meta.musicService === undefined && !this.serviceAllow.includes('unknown')) ); } - return plays; + return plays.map((x) => ({...x, meta: {...x.meta, parsedFrom: PARSED_FROM.history}})); } getUpstreamRecentlyPlayed = async (options: RecentlyPlayedOptions = {}): Promise => { diff --git a/src/backend/sources/WebScrobblerSource.ts b/src/backend/sources/WebScrobblerSource.ts index 43cce5e6..c9450a20 100644 --- a/src/backend/sources/WebScrobblerSource.ts +++ b/src/backend/sources/WebScrobblerSource.ts @@ -1,6 +1,6 @@ import dayjs, { type Dayjs } from "dayjs"; import type EventEmitter from "events"; -import { type PlayObjectMinimal, SOURCE_SOT } from "../../core/Atomic.ts"; +import { PARSED_FROM, type PlayObjectMinimal, SOURCE_SOT } from "../../core/Atomic.ts"; import { type FormatPlayObjectOptions, type InternalConfig, @@ -143,7 +143,7 @@ export class WebScrobblerSource extends MemorySource { }, meta: { trackId: uniqueID, - parsedFrom: P, + parsedFrom: PARSED_FROM.nowPlaying, url: { web: trackUrl, origin: originUrl