Add additional song types
This commit is contained in:
parent
e94783820e
commit
d1c038ea6f
4 changed files with 26 additions and 3 deletions
|
@ -572,6 +572,8 @@ const normalizeSong = (
|
|||
artistName: item.ArtistItems[0]?.Name,
|
||||
artists: item.ArtistItems.map((entry) => ({ id: entry.Id, name: entry.Name })),
|
||||
bitRate: item.MediaSources && Number(Math.trunc(item.MediaSources[0]?.Bitrate / 1000)),
|
||||
bpm: null,
|
||||
channels: null,
|
||||
compilation: null,
|
||||
container: (item.MediaSources && item.MediaSources[0]?.Container) || null,
|
||||
createdAt: item.DateCreated,
|
||||
|
@ -581,10 +583,13 @@ const normalizeSong = (
|
|||
id: item.Id,
|
||||
imageUrl: getSongCoverArtUrl({ baseUrl: server.url, item, size: imageSize || 300 }),
|
||||
isFavorite: (item.UserData && item.UserData.IsFavorite) || false,
|
||||
lastPlayedAt: null,
|
||||
name: item.Name,
|
||||
note: null,
|
||||
path: (item.MediaSources && item.MediaSources[0]?.Path) || null,
|
||||
playCount: (item.UserData && item.UserData.PlayCount) || 0,
|
||||
releaseDate: (item.ProductionYear && new Date(item.ProductionYear, 0, 1).toISOString()) || null,
|
||||
// releaseDate: (item.ProductionYear && new Date(item.ProductionYear, 0, 1).toISOString()) || null,
|
||||
releaseDate: null,
|
||||
releaseYear: (item.ProductionYear && String(item.ProductionYear)) || null,
|
||||
serverId: server.id,
|
||||
size: item.MediaSources && item.MediaSources[0]?.Size,
|
||||
|
|
|
@ -455,6 +455,8 @@ const normalizeSong = (
|
|||
artistName: item.artist,
|
||||
artists: [{ id: item.artistId, name: item.artist }],
|
||||
bitRate: item.bitRate,
|
||||
bpm: item.bpm ? item.bpm : null,
|
||||
channels: item.channels ? item.channels : null,
|
||||
compilation: item.compilation,
|
||||
container: item.suffix,
|
||||
createdAt: item.createdAt.split('T')[0],
|
||||
|
@ -464,7 +466,9 @@ const normalizeSong = (
|
|||
id: item.id,
|
||||
imageUrl,
|
||||
isFavorite: item.starred,
|
||||
lastPlayedAt: item.playDate ? item.playDate : null,
|
||||
name: item.title,
|
||||
note: item.comment ? item.comment : null,
|
||||
path: item.path,
|
||||
playCount: item.playCount,
|
||||
releaseDate: new Date(item.year, 0, 1).toISOString(),
|
||||
|
|
|
@ -56,7 +56,9 @@ export type NDSong = {
|
|||
artistId: string;
|
||||
bitRate: number;
|
||||
bookmarkPosition: number;
|
||||
channels: number;
|
||||
bpm?: number;
|
||||
channels?: number;
|
||||
comment?: string;
|
||||
compilation: boolean;
|
||||
createdAt: string;
|
||||
discNumber: number;
|
||||
|
@ -66,6 +68,7 @@ export type NDSong = {
|
|||
genres: NDGenre[];
|
||||
hasCoverArt: boolean;
|
||||
id: string;
|
||||
lyrics?: string;
|
||||
mbzAlbumArtistId: string;
|
||||
mbzAlbumId: string;
|
||||
mbzArtistId: string;
|
||||
|
@ -206,7 +209,7 @@ export type NDAlbumListParams = {
|
|||
NDOrder;
|
||||
|
||||
export enum NDSongListSort {
|
||||
ALBUM = 'album',
|
||||
ALBUM = 'album, order_album_artist_name, disc_number, track_number, title',
|
||||
ALBUM_ARTIST = 'albumArtist',
|
||||
ARTIST = 'artist',
|
||||
BPM = 'bpm',
|
||||
|
|
|
@ -174,6 +174,8 @@ export type Song = {
|
|||
artistName: string;
|
||||
artists: RelatedArtist[];
|
||||
bitRate: number;
|
||||
bpm: number | null;
|
||||
channels: number | null;
|
||||
compilation: boolean | null;
|
||||
container: string | null;
|
||||
createdAt: string;
|
||||
|
@ -183,7 +185,9 @@ export type Song = {
|
|||
id: string;
|
||||
imageUrl: string | null;
|
||||
isFavorite: boolean;
|
||||
lastPlayedAt: string | null;
|
||||
name: string;
|
||||
note: string | null;
|
||||
path: string | null;
|
||||
playCount: number;
|
||||
releaseDate: string | null;
|
||||
|
@ -393,6 +397,7 @@ export type RawSongListResponse = NDSongList | JFSongList | undefined;
|
|||
export type SongListResponse = BasePaginatedResponse<Song[]>;
|
||||
|
||||
export enum SongListSort {
|
||||
ALBUM = 'album',
|
||||
ALBUM_ARTIST = 'albumArtist',
|
||||
ARTIST = 'artist',
|
||||
BPM = 'bpm',
|
||||
|
@ -416,6 +421,8 @@ export type SongListQuery = {
|
|||
filters?: string;
|
||||
genres?: string;
|
||||
includeItemTypes: 'Audio';
|
||||
maxYear?: number;
|
||||
minYear?: number;
|
||||
sortBy?: JFSongListSort;
|
||||
years?: string;
|
||||
};
|
||||
|
@ -430,6 +437,7 @@ export type SongListQuery = {
|
|||
title?: string;
|
||||
year?: number;
|
||||
};
|
||||
searchTerm?: string;
|
||||
sortBy: SongListSort;
|
||||
sortOrder: SortOrder;
|
||||
startIndex: number;
|
||||
|
@ -445,6 +453,7 @@ type SongListSortMap = {
|
|||
|
||||
export const songListSortMap: SongListSortMap = {
|
||||
jellyfin: {
|
||||
album: JFSongListSort.ALBUM,
|
||||
albumArtist: JFSongListSort.ALBUM_ARTIST,
|
||||
artist: JFSongListSort.ARTIST,
|
||||
bpm: undefined,
|
||||
|
@ -463,6 +472,7 @@ export const songListSortMap: SongListSortMap = {
|
|||
year: undefined,
|
||||
},
|
||||
navidrome: {
|
||||
album: NDSongListSort.ALBUM,
|
||||
albumArtist: NDSongListSort.ALBUM_ARTIST,
|
||||
artist: NDSongListSort.ARTIST,
|
||||
bpm: NDSongListSort.BPM,
|
||||
|
@ -481,6 +491,7 @@ export const songListSortMap: SongListSortMap = {
|
|||
year: NDSongListSort.YEAR,
|
||||
},
|
||||
subsonic: {
|
||||
album: undefined,
|
||||
albumArtist: undefined,
|
||||
artist: undefined,
|
||||
bpm: undefined,
|
||||
|
|
Reference in a new issue