feat(rebase): rebase

This commit is contained in:
Aiden Vigue
2021-02-15 14:26:25 -05:00
parent 19b51592ea
commit 29274614c3
13 changed files with 85 additions and 94 deletions

View File

@@ -71,19 +71,18 @@ export interface JellyfinLibraryItemExtended extends JellyfinLibraryItem {
class JellyfinAPI {
private authToken?: string;
private userId?: string;
private jellyfinHost: string;
private axios: AxiosInstance;
constructor(jellyfinHost: string, authToken?: string) {
constructor(jellyfinHost: string, authToken?: string, userId?: string) {
this.jellyfinHost = jellyfinHost;
this.authToken = authToken;
this.userId = userId;
let authHeaderVal = '';
if (this.authToken) {
authHeaderVal =
'MediaBrowser Client="Overseerr", Device="Axios", DeviceId="TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NDsgcnY6ODUuMCkgR2Vja28vMjAxMDAxMDEgRmlyZWZveC84NS4wfDE2MTI5MjcyMDM5NzM1", Version="10.8.0", Token="' +
authToken +
'"';
authHeaderVal = `MediaBrowser Client="Overseerr", Device="Axios", DeviceId="TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NDsgcnY6ODUuMCkgR2Vja28vMjAxMDAxMDEgRmlyZWZveC84NS4wfDE2MTI5MjcyMDM5NzM1", Version="10.8.0", Token="${authToken}"`;
} else {
authHeaderVal =
'MediaBrowser Client="Overseerr", Device="Axios", DeviceId="TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NDsgcnY6ODUuMCkgR2Vja28vMjAxMDAxMDEgRmlyZWZveC84NS4wfDE2MTI5MjcyMDM5NzM1", Version="10.8.0"';
@@ -117,9 +116,26 @@ class JellyfinAPI {
}
}
public async getServerName(): Promise<string> {
try {
const account = await this.axios.get<JellyfinUserResponse>(
`/System/Info/Public'}`
);
return account.data.ServerName;
} catch (e) {
logger.error(
`Something went wrong while getting the server name from the Jellyfin server: ${e.message}`,
{ label: 'Jellyfin API' }
);
throw new Error('girl idk');
}
}
public async getUser(): Promise<JellyfinUserResponse> {
try {
const account = await this.axios.get<JellyfinUserResponse>('/Users/Me');
const account = await this.axios.get<JellyfinUserResponse>(
`/Users/${this.userId ?? 'Me'}`
);
return account.data;
} catch (e) {
logger.error(

View File

@@ -1,5 +1,6 @@
export enum MediaServerType {
PLEX = 1,
JELLYFIN, //also works for emby (identical APIs, etc)
JELLYFIN,
EMBY,
NOT_CONFIGURED,
}

View File

@@ -7,6 +7,7 @@ export interface SettingsAboutResponse {
export interface PublicSettingsResponse {
jellyfinHost?: string;
jellyfinServerName?: string;
initialized: boolean;
applicationTitle: string;
hideAvailable: boolean;

View File

@@ -552,7 +552,7 @@ class JobJellyfinSync {
this.running = true;
const userRepository = getRepository(User);
const admin = await userRepository.findOne({
select: ['id', 'jellyfinAuthToken'],
select: ['id', 'jellyfinAuthToken', 'jellyfinId'],
order: { id: 'ASC' },
});
@@ -562,7 +562,8 @@ class JobJellyfinSync {
this.jfClient = new JellyfinAPI(
settings.jellyfin.hostname ?? '',
admin.jellyfinAuthToken ?? ''
admin.jellyfinAuthToken ?? '',
admin.jellyfinId ?? ''
);
this.libraries = settings.jellyfin.libraries.filter(

View File

@@ -99,6 +99,7 @@ interface FullPublicSettings extends PublicSettings {
originalLanguage: string;
mediaServerType: number;
jellyfinHost?: string;
jellyfinServerName?: string;
}
export interface NotificationAgentConfig {
@@ -368,17 +369,10 @@ class Settings {
series4kEnabled: this.data.sonarr.some(
(sonarr) => sonarr.is4k && sonarr.isDefault
),
<<<<<<< HEAD
region: this.data.main.region,
originalLanguage: this.data.main.originalLanguage,
=======
mediaServerType: this.main.mediaServerType,
<<<<<<< HEAD
jfHost: this.jellyfin.hostname ?? '',
>>>>>>> feat(all): add initial Jellyfin/Emby support
=======
jellyfinHost: this.jellyfin.hostname,
>>>>>>> feat(rebase): rebase
};
}

View File

@@ -181,6 +181,7 @@ authRoutes.post('/jellyfin', async (req, res, next) => {
: body.hostname;
// First we need to attempt to log the user in to jellyfin
const jellyfinserver = new JellyfinAPI(hostname ?? '');
settings.jellyfin.name = await jellyfinserver.getServerName();
const account = await jellyfinserver.login(body.username, body.password);