diff --git a/README.md b/README.md index a477198..7a64eed 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ No installation is required on the desktop. The app is portable. ### Docker ⚠️ Currently, the docker image is only built for `linux/amd64` systems which means it cannot be run on ARM-based systems -like older Raspberry Pis. +like Raspberry Pis. You can either build the docker image locally and run using [`docker-compose.yaml`](docker-compose.yaml) or use the published [official image](https://hub.docker.com/r/m4heshd/ufc-ripper). diff --git a/server-modules/bin-util.js b/server-modules/bin-util.js index 69b4ca6..3eb5594 100644 --- a/server-modules/bin-util.js +++ b/server-modules/bin-util.js @@ -23,6 +23,7 @@ const bins = { module.exports = { binPath, validateBins, + getListFormatsOutput, openDLSession, cancelDLSession, openDLDir, @@ -42,6 +43,41 @@ function validateBins(cb) { } } +function getListFormatsOutput(hls) { + return new Promise((resolve, reject) => { + const args = ['--print', '%(formats.:.{format_id,resolution,fps,tbr,vcodec,acodec})j', hls]; + let output = {}; + + const yt_dlp = spawn(path.join(bins.ytDlp), args); + + yt_dlp.on('error', (error) => { + console.error(`${getConfig('verboseLogging') ? error.stack : error}\n`); + reject(createUFCRError(error, 'Failed to start the yt-dlp process')); + }); + + yt_dlp.on('close', (code) => { + if (code === 0) { + if (Array.isArray(output) && output.length) { + resolve(output); + } else { + reject(createUFCRError('Response does not contain any streams. Please check the URL you entered')); + } + } else { + reject(createUFCRError(output, 'Format request process ended with error. Check the console for error information')); + } + }); + + yt_dlp.stdout.on('data', (data) => { + output = JSON.parse(data.toString()); + }); + + yt_dlp.stderr.on('data', (data) => { + if (getConfig('verboseLogging')) console.error(data.toString()); + output += data.toString(); + }); + }); +} + function openDLSession(VOD, isRestart, cb) { const {qID, title, hls, vodURL} = VOD; const { diff --git a/server-modules/io-util.js b/server-modules/io-util.js index 0f21b24..54969fb 100644 --- a/server-modules/io-util.js +++ b/server-modules/io-util.js @@ -38,6 +38,7 @@ function initIO(httpServer) { socket.on('get-dlq', cb => cb(DLQ)); socket.on('login', login); socket.on('verify-url', verifyVOD); + socket.on('get-formats', getFormats); socket.on('download', downloadVOD); socket.on('cancel-download', cancelDownload); socket.on('clear-dlq', clearDLQ); @@ -69,6 +70,14 @@ async function verifyVOD(url, cb) { } } +async function getFormats(url, cb) { + try { + await sendFormats(url, cb); + } catch (error) { + sendError(error, cb); + } +} + async function downloadVOD(VOD, isRestart, cb) { try { require('./bin-util').openDLSession( @@ -149,6 +158,17 @@ function sendVODMeta(VOD, cb) { }); } +async function sendFormats(url, cb) { + const VOD = await getVODMeta(url); + const hls = await getVODStream(VOD.id); + const formats = await require('./bin-util').getListFormatsOutput(hls); + + cb({ + title: VOD.title, + formats + }); +} + function sendVODDownload(VOD, isRestart, cb) { DLQ[VOD.qID] = { ...VOD, diff --git a/src/assets/styles/common.scss b/src/assets/styles/common.scss index d98933a..19c4744 100644 --- a/src/assets/styles/common.scss +++ b/src/assets/styles/common.scss @@ -3,6 +3,8 @@ body { --failure: #fa3434; --failure-bg: #3a0d06; --warning: #fdd716; + --secondary-text: #ffde39; + --inactive-text: #7c7c7c; } .center-content { diff --git a/src/components/ModViewFormats.vue b/src/components/ModViewFormats.vue new file mode 100644 index 0000000..bb2c435 --- /dev/null +++ b/src/components/ModViewFormats.vue @@ -0,0 +1,125 @@ + + + + + diff --git a/src/modules/ws-util.js b/src/modules/ws-util.js index a220fde..7308b23 100644 --- a/src/modules/ws-util.js +++ b/src/modules/ws-util.js @@ -103,6 +103,10 @@ export function useWSUtil() { return emitPromise('verify-url', url); } + function getFormats(url) { + return emitPromise('get-formats', url); + } + function downloadVOD(VOD, isRestart) { return emitPromise('download', VOD, isRestart); } @@ -139,6 +143,7 @@ export function useWSUtil() { saveConfig, login, verifyURL, + getFormats, downloadVOD, cancelDownload, clearDLQ, diff --git a/src/pages/Landing.vue b/src/pages/Landing.vue index 13d3e7b..fd8ed6c 100644 --- a/src/pages/Landing.vue +++ b/src/pages/Landing.vue @@ -33,6 +33,15 @@ download + +