Refactor api hooks
This commit is contained in:
parent
331f05b77d
commit
c8ea7322fd
6 changed files with 80 additions and 61 deletions
23
src/utils/jellyfin-apiclient/compat.ts
Normal file
23
src/utils/jellyfin-apiclient/compat.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { Api, Jellyfin } from '@jellyfin/sdk';
|
||||
import { ApiClient } from 'jellyfin-apiclient';
|
||||
|
||||
/**
|
||||
* Returns an SDK Api instance using the same parameters as the provided ApiClient.
|
||||
* @param {ApiClient} apiClient The (legacy) ApiClient.
|
||||
* @returns {Api} An equivalent SDK Api instance.
|
||||
*/
|
||||
export const toApi = (apiClient: ApiClient): Api => {
|
||||
return (new Jellyfin({
|
||||
clientInfo: {
|
||||
name: apiClient.appName(),
|
||||
version: apiClient.appVersion()
|
||||
},
|
||||
deviceInfo: {
|
||||
name: apiClient.deviceName(),
|
||||
id: apiClient.deviceId()
|
||||
}
|
||||
})).createApi(
|
||||
apiClient.serverAddress(),
|
||||
apiClient.accessToken()
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue