mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-20 13:43:19 +03:00
Server autocloses on crash
Thumbnails are now retrieved using file UID
This commit is contained in:
@@ -327,9 +327,14 @@ async function startServer() {
|
|||||||
await setPortItemFromENV();
|
await setPortItemFromENV();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.listen(backendPort,function(){
|
const server = app.listen(backendPort,function(){
|
||||||
logger.info(`YoutubeDL-Material ${CONSTS['CURRENT_VERSION']} started on PORT ${backendPort}`);
|
logger.info(`YoutubeDL-Material ${CONSTS['CURRENT_VERSION']} started on PORT ${backendPort}`);
|
||||||
});
|
});
|
||||||
|
process.on('uncaughtException', err => {
|
||||||
|
logger.error('Server has crashed!');
|
||||||
|
logger.error(err);
|
||||||
|
server.close();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function restartServer(is_update = false) {
|
async function restartServer(is_update = false) {
|
||||||
@@ -616,23 +621,18 @@ async function setConfigFromEnv() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadConfig() {
|
async function loadConfig() {
|
||||||
logger.info('loading config')
|
|
||||||
loadConfigValues();
|
loadConfigValues();
|
||||||
|
|
||||||
// connect to DB
|
// connect to DB
|
||||||
logger.info('connecting to db')
|
|
||||||
await db_api.connectToDB();
|
await db_api.connectToDB();
|
||||||
|
|
||||||
// creates archive path if missing
|
// creates archive path if missing
|
||||||
logger.info('ensuring archive path of ' + archivePath)
|
|
||||||
await fs.ensureDir(archivePath);
|
await fs.ensureDir(archivePath);
|
||||||
|
|
||||||
// check migrations
|
// check migrations
|
||||||
logger.info('checking migrations')
|
|
||||||
await checkMigrations();
|
await checkMigrations();
|
||||||
|
|
||||||
// now this is done here due to youtube-dl's repo takedown
|
// now this is done here due to youtube-dl's repo takedown
|
||||||
logger.info('starting youtube dl')
|
|
||||||
await startYoutubeDL();
|
await startYoutubeDL();
|
||||||
|
|
||||||
// get subscriptions
|
// get subscriptions
|
||||||
@@ -2479,9 +2479,10 @@ app.get('/api/stream', optionalJwt, async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/api/thumbnail/:path', optionalJwt, async (req, res) => {
|
app.get('/api/thumbnail/:uid', optionalJwt, async (req, res) => {
|
||||||
let file_path = decodeURIComponent(req.params.path);
|
const file_obj = await db_api.getRecord('files', {uid: req.params.uid});
|
||||||
if (fs.existsSync(file_path)) path.isAbsolute(file_path) ? res.sendFile(file_path) : res.sendFile(path.join('./', file_path));
|
const file_path = file_obj['thumbnailPath'];
|
||||||
|
if (fs.existsSync(file_path)) res.sendFile(file_path, { root: '.' });
|
||||||
else res.sendStatus(404);
|
else res.sendStatus(404);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export class UnifiedFileCardComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.file_obj && this.file_obj.thumbnailPath) {
|
if (this.file_obj && this.file_obj.thumbnailPath) {
|
||||||
this.thumbnailBlobURL = `${this.baseStreamPath}thumbnail/${encodeURIComponent(this.file_obj.thumbnailPath)}${this.jwtString}`;
|
this.thumbnailBlobURL = `${this.baseStreamPath}thumbnail/${this.file_obj.uid}${this.jwtString}`;
|
||||||
/*const mime = getMimeByFilename(this.file_obj.thumbnailPath);
|
/*const mime = getMimeByFilename(this.file_obj.thumbnailPath);
|
||||||
const blob = new Blob([new Uint8Array(this.file_obj.thumbnailBlob.data)], {type: mime});
|
const blob = new Blob([new Uint8Array(this.file_obj.thumbnailBlob.data)], {type: mime});
|
||||||
const bloburl = URL.createObjectURL(blob);
|
const bloburl = URL.createObjectURL(blob);
|
||||||
|
|||||||
Reference in New Issue
Block a user