mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 12:30:12 +02:00
Adjust album/song types
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { api } from '../lib';
|
||||
import { AlbumsResponse, BasePaginationRequest } from './types';
|
||||
import { AlbumResponse, AlbumsResponse, BasePaginationRequest } from './types';
|
||||
|
||||
export interface AlbumsRequest extends BasePaginationRequest {
|
||||
orderBy: string;
|
||||
@@ -8,7 +8,7 @@ export interface AlbumsRequest extends BasePaginationRequest {
|
||||
}
|
||||
|
||||
const getAlbum = async (params: { id: number }, signal?: AbortSignal) => {
|
||||
const { data } = await api.get<AlbumsResponse>(`/albums/${params.id}`, {
|
||||
const { data } = await api.get<AlbumResponse>(`/albums/${params.id}`, {
|
||||
signal,
|
||||
});
|
||||
return data;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Album } from '../../types';
|
||||
|
||||
export interface BaseResponse<T> {
|
||||
data: T;
|
||||
error?: string | any;
|
||||
@@ -112,45 +114,6 @@ export type AlbumResponse = BaseResponse<Album>;
|
||||
|
||||
export type AlbumsResponse = BasePaginatedResponse<Album[]>;
|
||||
|
||||
export interface Album {
|
||||
_count: Count;
|
||||
albumArtistId: number;
|
||||
createdAt: string;
|
||||
date: string;
|
||||
genres: GenreResponse[];
|
||||
id: number;
|
||||
name: string;
|
||||
remoteCreatedAt: string;
|
||||
remoteId: string;
|
||||
serverFolderId: number;
|
||||
songs: Song[];
|
||||
updatedAt: string;
|
||||
year: number;
|
||||
}
|
||||
|
||||
export interface Song {
|
||||
album?: Partial<Album>;
|
||||
albumId: number;
|
||||
artistName: null;
|
||||
artists?: ArtistResponse[];
|
||||
bitRate: number;
|
||||
container: string;
|
||||
createdAt: string;
|
||||
date: string;
|
||||
disc: number;
|
||||
duration: number;
|
||||
externals?: ExternalResponse[];
|
||||
id: number;
|
||||
images?: ImageResponse[];
|
||||
name: string;
|
||||
remoteCreatedAt: string;
|
||||
remoteId: string;
|
||||
serverFolderId: number;
|
||||
track: number;
|
||||
updatedAt: string;
|
||||
year: number;
|
||||
}
|
||||
|
||||
export type Count = {
|
||||
artists?: number;
|
||||
externals?: number;
|
||||
|
||||
@@ -27,14 +27,14 @@ const MetadataStack = styled.div`
|
||||
|
||||
export const LeftControls = () => {
|
||||
const song = usePlayerStore((state) => state.current.song);
|
||||
const title = song?.title;
|
||||
const artists = song?.artist?.map((artist) => artist?.title).join(', ');
|
||||
const title = song?.name;
|
||||
const artists = song?.artists?.map((artist) => artist?.name).join(', ');
|
||||
const album = song?.album;
|
||||
|
||||
return (
|
||||
<LeftControlsContainer>
|
||||
<ImageWrapper>
|
||||
<img alt="img" height={60} src={song?.image} width={60} />
|
||||
<img alt="img" height={60} src={song?.imageUrl} width={60} />
|
||||
</ImageWrapper>
|
||||
<MetadataStack>
|
||||
<Text
|
||||
|
||||
@@ -56,25 +56,12 @@ export const usePlayQueueHandler = () => {
|
||||
: getSubsonicStreamUrl(auth, song, deviceId);
|
||||
|
||||
return {
|
||||
albumId: song.albumId,
|
||||
artistName: song.artistName,
|
||||
duration: song.duration,
|
||||
id: song.id,
|
||||
...song,
|
||||
streamUrl,
|
||||
title: song.name,
|
||||
year: song.year,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
albumId: song.albumId,
|
||||
artistName: song.artistName,
|
||||
duration: song.duration,
|
||||
id: song.id,
|
||||
streamUrl: song.streamUrl,
|
||||
title: song.name,
|
||||
year: song.year,
|
||||
};
|
||||
return song;
|
||||
});
|
||||
|
||||
const playerData = addToQueue(songs, options.play);
|
||||
|
||||
@@ -111,6 +111,8 @@ const songs = (
|
||||
items: any[],
|
||||
options: {
|
||||
deviceId: string;
|
||||
imageUrl?: string;
|
||||
serverFolderId?: number;
|
||||
serverType?: string;
|
||||
token: string;
|
||||
url?: string;
|
||||
@@ -126,6 +128,7 @@ const songs = (
|
||||
const url = options.url ? options.url : item.server.serverUrls[0];
|
||||
|
||||
return {
|
||||
album: item.album.name,
|
||||
albumId: item.albumId,
|
||||
artistName: item.artistName,
|
||||
artists: relatedArtists(item.artists),
|
||||
@@ -138,10 +141,13 @@ const songs = (
|
||||
duration: item.duration,
|
||||
genres: relatedGenres(item.genres),
|
||||
id: item.id,
|
||||
image: primaryImage(item.images, serverType, url, item.remoteId),
|
||||
imageUrl:
|
||||
primaryImage(item.images, serverType, url, item.remoteId) ||
|
||||
options.imageUrl,
|
||||
name: item.name,
|
||||
remoteCreatedAt: item.remoteCreatedAt,
|
||||
remoteId: item.remoteId,
|
||||
serverFolderId: item.serverFolderId,
|
||||
serverId: item.serverId,
|
||||
streamUrl: streamUrl(serverType, {
|
||||
deviceId: options.deviceId,
|
||||
@@ -167,16 +173,23 @@ const albums = (items: any[], user: User) => {
|
||||
(r: Rating) => r.userId === user.id
|
||||
)?.value;
|
||||
const averageRating = meanBy(item.ratings, 'value');
|
||||
const imageUrl = primaryImage(
|
||||
item.images,
|
||||
serverType,
|
||||
url,
|
||||
item.remoteId
|
||||
);
|
||||
|
||||
return {
|
||||
albumArtist: item.albumArtist,
|
||||
albumArtistId: item.albumArtistId,
|
||||
averageRating,
|
||||
createdAt: item.createdAt,
|
||||
dateCreated: item.date,
|
||||
date: item.date,
|
||||
deleted: item.deleted,
|
||||
genres: relatedGenres(item.genres),
|
||||
id: item.id,
|
||||
image: primaryImage(item.images, serverType, url, item.remoteId),
|
||||
imageUrl,
|
||||
name: item.name,
|
||||
rating,
|
||||
remoteCreatedAt: item.remoteCreatedAt,
|
||||
@@ -186,6 +199,8 @@ const albums = (items: any[], user: User) => {
|
||||
songCount: item._count.songs,
|
||||
songs: songs(item.songs, {
|
||||
deviceId: user.deviceId,
|
||||
imageUrl,
|
||||
serverFolderId: item.serverFolderId,
|
||||
serverType,
|
||||
token,
|
||||
url,
|
||||
|
||||
+66
-86
@@ -103,46 +103,55 @@ export interface GenericItem {
|
||||
}
|
||||
|
||||
export interface APIResult {
|
||||
data: Album[] | Artist[] | Genre[] | Playlist[] | Song[];
|
||||
data: Album[] | Artist[] | Genre[] | Song[];
|
||||
totalRecordCount?: number;
|
||||
}
|
||||
|
||||
export interface Album {
|
||||
albumArtist?: string;
|
||||
albumArtist: Partial<AlbumArtist>;
|
||||
albumArtistId: string;
|
||||
albumGenre?: string;
|
||||
albumId: string;
|
||||
artist?: Artist[];
|
||||
created: string;
|
||||
duration: number;
|
||||
genre?: Genre[];
|
||||
id: string;
|
||||
image: string;
|
||||
isDir?: boolean;
|
||||
playCount?: number;
|
||||
song?: Song[];
|
||||
averageRating: number;
|
||||
container: string;
|
||||
createdAt: string;
|
||||
date: string;
|
||||
deleted: boolean;
|
||||
genres: Genre[];
|
||||
id: number;
|
||||
imageUrl: string;
|
||||
name: string;
|
||||
rating: number;
|
||||
remoteCreatedAt: string;
|
||||
remoteId: string;
|
||||
serverFolderId: number;
|
||||
serverType: ServerType | string;
|
||||
songCount: number;
|
||||
starred?: string;
|
||||
title: string;
|
||||
type: Item.ALBUM;
|
||||
uniqueId: string;
|
||||
userRating?: number;
|
||||
year?: number;
|
||||
songs: Song[];
|
||||
updatedAt: string;
|
||||
year: number;
|
||||
}
|
||||
|
||||
export interface AlbumArtist {
|
||||
biography?: string;
|
||||
createdAt: string;
|
||||
deleted: boolean;
|
||||
id: number;
|
||||
name: string;
|
||||
remoteCreatedAt: string;
|
||||
remoteId: string;
|
||||
serverId: number;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface Artist {
|
||||
album?: Album[];
|
||||
albumCount?: number;
|
||||
duration?: number;
|
||||
genre?: Genre[];
|
||||
id?: string;
|
||||
image?: string;
|
||||
info?: ArtistInfo;
|
||||
starred?: string;
|
||||
title: string;
|
||||
type?: Item.ARTIST;
|
||||
uniqueId?: string;
|
||||
userRating?: number;
|
||||
biography?: string;
|
||||
createdAt: string;
|
||||
deleted: boolean;
|
||||
id: number;
|
||||
name: string;
|
||||
remoteCreatedAt: string;
|
||||
remoteId: string;
|
||||
serverId: number;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ArtistInfo {
|
||||
@@ -152,72 +161,39 @@ export interface ArtistInfo {
|
||||
similarArtist?: Artist[];
|
||||
}
|
||||
|
||||
export interface Folder {
|
||||
created: string;
|
||||
id: string;
|
||||
image: string;
|
||||
isDir?: boolean;
|
||||
title: string;
|
||||
type: Item.FOLDER;
|
||||
uniqueId: string;
|
||||
}
|
||||
|
||||
export interface Genre {
|
||||
albumCount?: number;
|
||||
id: string;
|
||||
name: string;
|
||||
songCount?: number;
|
||||
title: string;
|
||||
type?: Item.GENRE;
|
||||
uniqueId?: string;
|
||||
}
|
||||
|
||||
export interface Playlist {
|
||||
changed?: string;
|
||||
comment?: string;
|
||||
created?: string;
|
||||
duration: number;
|
||||
genre?: Genre[];
|
||||
id: string;
|
||||
image: string;
|
||||
owner?: string;
|
||||
public?: boolean;
|
||||
song?: Song[];
|
||||
songCount?: number;
|
||||
title: string;
|
||||
type: Item.PLAYLIST;
|
||||
uniqueId: string;
|
||||
}
|
||||
|
||||
export interface Song {
|
||||
album?: string;
|
||||
albumArtist?: string;
|
||||
albumArtistId?: number;
|
||||
albumGenre?: string;
|
||||
albumId?: number;
|
||||
artist?: Artist[];
|
||||
artistName?: string | null;
|
||||
bitRate?: number;
|
||||
contentType?: string;
|
||||
created?: string;
|
||||
discNumber?: number;
|
||||
duration?: number;
|
||||
genre?: Genre[];
|
||||
album: string;
|
||||
albumId: number;
|
||||
artistName: null;
|
||||
artists: Partial<Artist>[];
|
||||
bitRate: number;
|
||||
container: string;
|
||||
createdAt: string;
|
||||
date: string;
|
||||
deleted: boolean;
|
||||
disc: number;
|
||||
duration: number;
|
||||
genres: Partial<Genre>[];
|
||||
id: number;
|
||||
image?: string;
|
||||
isDir?: boolean;
|
||||
parent?: string;
|
||||
path?: string;
|
||||
playCount?: number;
|
||||
size?: number;
|
||||
starred?: string;
|
||||
imageUrl: string;
|
||||
name: string;
|
||||
remoteCreatedAt: string;
|
||||
remoteId: string;
|
||||
serverFolderId: number;
|
||||
serverId: number;
|
||||
streamUrl: string;
|
||||
suffix?: string;
|
||||
title: string;
|
||||
track?: number;
|
||||
type?: Item.SONG;
|
||||
uniqueId?: string;
|
||||
userRating?: number;
|
||||
year?: number;
|
||||
track: number;
|
||||
updatedAt: string;
|
||||
year: number;
|
||||
}
|
||||
|
||||
export interface ScanStatus {
|
||||
@@ -247,3 +223,7 @@ export interface ServerFolderAuth {
|
||||
userId: string;
|
||||
username: string;
|
||||
}
|
||||
|
||||
export interface UniqueId {
|
||||
uniqueId: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user