feat: implement import users from Jellyfin button

This commit is contained in:
notfakie
2022-04-27 08:06:39 +12:00
parent 103350fe14
commit 9e2f3f0639
26 changed files with 468 additions and 33 deletions

View File

@@ -15,6 +15,10 @@ export interface JellyfinLoginResponse {
AccessToken: string;
}
export interface JellyfinUserListResponse {
users: Array<JellyfinUserResponse>;
}
export interface JellyfinLibrary {
type: 'show' | 'movie';
key: string;
@@ -134,6 +138,19 @@ class JellyfinAPI {
}
}
public async getUsers(): Promise<JellyfinUserListResponse> {
try {
const account = await this.axios.get(`/Users`);
return { users: account.data };
} catch (e) {
logger.error(
`Something went wrong while getting the account from the Jellyfin server: ${e.message}`,
{ label: 'Jellyfin API' }
);
throw new Error('Invalid auth token');
}
}
public async getUser(): Promise<JellyfinUserResponse> {
try {
const account = await this.axios.get<JellyfinUserResponse>(