mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 03:53:09 +02:00
upd: add config option to enable builtin video thumbnail generator
This commit is contained in:
parent
a3c302e756
commit
634259d600
5 changed files with 34 additions and 17 deletions
|
@ -198,6 +198,11 @@ proxyRemoteFiles: true
|
||||||
# https://example.com/thumbnail.webp?thumbnail=1&url=https%3A%2F%2Fstorage.example.com%2Fpath%2Fto%2Fvideo.mp4
|
# https://example.com/thumbnail.webp?thumbnail=1&url=https%3A%2F%2Fstorage.example.com%2Fpath%2Fto%2Fvideo.mp4
|
||||||
#videoThumbnailGenerator: https://example.com
|
#videoThumbnailGenerator: https://example.com
|
||||||
|
|
||||||
|
# Enables the built-in thumbnail generator for remote videos. (default: false)
|
||||||
|
# Only useful if "Cache remote files" is disabled, and "videoThumbnailGenerator" is unset.
|
||||||
|
# Without it, remote video files that are not cached will not have any thumbnails.
|
||||||
|
#enableBuiltinVideoThumbnailGenerator: false
|
||||||
|
|
||||||
# Sign to ActivityPub GET request (default: true)
|
# Sign to ActivityPub GET request (default: true)
|
||||||
signToActivityPubGet: true
|
signToActivityPubGet: true
|
||||||
# check that inbound ActivityPub GET requests are signed ("authorized fetch")
|
# check that inbound ActivityPub GET requests are signed ("authorized fetch")
|
||||||
|
|
|
@ -213,6 +213,11 @@ proxyRemoteFiles: true
|
||||||
# https://example.com/thumbnail.webp?thumbnail=1&url=https%3A%2F%2Fstorage.example.com%2Fpath%2Fto%2Fvideo.mp4
|
# https://example.com/thumbnail.webp?thumbnail=1&url=https%3A%2F%2Fstorage.example.com%2Fpath%2Fto%2Fvideo.mp4
|
||||||
#videoThumbnailGenerator: https://example.com
|
#videoThumbnailGenerator: https://example.com
|
||||||
|
|
||||||
|
# Enables the built-in thumbnail generator for remote videos. (default: false)
|
||||||
|
# Only useful if "Cache remote files" is disabled, and "videoThumbnailGenerator" is unset.
|
||||||
|
# Without it, remote video files that are not cached will not have any thumbnails.
|
||||||
|
#enableBuiltinVideoThumbnailGenerator: false
|
||||||
|
|
||||||
# Sign to ActivityPub GET request (default: true)
|
# Sign to ActivityPub GET request (default: true)
|
||||||
signToActivityPubGet: true
|
signToActivityPubGet: true
|
||||||
# check that inbound ActivityPub GET requests are signed ("authorized fetch")
|
# check that inbound ActivityPub GET requests are signed ("authorized fetch")
|
||||||
|
|
|
@ -86,6 +86,7 @@ type Source = {
|
||||||
mediaProxy?: string;
|
mediaProxy?: string;
|
||||||
proxyRemoteFiles?: boolean;
|
proxyRemoteFiles?: boolean;
|
||||||
videoThumbnailGenerator?: string;
|
videoThumbnailGenerator?: string;
|
||||||
|
enableBuiltinVideoThumbnailGenerator?: boolean;
|
||||||
|
|
||||||
customMOTD?: string[];
|
customMOTD?: string[];
|
||||||
|
|
||||||
|
@ -167,6 +168,7 @@ export type Config = {
|
||||||
mediaProxy: string;
|
mediaProxy: string;
|
||||||
externalMediaProxyEnabled: boolean;
|
externalMediaProxyEnabled: boolean;
|
||||||
videoThumbnailGenerator: string | null;
|
videoThumbnailGenerator: string | null;
|
||||||
|
enableBuiltinVideoThumbnailGenerator: boolean;
|
||||||
redis: RedisOptions & RedisOptionsSource;
|
redis: RedisOptions & RedisOptionsSource;
|
||||||
redisForPubsub: RedisOptions & RedisOptionsSource;
|
redisForPubsub: RedisOptions & RedisOptionsSource;
|
||||||
redisForJobQueue: RedisOptions & RedisOptionsSource;
|
redisForJobQueue: RedisOptions & RedisOptionsSource;
|
||||||
|
@ -272,6 +274,7 @@ export function loadConfig(): Config {
|
||||||
videoThumbnailGenerator: config.videoThumbnailGenerator ?
|
videoThumbnailGenerator: config.videoThumbnailGenerator ?
|
||||||
config.videoThumbnailGenerator.endsWith('/') ? config.videoThumbnailGenerator.substring(0, config.videoThumbnailGenerator.length - 1) : config.videoThumbnailGenerator
|
config.videoThumbnailGenerator.endsWith('/') ? config.videoThumbnailGenerator.substring(0, config.videoThumbnailGenerator.length - 1) : config.videoThumbnailGenerator
|
||||||
: null,
|
: null,
|
||||||
|
enableBuiltinVideoThumbnailGenerator: config.enableBuiltinVideoThumbnailGenerator ?? false,
|
||||||
userAgent: `Misskey/${version} (${config.url})`,
|
userAgent: `Misskey/${version} (${config.url})`,
|
||||||
clientEntry: clientManifest['src/_boot_.ts'],
|
clientEntry: clientManifest['src/_boot_.ts'],
|
||||||
clientManifestExists: clientManifestExists,
|
clientManifestExists: clientManifestExists,
|
||||||
|
|
|
@ -51,12 +51,14 @@ export class VideoProcessingService {
|
||||||
@bindThis
|
@bindThis
|
||||||
public getExternalVideoThumbnailUrl(url: string): string | null {
|
public getExternalVideoThumbnailUrl(url: string): string | null {
|
||||||
if (this.config.videoThumbnailGenerator == null) {
|
if (this.config.videoThumbnailGenerator == null) {
|
||||||
return appendQuery(
|
if (this.config.enableBuiltinVideoThumbnailGenerator) {
|
||||||
`${this.config.url}/proxy/thumbnail.webp`,
|
return appendQuery(
|
||||||
query({
|
`${this.config.url}/proxy/thumbnail.webp`,
|
||||||
url,
|
query({ url }),
|
||||||
}),
|
);
|
||||||
);
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return appendQuery(
|
return appendQuery(
|
||||||
|
|
|
@ -83,12 +83,14 @@ export class FileServerService {
|
||||||
.catch(err => this.errorHandler(request, reply, err));
|
.catch(err => this.errorHandler(request, reply, err));
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.get<{
|
if (this.config.enableBuiltinVideoThumbnailGenerator) {
|
||||||
Querystring: { url: string; };
|
fastify.get<{
|
||||||
}>('/proxy/thumbnail.webp', async (request, reply) => {
|
Querystring: { url: string; };
|
||||||
return await this.videoThumbnailHandler(request, reply)
|
}>('/proxy/thumbnail.webp', async (request, reply) => {
|
||||||
.catch(err => this.errorHandler(request, reply, err));
|
return await this.videoThumbnailHandler(request, reply)
|
||||||
});
|
.catch(err => this.errorHandler(request, reply, err));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
fastify.get<{
|
fastify.get<{
|
||||||
Params: { url: string; };
|
Params: { url: string; };
|
||||||
|
@ -395,7 +397,7 @@ export class FileServerService {
|
||||||
if (file === '404') {
|
if (file === '404') {
|
||||||
reply.code(404);
|
reply.code(404);
|
||||||
reply.header('Cache-Control', 'max-age=86400');
|
reply.header('Cache-Control', 'max-age=86400');
|
||||||
return reply.sendFile('/dummy.png', assets); // TODO: return webp
|
return reply.sendFile('/dummy.png', assets);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file === '204') {
|
if (file === '204') {
|
||||||
|
|
Loading…
Reference in a new issue