Add additional song types

This commit is contained in:
jeffvli 2022-12-27 02:00:39 -08:00
parent e94783820e
commit d1c038ea6f
4 changed files with 26 additions and 3 deletions

View file

@ -572,6 +572,8 @@ const normalizeSong = (
artistName: item.ArtistItems[0]?.Name, artistName: item.ArtistItems[0]?.Name,
artists: item.ArtistItems.map((entry) => ({ id: entry.Id, name: entry.Name })), artists: item.ArtistItems.map((entry) => ({ id: entry.Id, name: entry.Name })),
bitRate: item.MediaSources && Number(Math.trunc(item.MediaSources[0]?.Bitrate / 1000)), bitRate: item.MediaSources && Number(Math.trunc(item.MediaSources[0]?.Bitrate / 1000)),
bpm: null,
channels: null,
compilation: null, compilation: null,
container: (item.MediaSources && item.MediaSources[0]?.Container) || null, container: (item.MediaSources && item.MediaSources[0]?.Container) || null,
createdAt: item.DateCreated, createdAt: item.DateCreated,
@ -581,10 +583,13 @@ const normalizeSong = (
id: item.Id, id: item.Id,
imageUrl: getSongCoverArtUrl({ baseUrl: server.url, item, size: imageSize || 300 }), imageUrl: getSongCoverArtUrl({ baseUrl: server.url, item, size: imageSize || 300 }),
isFavorite: (item.UserData && item.UserData.IsFavorite) || false, isFavorite: (item.UserData && item.UserData.IsFavorite) || false,
lastPlayedAt: null,
name: item.Name, name: item.Name,
note: null,
path: (item.MediaSources && item.MediaSources[0]?.Path) || null, path: (item.MediaSources && item.MediaSources[0]?.Path) || null,
playCount: (item.UserData && item.UserData.PlayCount) || 0, 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, releaseYear: (item.ProductionYear && String(item.ProductionYear)) || null,
serverId: server.id, serverId: server.id,
size: item.MediaSources && item.MediaSources[0]?.Size, size: item.MediaSources && item.MediaSources[0]?.Size,

View file

@ -455,6 +455,8 @@ const normalizeSong = (
artistName: item.artist, artistName: item.artist,
artists: [{ id: item.artistId, name: item.artist }], artists: [{ id: item.artistId, name: item.artist }],
bitRate: item.bitRate, bitRate: item.bitRate,
bpm: item.bpm ? item.bpm : null,
channels: item.channels ? item.channels : null,
compilation: item.compilation, compilation: item.compilation,
container: item.suffix, container: item.suffix,
createdAt: item.createdAt.split('T')[0], createdAt: item.createdAt.split('T')[0],
@ -464,7 +466,9 @@ const normalizeSong = (
id: item.id, id: item.id,
imageUrl, imageUrl,
isFavorite: item.starred, isFavorite: item.starred,
lastPlayedAt: item.playDate ? item.playDate : null,
name: item.title, name: item.title,
note: item.comment ? item.comment : null,
path: item.path, path: item.path,
playCount: item.playCount, playCount: item.playCount,
releaseDate: new Date(item.year, 0, 1).toISOString(), releaseDate: new Date(item.year, 0, 1).toISOString(),

View file

@ -56,7 +56,9 @@ export type NDSong = {
artistId: string; artistId: string;
bitRate: number; bitRate: number;
bookmarkPosition: number; bookmarkPosition: number;
channels: number; bpm?: number;
channels?: number;
comment?: string;
compilation: boolean; compilation: boolean;
createdAt: string; createdAt: string;
discNumber: number; discNumber: number;
@ -66,6 +68,7 @@ export type NDSong = {
genres: NDGenre[]; genres: NDGenre[];
hasCoverArt: boolean; hasCoverArt: boolean;
id: string; id: string;
lyrics?: string;
mbzAlbumArtistId: string; mbzAlbumArtistId: string;
mbzAlbumId: string; mbzAlbumId: string;
mbzArtistId: string; mbzArtistId: string;
@ -206,7 +209,7 @@ export type NDAlbumListParams = {
NDOrder; NDOrder;
export enum NDSongListSort { export enum NDSongListSort {
ALBUM = 'album', ALBUM = 'album, order_album_artist_name, disc_number, track_number, title',
ALBUM_ARTIST = 'albumArtist', ALBUM_ARTIST = 'albumArtist',
ARTIST = 'artist', ARTIST = 'artist',
BPM = 'bpm', BPM = 'bpm',

View file

@ -174,6 +174,8 @@ export type Song = {
artistName: string; artistName: string;
artists: RelatedArtist[]; artists: RelatedArtist[];
bitRate: number; bitRate: number;
bpm: number | null;
channels: number | null;
compilation: boolean | null; compilation: boolean | null;
container: string | null; container: string | null;
createdAt: string; createdAt: string;
@ -183,7 +185,9 @@ export type Song = {
id: string; id: string;
imageUrl: string | null; imageUrl: string | null;
isFavorite: boolean; isFavorite: boolean;
lastPlayedAt: string | null;
name: string; name: string;
note: string | null;
path: string | null; path: string | null;
playCount: number; playCount: number;
releaseDate: string | null; releaseDate: string | null;
@ -393,6 +397,7 @@ export type RawSongListResponse = NDSongList | JFSongList | undefined;
export type SongListResponse = BasePaginatedResponse<Song[]>; export type SongListResponse = BasePaginatedResponse<Song[]>;
export enum SongListSort { export enum SongListSort {
ALBUM = 'album',
ALBUM_ARTIST = 'albumArtist', ALBUM_ARTIST = 'albumArtist',
ARTIST = 'artist', ARTIST = 'artist',
BPM = 'bpm', BPM = 'bpm',
@ -416,6 +421,8 @@ export type SongListQuery = {
filters?: string; filters?: string;
genres?: string; genres?: string;
includeItemTypes: 'Audio'; includeItemTypes: 'Audio';
maxYear?: number;
minYear?: number;
sortBy?: JFSongListSort; sortBy?: JFSongListSort;
years?: string; years?: string;
}; };
@ -430,6 +437,7 @@ export type SongListQuery = {
title?: string; title?: string;
year?: number; year?: number;
}; };
searchTerm?: string;
sortBy: SongListSort; sortBy: SongListSort;
sortOrder: SortOrder; sortOrder: SortOrder;
startIndex: number; startIndex: number;
@ -445,6 +453,7 @@ type SongListSortMap = {
export const songListSortMap: SongListSortMap = { export const songListSortMap: SongListSortMap = {
jellyfin: { jellyfin: {
album: JFSongListSort.ALBUM,
albumArtist: JFSongListSort.ALBUM_ARTIST, albumArtist: JFSongListSort.ALBUM_ARTIST,
artist: JFSongListSort.ARTIST, artist: JFSongListSort.ARTIST,
bpm: undefined, bpm: undefined,
@ -463,6 +472,7 @@ export const songListSortMap: SongListSortMap = {
year: undefined, year: undefined,
}, },
navidrome: { navidrome: {
album: NDSongListSort.ALBUM,
albumArtist: NDSongListSort.ALBUM_ARTIST, albumArtist: NDSongListSort.ALBUM_ARTIST,
artist: NDSongListSort.ARTIST, artist: NDSongListSort.ARTIST,
bpm: NDSongListSort.BPM, bpm: NDSongListSort.BPM,
@ -481,6 +491,7 @@ export const songListSortMap: SongListSortMap = {
year: NDSongListSort.YEAR, year: NDSongListSort.YEAR,
}, },
subsonic: { subsonic: {
album: undefined,
albumArtist: undefined, albumArtist: undefined,
artist: undefined, artist: undefined,
bpm: undefined, bpm: undefined,