Skip to content

Commit

Permalink
Merge branch 'develop' into feat-add-tvdb-indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
TOomaAh authored Nov 3, 2024
2 parents 67a846c + cf59102 commit 2ee5535
Show file tree
Hide file tree
Showing 30 changed files with 776 additions and 342 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ yarn-error.log*
# database
config/db/*.sqlite3*
config/settings.json
config/settings.old.json

# logs
config/logs/*.log*
Expand Down
4 changes: 4 additions & 0 deletions docs/getting-started/aur.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ sidebar_position: 4

# AUR (Arch User Repository)

:::note Disclaimer
This AUR package is not maintained by us but by a third party. Please refer to the maintainer for any issues.
:::

:::info
This method is not recommended for most users. It is intended for advanced users who are using Arch Linux or an Arch-based distribution.
:::
Expand Down
3 changes: 3 additions & 0 deletions overseerr-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,9 @@ paths:
appDataPath:
type: string
example: /app/config
appDataPermissions:
type: boolean
example: true
/settings/main:
get:
summary: Get main settings
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
"sqlite3": "5.1.4",
"swagger-ui-express": "4.6.2",
"swr": "2.2.5",
"typeorm": "0.3.12",
"typeorm": "0.3.11",
"undici": "^6.20.1",
"web-push": "3.5.0",
"winston": "3.8.2",
"winston-daily-rotate-file": "4.7.1",
Expand Down
65 changes: 27 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions server/api/externalapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,28 @@ class ExternalAPI {
this.fetch = fetch;
}

this.baseUrl = baseUrl;
this.params = params;
const url = new URL(baseUrl);

this.defaultHeaders = {
'Content-Type': 'application/json',
Accept: 'application/json',
...((url.username || url.password) && {
Authorization: `Basic ${Buffer.from(
`${url.username}:${url.password}`
).toString('base64')}`,
}),
...options.headers,
};

if (url.username || url.password) {
url.username = '';
url.password = '';
baseUrl = url.toString();
}

this.baseUrl = baseUrl;
this.params = params;

this.cache = options.nodeCache;
}

Expand Down
2 changes: 1 addition & 1 deletion server/api/jellyfin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ class JellyfinAPI extends ExternalAPI {
).AccessToken;
} catch (e) {
logger.error(
`Something went wrong while creating an API key the Jellyfin server: ${e.message}`,
`Something went wrong while creating an API key from the Jellyfin server: ${e.message}`,
{ label: 'Jellyfin API' }
);

Expand Down
2 changes: 1 addition & 1 deletion server/api/plexapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class PlexAPI {
settings.plex.libraries = [];
}

settings.save();
await settings.save();
}

public async getLibraryContents(
Expand Down
13 changes: 13 additions & 0 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import clearCookies from '@server/middleware/clearcookies';
import routes from '@server/routes';
import avatarproxy from '@server/routes/avatarproxy';
import imageproxy from '@server/routes/imageproxy';
import { appDataPermissions } from '@server/utils/appDataVolume';
import { getAppVersion } from '@server/utils/appVersion';
import createCustomProxyAgent from '@server/utils/customProxyAgent';
import restartFlag from '@server/utils/restartFlag';
import { getClientIp } from '@supercharge/request-ip';
import { TypeormStore } from 'connect-typeorm/out';
Expand Down Expand Up @@ -51,6 +53,12 @@ const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();

if (!appDataPermissions()) {
logger.error(
'Something went wrong while checking config folder! Please ensure the config folder is set up properly.\nhttps://docs.jellyseerr.dev/getting-started'
);
}

app
.prepare()
.then(async () => {
Expand All @@ -67,6 +75,11 @@ app
const settings = await getSettings().load();
restartFlag.initializeSettings(settings.main);

// Register HTTP proxy
if (settings.main.proxy.enabled) {
await createCustomProxyAgent(settings.main.proxy);
}

// Migrate library types
if (
settings.plex.libraries.length > 1 &&
Expand Down
21 changes: 18 additions & 3 deletions server/lib/imageproxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ class ImageProxy {
private cacheVersion;
private key;
private baseUrl;
private headers: HeadersInit | null = null;

constructor(
key: string,
baseUrl: string,
options: {
cacheVersion?: number;
rateLimitOptions?: RateLimitOptions;
headers?: HeadersInit;
} = {}
) {
this.cacheVersion = options.cacheVersion ?? 1;
Expand All @@ -155,9 +157,13 @@ class ImageProxy {
} else {
this.fetch = fetch;
}
this.headers = options.headers || null;
}

public async getImage(path: string): Promise<ImageResponse> {
public async getImage(
path: string,
fallbackPath?: string
): Promise<ImageResponse> {
const cacheKey = this.getCacheKey(path);

const imageResponse = await this.get(cacheKey);
Expand All @@ -166,7 +172,11 @@ class ImageProxy {
const newImage = await this.set(path, cacheKey);

if (!newImage) {
throw new Error('Failed to load image');
if (fallbackPath) {
return await this.getImage(fallbackPath);
} else {
throw new Error('Failed to load image');
}
}

return newImage;
Expand Down Expand Up @@ -247,7 +257,12 @@ class ImageProxy {
: '/'
: '') +
(path.startsWith('/') ? path.slice(1) : path);
const response = await this.fetch(href);
const response = await this.fetch(href, {
headers: this.headers || undefined,
});
if (!response.ok) {
return null;
}
const arrayBuffer = await response.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);

Expand Down
2 changes: 1 addition & 1 deletion server/lib/scanners/plex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class PlexScanner
});

settings.plex.libraries = newLibraries;
settings.save();
await settings.save();
}
} else {
for (const library of this.libraries) {
Expand Down
Loading

0 comments on commit 2ee5535

Please sign in to comment.