Compare commits
23 Commits
345af9d759
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5dea3be1f1 | ||
|
|
dac21bbe23 | ||
|
|
08dd0a38a6 | ||
|
|
b856269591 | ||
|
|
dc5c541bc4 | ||
|
|
6faebd723d | ||
|
|
478e154d5d | ||
|
|
9b288ebd63 | ||
|
|
9025960ee0 | ||
|
|
58f4901c0a | ||
|
|
b008ff411d | ||
|
|
9d023ef255 | ||
|
|
fc8e9ebc48 | ||
|
|
aba85207e7 | ||
| 02486aa6f6 | |||
| 3bd93c54fb | |||
|
|
5cb2bd7518 | ||
|
|
34e84d2d6b | ||
|
|
0a115b49e1 | ||
|
|
8e57d724be | ||
|
|
6081892297 | ||
|
|
2910754dd0 | ||
|
|
bce02889b4 |
10
Dockerfile
10
Dockerfile
@@ -1,9 +1,17 @@
|
||||
FROM node:22-alpine
|
||||
FROM node:22-bookworm-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
|
||||
RUN apt update && apt install -y apt-transport-https wget
|
||||
|
||||
RUN wget -O /usr/share/keyrings/gpg-pub-moritzbunkus.gpg https://mkvtoolnix.download/gpg-pub-moritzbunkus.gpg \
|
||||
&& echo "deb [signed-by=/usr/share/keyrings/gpg-pub-moritzbunkus.gpg] https://mkvtoolnix.download/debian/ bookworm main" > /etc/apt/sources.list.d/mkvtoolnix.download.list \
|
||||
&& echo "deb-src [signed-by=/usr/share/keyrings/gpg-pub-moritzbunkus.gpg] https://mkvtoolnix.download/debian/ bookworm main" >> /etc/apt/sources.list.d/mkvtoolnix.download.list
|
||||
|
||||
RUN apt update && apt install -y mkvtoolnix ffmpeg
|
||||
|
||||
RUN npm install --production
|
||||
|
||||
RUN npm install -g pm2
|
||||
|
||||
15
package.json
15
package.json
@@ -9,15 +9,18 @@
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^1.7.7",
|
||||
"bull": "^4.16.3",
|
||||
"cheerio": "^1.0.0",
|
||||
"axios": "^1.11.0",
|
||||
"bull": "^4.16.5",
|
||||
"cheerio": "^1.1.2",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.21.0",
|
||||
"express": "^5.1.0",
|
||||
"ffprobe": "^1.1.2",
|
||||
"ffprobe-static": "^3.1.0",
|
||||
"fs": "^0.0.1-security",
|
||||
"mpd-parser": "^1.3.0",
|
||||
"mpd-parser": "^1.3.1",
|
||||
"path": "^0.12.7",
|
||||
"tar": "^7.4.3",
|
||||
"unzipper": "^0.12.3"
|
||||
"unzipper": "^0.12.3",
|
||||
"xml2js": "^0.6.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,10 @@ const getLocalBinFileInfo = (binType) => {
|
||||
stat: fs.existsSync(path) ? fs.statSync(path) : null,
|
||||
version: getBinVersion(`${BIN_PATH}/.${binType}.version`)
|
||||
}
|
||||
} else if (binType === 'realesrgan') {
|
||||
return {
|
||||
path: `${BIN_PATH}/realesrgan_macos/realesrgan-ncnn-vulkan`
|
||||
};
|
||||
} else {
|
||||
throw new Error(`Bad binType "${binType}" provided`);
|
||||
}
|
||||
@@ -154,7 +158,7 @@ const checkDownloaderUpdate = async () => {
|
||||
localInfos,
|
||||
remoteInfos
|
||||
},
|
||||
newReleaseAvailable: localInfos?.version ? parseInt(localInfos.version) !== remoteInfos?.id : remoteInfos?.name || false,
|
||||
newReleaseAvailable: remoteInfos ? localInfos?.version ? parseInt(localInfos.version) !== remoteInfos?.id : remoteInfos?.name || false : false,
|
||||
filsIsPresent: localInfos?.stat ? true : false
|
||||
}
|
||||
} catch(e) {
|
||||
@@ -186,30 +190,72 @@ const processUpdate = async (data) => {
|
||||
try {
|
||||
let downloadURL = data.binType === 'downloader' ? data.details.remoteInfos.browser_download_url : data.details.remoteInfos.downloadUrl;
|
||||
let filename = data.binType === 'downloader' ? data.details.remoteInfos.name : data.details.remoteInfos.filename;
|
||||
fs.mkdirSync(tmpUpdatePath);
|
||||
fs.mkdirSync(tmpUpdatePath, { recursive: true });
|
||||
const zipDest = `${tmpUpdatePath}/${filename}`;
|
||||
console.log('Will download file from ' + downloadURL);
|
||||
await downloadFile(downloadURL, zipDest);
|
||||
console.log('File downloaded to ' + zipDest)
|
||||
console.log('Will decompress downloaded file');
|
||||
const unzippedFolderDest = `${tmpUpdatePath}/${data.binType}_tmp`
|
||||
fs.mkdirSync(unzippedFolderDest);
|
||||
fs.mkdirSync(unzippedFolderDest, { recursive: true });
|
||||
await extractFile(zipDest, unzippedFolderDest);
|
||||
console.log('Unzipped !');
|
||||
const uncompressedFoldersS = fs.readdirSync(unzippedFolderDest);
|
||||
console.log(uncompressedFoldersS)
|
||||
if (uncompressedFoldersS.length !== 1)
|
||||
throw new Error('Unable to retrieve decompressed folder');
|
||||
const uncompressedFolders = fs.readdirSync(`${unzippedFolderDest}/${uncompressedFoldersS[0]}`);
|
||||
if (uncompressedFolders.length === 0)
|
||||
throw new Error('Unable to retrieve archive content');
|
||||
if (data.binType === 'downloader')
|
||||
fs.renameSync(`${unzippedFolderDest}/${uncompressedFoldersS[0]}/${uncompressedFolders[0]}`, data.details.localInfos.path);
|
||||
else if (data.binType === 'mp4decrypt')
|
||||
fs.renameSync(`${unzippedFolderDest}/${uncompressedFoldersS[0]}/bin/mp4decrypt`, data.details.localInfos.path);
|
||||
|
||||
const extractedItems = fs.readdirSync(unzippedFolderDest);
|
||||
console.log('Extracted items:', extractedItems);
|
||||
|
||||
if (extractedItems.length === 0) {
|
||||
throw new Error('No files found after extraction');
|
||||
}
|
||||
|
||||
if (data.binType === 'downloader') {
|
||||
let binaryPath = null;
|
||||
|
||||
for (const item of extractedItems) {
|
||||
const itemPath = `${unzippedFolderDest}/${item}`;
|
||||
const stat = fs.statSync(itemPath);
|
||||
|
||||
if (stat.isFile() && (item === 'N_m3u8DL-RE' || item.includes('N_m3u8DL-RE'))) {
|
||||
binaryPath = itemPath;
|
||||
break;
|
||||
} else if (stat.isDirectory()) {
|
||||
const subItems = fs.readdirSync(itemPath);
|
||||
const binary = subItems.find(subItem =>
|
||||
subItem === 'N_m3u8DL-RE' || subItem.includes('N_m3u8DL-RE')
|
||||
);
|
||||
if (binary) {
|
||||
binaryPath = `${itemPath}/${binary}`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!binaryPath) {
|
||||
throw new Error('N_m3u8DL-RE binary not found in archive');
|
||||
}
|
||||
|
||||
fs.renameSync(binaryPath, data.details.localInfos.path);
|
||||
|
||||
} else if (data.binType === 'mp4decrypt') {
|
||||
if (extractedItems.length !== 1) {
|
||||
throw new Error('Unable to retrieve decompressed folder for mp4decrypt');
|
||||
}
|
||||
|
||||
const mainFolder = `${unzippedFolderDest}/${extractedItems[0]}`;
|
||||
const mp4decryptPath = `${mainFolder}/bin/mp4decrypt`;
|
||||
|
||||
if (!fs.existsSync(mp4decryptPath)) {
|
||||
throw new Error('mp4decrypt binary not found at expected path: bin/mp4decrypt');
|
||||
}
|
||||
|
||||
fs.renameSync(mp4decryptPath, data.details.localInfos.path);
|
||||
}
|
||||
|
||||
fs.chmodSync(data.details.localInfos.path, 0o755);
|
||||
writeBinVersion(`${BIN_PATH}/.${data.binType}.version`, data.details.remoteInfos[data.binType === 'downloader' ? 'id' : 'version'])
|
||||
|
||||
} catch(e) {
|
||||
console.error('Error during update process:', e);
|
||||
throw e;
|
||||
} finally {
|
||||
fs.rmSync(tmpUpdatePath, { recursive: true, force: true });
|
||||
@@ -250,7 +296,7 @@ const getLatestGithubReleaseAssetUrl = async (owner, repo, assetName) => {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erreur:', error.message);
|
||||
throw error;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user