mirror of
https://github.com/FJurmanovic/sugarr.git
synced 2026-11-11 15:51:09 +00:00
62 lines
1.5 KiB
TypeScript
62 lines
1.5 KiB
TypeScript
import { ApiClient } from '../../../core/http/ApiClient';
|
|
import type { Movie } from '../../models';
|
|
import { ItemsEndpoint } from './endpoints/ItemsEndpoint';
|
|
|
|
export class JellyfinClient extends ApiClient {
|
|
private readonly endpoint = new ItemsEndpoint();
|
|
|
|
constructor(
|
|
baseUrl: string,
|
|
private readonly apiKey: string,
|
|
private readonly userId: string
|
|
) {
|
|
super(baseUrl);
|
|
}
|
|
|
|
protected buildHeaders(): Record<string, string> {
|
|
return {
|
|
...super.buildHeaders(),
|
|
Authorization: `MediaBrowser Token="${this.apiKey}"`,
|
|
};
|
|
}
|
|
|
|
getFavoriteMovies(): Promise<Movie[]> {
|
|
return this.request(this.endpoint, {
|
|
userId: this.userId,
|
|
query: {
|
|
IncludeItemTypes: 'Movie',
|
|
Recursive: 'true',
|
|
IsFavorite: 'true',
|
|
Fields: 'ProviderIds,Genres,CommunityRating,UserData',
|
|
},
|
|
});
|
|
}
|
|
|
|
getRecentlyWatched(): Promise<Movie[]> {
|
|
return this.request(this.endpoint, {
|
|
userId: this.userId,
|
|
query: {
|
|
IncludeItemTypes: 'Movie',
|
|
Recursive: 'true',
|
|
Filters: 'IsPlayed',
|
|
SortBy: 'DatePlayed',
|
|
SortOrder: 'Descending',
|
|
Limit: '50',
|
|
Fields: 'ProviderIds,Genres,CommunityRating,UserData',
|
|
},
|
|
});
|
|
}
|
|
|
|
getAllMovies(): Promise<Movie[]> {
|
|
return this.request(this.endpoint, {
|
|
userId: this.userId,
|
|
query: {
|
|
IncludeItemTypes: 'Movie',
|
|
Recursive: 'true',
|
|
Fields: 'ProviderIds',
|
|
Limit: '10000',
|
|
},
|
|
});
|
|
}
|
|
}
|