mirror of
https://github.com/leinelissen/jellyfin-audio-player.git
synced 2026-09-03 05:10:01 +03:00
Update Emby driver to use API types and complete type reorganization
Co-authored-by: leinelissen <10154841+leinelissen@users.noreply.github.com>
This commit is contained in:
co-authored by
leinelissen
parent
2f9ccb6f75
commit
c811dcb3ca
@@ -22,6 +22,11 @@ import {
|
||||
StreamOptions,
|
||||
DownloadOptions,
|
||||
DownloadInfo,
|
||||
EmbyAlbum,
|
||||
EmbyTrack,
|
||||
EmbyArtist,
|
||||
EmbyPlaylist,
|
||||
EmbyItemsResponse,
|
||||
} from './types';
|
||||
|
||||
/** Map the output of `Platform.OS`, so that Emby can understand it. */
|
||||
@@ -146,22 +151,9 @@ export class EmbyDriver extends SourceDriver {
|
||||
Limit: limit.toString(),
|
||||
});
|
||||
|
||||
const response = await this.fetch<{ Items: Array<{
|
||||
Id: string;
|
||||
Name: string;
|
||||
ProductionYear?: number;
|
||||
IsFolder: boolean;
|
||||
AlbumArtist?: string;
|
||||
DateCreated?: string;
|
||||
ArtistItems?: Array<{
|
||||
Id: string;
|
||||
Name: string;
|
||||
IsFolder: boolean;
|
||||
}>;
|
||||
[key: string]: unknown;
|
||||
}> }>(
|
||||
`/Users/${this.source.userId}/Items?${queryParams}`
|
||||
);
|
||||
const response = await this.fetch<EmbyItemsResponse<EmbyAlbum>>(
|
||||
`/Users/${this.source.userId}/Items?${queryParams}`
|
||||
);
|
||||
|
||||
return response.Items.map(item => ({
|
||||
id: item.Id,
|
||||
@@ -170,8 +162,8 @@ export class EmbyDriver extends SourceDriver {
|
||||
isFolder: item.IsFolder || false,
|
||||
albumArtist: item.AlbumArtist,
|
||||
dateCreated: item.DateCreated ? new Date(item.DateCreated).getTime() : undefined,
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder })) || [],
|
||||
...item,
|
||||
metadataJson: JSON.stringify(item),
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder, metadataJson: JSON.stringify(artist) })) || [],
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -179,20 +171,9 @@ export class EmbyDriver extends SourceDriver {
|
||||
* Get a specific album
|
||||
*/
|
||||
async getAlbum(albumId: string): Promise<Album> {
|
||||
const item = await this.fetch<{
|
||||
Id: string;
|
||||
Name: string;
|
||||
ProductionYear?: number;
|
||||
IsFolder: boolean;
|
||||
AlbumArtist?: string;
|
||||
DateCreated?: string;
|
||||
ArtistItems?: Array<{
|
||||
Id: string;
|
||||
Name: string;
|
||||
IsFolder: boolean;
|
||||
}>;
|
||||
[key: string]: unknown;
|
||||
}>(`/Users/${this.source.userId}/Items/${albumId}`);
|
||||
const item = await this.fetch<EmbyAlbum>(
|
||||
`/Users/${this.source.userId}/Items/${albumId}`
|
||||
);
|
||||
|
||||
return {
|
||||
id: item.Id,
|
||||
@@ -201,8 +182,8 @@ export class EmbyDriver extends SourceDriver {
|
||||
isFolder: item.IsFolder || false,
|
||||
albumArtist: item.AlbumArtist,
|
||||
dateCreated: item.DateCreated ? new Date(item.DateCreated).getTime() : undefined,
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder })) || [],
|
||||
...item,
|
||||
metadataJson: JSON.stringify(item),
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder, metadataJson: JSON.stringify(artist) })) || [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -221,25 +202,9 @@ export class EmbyDriver extends SourceDriver {
|
||||
Limit: limit.toString(),
|
||||
});
|
||||
|
||||
const response = await this.fetch<{ Items: Array<{
|
||||
Id: string;
|
||||
Name: string;
|
||||
AlbumId?: string;
|
||||
Album?: string;
|
||||
AlbumArtist?: string;
|
||||
ProductionYear?: number;
|
||||
IndexNumber?: number;
|
||||
ParentIndexNumber?: number;
|
||||
RunTimeTicks?: number;
|
||||
ArtistItems?: Array<{
|
||||
Id: string;
|
||||
Name: string;
|
||||
IsFolder: boolean;
|
||||
}>;
|
||||
[key: string]: unknown;
|
||||
}> }>(
|
||||
`/Users/${this.source.userId}/Items?${queryParams}`
|
||||
);
|
||||
const response = await this.fetch<EmbyItemsResponse<EmbyTrack>>(
|
||||
`/Users/${this.source.userId}/Items?${queryParams}`
|
||||
);
|
||||
|
||||
return response.Items.map(item => ({
|
||||
id: item.Id,
|
||||
@@ -251,8 +216,8 @@ export class EmbyDriver extends SourceDriver {
|
||||
indexNumber: item.IndexNumber,
|
||||
parentIndexNumber: item.ParentIndexNumber,
|
||||
runTimeTicks: item.RunTimeTicks,
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder })) || [],
|
||||
...item,
|
||||
metadataJson: JSON.stringify(item),
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder, metadataJson: JSON.stringify(artist) })) || [],
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -359,7 +324,7 @@ export class EmbyDriver extends SourceDriver {
|
||||
indexNumber: item.IndexNumber,
|
||||
parentIndexNumber: item.ParentIndexNumber,
|
||||
runTimeTicks: item.RunTimeTicks,
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder })) || [],
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder, metadataJson: JSON.stringify(artist) })) || [],
|
||||
...item,
|
||||
}));
|
||||
}
|
||||
@@ -446,7 +411,7 @@ export class EmbyDriver extends SourceDriver {
|
||||
isFolder: item.IsFolder || false,
|
||||
albumArtist: item.AlbumArtist,
|
||||
dateCreated: item.DateCreated ? new Date(item.DateCreated).getTime() : undefined,
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder })) || [],
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder, metadataJson: JSON.stringify(artist) })) || [],
|
||||
...item,
|
||||
}));
|
||||
}
|
||||
@@ -488,7 +453,7 @@ export class EmbyDriver extends SourceDriver {
|
||||
isFolder: item.IsFolder || false,
|
||||
albumArtist: item.AlbumArtist,
|
||||
dateCreated: item.DateCreated ? new Date(item.DateCreated).getTime() : undefined,
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder })) || [],
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder, metadataJson: JSON.stringify(artist) })) || [],
|
||||
...item,
|
||||
}));
|
||||
}
|
||||
@@ -536,7 +501,7 @@ export class EmbyDriver extends SourceDriver {
|
||||
indexNumber: item.IndexNumber,
|
||||
parentIndexNumber: item.ParentIndexNumber,
|
||||
runTimeTicks: item.RunTimeTicks,
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder })) || [],
|
||||
artistItems: item.ArtistItems?.map(artist => ({ id: artist.Id, name: artist.Name, isFolder: artist.IsFolder, metadataJson: JSON.stringify(artist) })) || [],
|
||||
...item,
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user