mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2025-12-30 13:39:12 -05:00
Compare commits
1 Commits
develop
...
preview-fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dcea6e965d |
@@ -4,27 +4,40 @@ import { Router } from 'express';
|
|||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
const tmdbImageProxy = new ImageProxy('tmdb', 'https://image.tmdb.org', {
|
// Delay the initialization of ImageProxy instances until the proxy (if any) is properly configured
|
||||||
rateLimitOptions: {
|
let _tmdbImageProxy: ImageProxy;
|
||||||
maxRequests: 20,
|
function initTmdbImageProxy() {
|
||||||
maxRPS: 50,
|
if (!_tmdbImageProxy) {
|
||||||
},
|
_tmdbImageProxy = new ImageProxy('tmdb', 'https://image.tmdb.org', {
|
||||||
});
|
rateLimitOptions: {
|
||||||
const tvdbImageProxy = new ImageProxy('tvdb', 'https://artworks.thetvdb.com', {
|
maxRequests: 20,
|
||||||
rateLimitOptions: {
|
maxRPS: 50,
|
||||||
maxRequests: 20,
|
},
|
||||||
maxRPS: 50,
|
});
|
||||||
},
|
}
|
||||||
});
|
return _tmdbImageProxy;
|
||||||
|
}
|
||||||
|
let _tvdbImageProxy: ImageProxy;
|
||||||
|
function initTvdbImageProxy() {
|
||||||
|
if (!_tvdbImageProxy) {
|
||||||
|
_tvdbImageProxy = new ImageProxy('tvdb', 'https://artworks.thetvdb.com', {
|
||||||
|
rateLimitOptions: {
|
||||||
|
maxRequests: 20,
|
||||||
|
maxRPS: 50,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return _tvdbImageProxy;
|
||||||
|
}
|
||||||
|
|
||||||
router.get('/:type/*', async (req, res) => {
|
router.get('/:type/*', async (req, res) => {
|
||||||
const imagePath = req.path.replace(/^\/\w+/, '');
|
const imagePath = req.path.replace(/^\/\w+/, '');
|
||||||
try {
|
try {
|
||||||
let imageData;
|
let imageData;
|
||||||
if (req.params.type === 'tmdb') {
|
if (req.params.type === 'tmdb') {
|
||||||
imageData = await tmdbImageProxy.getImage(imagePath);
|
imageData = await initTmdbImageProxy().getImage(imagePath);
|
||||||
} else if (req.params.type === 'tvdb') {
|
} else if (req.params.type === 'tvdb') {
|
||||||
imageData = await tvdbImageProxy.getImage(imagePath);
|
imageData = await initTvdbImageProxy().getImage(imagePath);
|
||||||
} else {
|
} else {
|
||||||
logger.error('Unsupported image type', {
|
logger.error('Unsupported image type', {
|
||||||
imagePath,
|
imagePath,
|
||||||
|
|||||||
Reference in New Issue
Block a user