mirror of
https://github.com/FoxxMD/multi-scrobbler.git
synced 2026-09-03 05:10:00 +03:00
feat(musicbrainz): Search by track MBID using basicorids #447
This commit is contained in:
@@ -494,7 +494,13 @@ export default class MusicbrainzTransformer extends AtomicPartsTransformer<Exter
|
||||
} = {}
|
||||
} = play;
|
||||
|
||||
using.push(brainz.recording !== undefined ? 'mbidrecording' : 'title');
|
||||
if(brainz.recording !== undefined) {
|
||||
using.push('mbidrecording');
|
||||
} else if(brainz.track !== undefined) {
|
||||
using.push('mbidtrack');
|
||||
} else {
|
||||
using.push('title');
|
||||
}
|
||||
using.push(brainz.album !== undefined ? 'mbidrelease' : 'album');
|
||||
using.push((brainz.artist ?? []).length > 0 ? 'mbidartist' : 'artist');
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export interface MusicbrainzApiClientConfig {
|
||||
apis: MusicbrainzApiConfigData[]
|
||||
}
|
||||
|
||||
export type UsingTypes = 'artist' | 'album' | 'title' | 'isrc' | 'mbidrecording' | 'mbidrelease' | 'mbidartist';
|
||||
export type UsingTypes = 'artist' | 'album' | 'title' | 'isrc' | 'mbidrecording' | 'mbidrelease' | 'mbidartist' | 'mbidtrack';
|
||||
|
||||
export interface SearchOptions {
|
||||
escapeCharacters?: boolean
|
||||
@@ -216,6 +216,9 @@ export class MusicbrainzApiClient extends AbstractApiClient {
|
||||
if(play.data?.meta?.brainz?.recording !== undefined && using.includes('mbidrecording')) {
|
||||
query.recording_mbid = play.data.meta.brainz.recording
|
||||
}
|
||||
if(play.data?.meta?.brainz?.track !== undefined && using.includes('mbidtrack')) {
|
||||
query.track_mbid = play.data.meta.brainz.track
|
||||
}
|
||||
if(play.data?.meta?.brainz?.album !== undefined && using.includes('mbidrelease')) {
|
||||
query.release_mbid = play.data.meta.brainz.album
|
||||
}
|
||||
@@ -287,6 +290,12 @@ export class MusicbrainzApiClient extends AbstractApiClient {
|
||||
}
|
||||
q += `rid:"${query.recording_mbid}"`
|
||||
}
|
||||
if(query.track_mbid !== undefined) {
|
||||
if(q !== '') {
|
||||
q += ' AND ';
|
||||
}
|
||||
q += `tid:"${query.track_mbid}"`
|
||||
}
|
||||
if(query.artist_mbids !== undefined) {
|
||||
q += `(arid:(${query.artist_mbids.map(x => `"${x}"`).join(' AND ')}) OR arid:(${query.artist_mbids.map(x => `"${x}"`).join(' OR ')}))`
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@ export default class PlexApiSource extends MemoryPositionalSource {
|
||||
const prevBrainzMeta = sessionData[0].play.data.meta.brainz ?? {};
|
||||
sessionData[0].play.data.meta.brainz = {
|
||||
...prevBrainzMeta,
|
||||
recording: trackMbId,
|
||||
track: trackMbId,
|
||||
album: albumMbId,
|
||||
// Plex doesn't track MBIDs for track artists, so we use the
|
||||
// album artist MBID instead.
|
||||
|
||||
@@ -133,6 +133,12 @@ export interface BrainzMeta {
|
||||
|
||||
/** Position of track within Release */
|
||||
trackNumber?: number
|
||||
|
||||
/** Track MBID (tid), not visible to end users and is only relevant in the context of a Release
|
||||
*
|
||||
* Specifies the track on a specific Release. Not the same as the Recording MBID.
|
||||
*/
|
||||
track?: string
|
||||
}
|
||||
|
||||
export interface SpotifyMeta {
|
||||
|
||||
Reference in New Issue
Block a user