mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-07 20:10:03 +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();
|
||||
}
|
||||
|
||||
app.listen(backendPort,function(){
|
||||
const server = app.listen(backendPort,function(){
|
||||
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) {
|
||||
@@ -616,23 +621,18 @@ async function setConfigFromEnv() {
|
||||
}
|
||||
|
||||
async function loadConfig() {
|
||||
logger.info('loading config')
|
||||
loadConfigValues();
|
||||
|
||||
// connect to DB
|
||||
logger.info('connecting to db')
|
||||
await db_api.connectToDB();
|
||||
|
||||
// creates archive path if missing
|
||||
logger.info('ensuring archive path of ' + archivePath)
|
||||
await fs.ensureDir(archivePath);
|
||||
|
||||
// check migrations
|
||||
logger.info('checking migrations')
|
||||
await checkMigrations();
|
||||
|
||||
// now this is done here due to youtube-dl's repo takedown
|
||||
logger.info('starting youtube dl')
|
||||
await startYoutubeDL();
|
||||
|
||||
// get subscriptions
|
||||
@@ -2479,9 +2479,10 @@ app.get('/api/stream', optionalJwt, async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/thumbnail/:path', optionalJwt, async (req, res) => {
|
||||
let file_path = decodeURIComponent(req.params.path);
|
||||
if (fs.existsSync(file_path)) path.isAbsolute(file_path) ? res.sendFile(file_path) : res.sendFile(path.join('./', file_path));
|
||||
app.get('/api/thumbnail/:uid', optionalJwt, async (req, res) => {
|
||||
const file_obj = await db_api.getRecord('files', {uid: req.params.uid});
|
||||
const file_path = file_obj['thumbnailPath'];
|
||||
if (fs.existsSync(file_path)) res.sendFile(file_path, { root: '.' });
|
||||
else res.sendStatus(404);
|
||||
});
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ export class UnifiedFileCardComponent implements OnInit {
|
||||
}
|
||||
|
||||
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 blob = new Blob([new Uint8Array(this.file_obj.thumbnailBlob.data)], {type: mime});
|
||||
const bloburl = URL.createObjectURL(blob);
|
||||
|
||||
Reference in New Issue
Block a user