mirror of
https://github.com/jellyfin/jellyfin-chromecast.git
synced 2024-11-23 05:59:50 +00:00
Merge pull request #692 from 3flex/axios-authAjaxUser
Migrate calls to authAjaxUser to jellyfin-sdk-typescript
This commit is contained in:
commit
8c99ff424f
@ -1,4 +1,5 @@
|
||||
import type { BaseItemDto } from '@jellyfin/sdk/lib/generated-client';
|
||||
import { getItemsApi, getUserLibraryApi } from '@jellyfin/sdk/lib/utils/api';
|
||||
import { AppStatus } from '../types/appStatus';
|
||||
import { parseISO8601Date, TicksPerSecond, ticksToSeconds } from '../helpers';
|
||||
import { JellyfinApi } from './jellyfinApi';
|
||||
@ -223,15 +224,14 @@ export abstract class DocumentManager {
|
||||
return;
|
||||
}
|
||||
|
||||
const item: BaseItemDto = await JellyfinApi.authAjaxUser(
|
||||
`Items/${itemId}`,
|
||||
{
|
||||
dataType: 'json',
|
||||
type: 'GET'
|
||||
}
|
||||
);
|
||||
const response = await getUserLibraryApi(
|
||||
JellyfinApi.jellyfinApi
|
||||
).getItem({
|
||||
itemId,
|
||||
userId: JellyfinApi.userId
|
||||
});
|
||||
|
||||
DocumentManager.showItem(item);
|
||||
DocumentManager.showItem(response.data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -353,21 +353,19 @@ export abstract class DocumentManager {
|
||||
* @returns promise waiting for the backdrop to be set
|
||||
*/
|
||||
private static async setRandomUserBackdrop(): Promise<void> {
|
||||
const result = await JellyfinApi.authAjaxUser('Items', {
|
||||
dataType: 'json',
|
||||
query: {
|
||||
ImageTypes: 'Backdrop',
|
||||
IncludeItemTypes: 'Movie,Series',
|
||||
Limit: 1,
|
||||
MaxOfficialRating: 'PG-13',
|
||||
Recursive: true,
|
||||
SortBy: 'Random'
|
||||
// Although we're limiting to what the user has access to,
|
||||
// not everyone will want to see adult backdrops rotating on their TV.
|
||||
},
|
||||
type: 'GET'
|
||||
const response = await getItemsApi(JellyfinApi.jellyfinApi).getItems({
|
||||
imageTypes: ['Backdrop'],
|
||||
includeItemTypes: ['Movie', 'Series'],
|
||||
limit: 1,
|
||||
// Although we're limiting to what the user has access to,
|
||||
// not everyone will want to see adult backdrops rotating on their TV.
|
||||
maxOfficialRating: 'PG-13',
|
||||
recursive: true,
|
||||
sortBy: ['Random']
|
||||
});
|
||||
|
||||
const result = response.data;
|
||||
|
||||
let src: string | null = null;
|
||||
let item: BaseItemDto | null = null;
|
||||
|
||||
|
@ -3,7 +3,7 @@ import type {
|
||||
MediaStream,
|
||||
MediaSourceInfo
|
||||
} from '@jellyfin/sdk/lib/generated-client';
|
||||
import { getSessionApi } from '@jellyfin/sdk/lib/utils/api';
|
||||
import { getSessionApi, getUserLibraryApi } from '@jellyfin/sdk/lib/utils/api';
|
||||
import {
|
||||
getCurrentPositionTicks,
|
||||
getReportingParams,
|
||||
@ -631,12 +631,15 @@ export async function onStopPlayerBeforePlaybackDone(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
options: any
|
||||
): Promise<void> {
|
||||
const data = await JellyfinApi.authAjaxUser(`Items/${item.Id}`, {
|
||||
dataType: 'json',
|
||||
type: 'GET'
|
||||
});
|
||||
if (item.Id) {
|
||||
const response = await getUserLibraryApi(
|
||||
JellyfinApi.jellyfinApi
|
||||
).getItem({
|
||||
itemId: item.Id
|
||||
});
|
||||
|
||||
PlaybackManager.playItemInternal(data, options);
|
||||
PlaybackManager.playItemInternal(response.data, options);
|
||||
}
|
||||
}
|
||||
|
||||
let lastBitrateDetect = 0;
|
||||
|
@ -17,7 +17,8 @@ import type {
|
||||
import {
|
||||
getInstantMixApi,
|
||||
getItemsApi,
|
||||
getTvShowsApi
|
||||
getTvShowsApi,
|
||||
getUserApi
|
||||
} from '@jellyfin/sdk/lib/utils/api';
|
||||
import { JellyfinApi } from './components/jellyfinApi';
|
||||
import { PlaybackManager, PlaybackState } from './components/playbackManager';
|
||||
@ -593,11 +594,10 @@ export async function getEpisodesForPlayback(
|
||||
* Get user object for the current user
|
||||
* @returns user object
|
||||
*/
|
||||
export function getUser(): Promise<UserDto> {
|
||||
return JellyfinApi.authAjaxUser('', {
|
||||
dataType: 'json',
|
||||
type: 'GET'
|
||||
});
|
||||
export async function getUser(): Promise<UserDto> {
|
||||
const response = await getUserApi(JellyfinApi.jellyfinApi).getCurrentUser();
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user