From aa1e36ae3504d406a9cf668aedb4c490fa3c86a8 Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Wed, 21 Jul 2021 23:59:00 -0600 Subject: [PATCH 1/5] Updated dockerfile to download python3 for yt-dlp support --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 68d648d..957657b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ RUN addgroup -S $USER -g $GID && adduser -D -S $USER -G $USER -u $UID RUN apk add --no-cache \ ffmpeg \ npm \ - python2 \ + python3 \ su-exec \ && apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ \ atomicparsley From f0e73c1708062aed2f8a6f8b678bf3c8bf9e3b82 Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Thu, 22 Jul 2021 01:50:51 -0600 Subject: [PATCH 2/5] python3 now aliases as python in Dockerfile --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 957657b..db83c4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,6 +34,9 @@ RUN apk add --no-cache \ && apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ \ atomicparsley +RUN ln -s /usr/bin/python3 /usr/bin/python & \ + ln -s /usr/bin/pip3 /usr/bin/pip + WORKDIR /app COPY --chown=$UID:$GID [ "backend/package.json", "backend/package-lock.json", "/app/" ] RUN npm install forever -g From 8469ae10adf4e1ae7d1008cc3b65cf360d38557e Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Thu, 22 Jul 2021 02:10:14 -0600 Subject: [PATCH 3/5] Fixed issue where backend would crash if the details bin did not exist for youtube-dl --- backend/app.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/backend/app.js b/backend/app.js index d07f4c5..3c30dab 100644 --- a/backend/app.js +++ b/backend/app.js @@ -4,7 +4,6 @@ var { promisify } = require('util'); var auth_api = require('./authentication/auth'); var winston = require('winston'); var path = require('path'); -var youtubedl = require('youtube-dl'); var ffmpeg = require('fluent-ffmpeg'); var compression = require('compression'); var glob = require("glob") @@ -24,15 +23,22 @@ const fetch = require('node-fetch'); var URL = require('url').URL; const shortid = require('shortid') const url_api = require('url'); -var config_api = require('./config.js'); -var subscriptions_api = require('./subscriptions') -var categories_api = require('./categories'); -var twitch_api = require('./twitch'); const CONSTS = require('./consts') const { spawn } = require('child_process') const read_last_lines = require('read-last-lines'); var ps = require('ps-node'); +// needed if bin/details somehow gets deleted +const DETAILS_BIN_PATH = 'node_modules/youtube-dl/bin/details' +if (!fs.existsSync(DETAILS_BIN_PATH)) fs.writeJSONSync(DETAILS_BIN_PATH, {"version":"2000.06.06","path":"node_modules\\youtube-dl\\bin\\youtube-dl.exe","exec":"youtube-dl.exe","downloader":"youtube-dl"}) + +var youtubedl = require('youtube-dl'); + +var config_api = require('./config.js'); +var subscriptions_api = require('./subscriptions') +var categories_api = require('./categories'); +var twitch_api = require('./twitch'); + const is_windows = process.platform === 'win32'; var app = express(); @@ -1366,18 +1372,17 @@ async function autoUpdateYoutubeDL() { const default_downloader = config_api.getConfigItem('ytdl_default_downloader'); const tags_url = download_sources[default_downloader]['tags_url']; // get current version - let current_app_details_path = 'node_modules/youtube-dl/bin/details'; - let current_app_details_exists = fs.existsSync(current_app_details_path); + let current_app_details_exists = fs.existsSync(DETAILS_BIN_PATH); if (!current_app_details_exists) { - logger.warn(`Failed to get youtube-dl binary details at location '${current_app_details_path}'. Generating file...`); - fs.writeJSONSync('node_modules/youtube-dl/bin/details', {"version":"2020.00.00", "downloader": default_downloader}); + logger.warn(`Failed to get youtube-dl binary details at location '${DETAILS_BIN_PATH}'. Generating file...`); + fs.writeJSONSync(DETAILS_BIN_PATH, {"version":"2020.00.00", "downloader": default_downloader}); } - let current_app_details = JSON.parse(fs.readFileSync(current_app_details_path)); + let current_app_details = JSON.parse(fs.readFileSync(DETAILS_BIN_PATH)); let current_version = current_app_details['version']; let current_downloader = current_app_details['downloader']; let stored_binary_path = current_app_details['path']; if (!stored_binary_path || typeof stored_binary_path !== 'string') { - // logger.info(`INFO: Failed to get youtube-dl binary path at location: ${current_app_details_path}, attempting to guess actual path...`); + // logger.info(`INFO: Failed to get youtube-dl binary path at location: ${DETAILS_BIN_PATH}, attempting to guess actual path...`); const guessed_base_path = 'node_modules/youtube-dl/bin/'; const guessed_file_path = guessed_base_path + 'youtube-dl' + (is_windows ? '.exe' : ''); if (fs.existsSync(guessed_file_path)) { @@ -1460,16 +1465,14 @@ async function downloadLatestYoutubeDLPBinary(new_version) { } function updateDetailsJSON(new_version, downloader) { - const details_path = 'node_modules/youtube-dl/bin/details'; - const details_json = fs.readJSONSync(details_path); + const details_json = fs.readJSONSync(DETAILS_BIN_PATH); if (new_version) details_json['version'] = new_version; details_json['downloader'] = downloader; - fs.writeJSONSync(details_path, details_json); + fs.writeJSONSync(DETAILS_BIN_PATH, details_json); } function getCurrentDownloader() { - const details_path = 'node_modules/youtube-dl/bin/details'; - const details_json = fs.readJSONSync(details_path); + const details_json = fs.readJSONSync(DETAILS_BIN_PATH); return details_json['downloader']; } From ce8f90ca1db43849c9371d576a11a4064568e288 Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Thu, 22 Jul 2021 02:13:11 -0600 Subject: [PATCH 4/5] Reverted python3->python dockerfile changes and re-added python2 to dockerfile --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index db83c4c..0be5ff4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,14 +29,12 @@ RUN addgroup -S $USER -g $GID && adduser -D -S $USER -G $USER -u $UID RUN apk add --no-cache \ ffmpeg \ npm \ + python2 \ python3 \ su-exec \ && apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ \ atomicparsley -RUN ln -s /usr/bin/python3 /usr/bin/python & \ - ln -s /usr/bin/pip3 /usr/bin/pip - WORKDIR /app COPY --chown=$UID:$GID [ "backend/package.json", "backend/package-lock.json", "/app/" ] RUN npm install forever -g From ccb4819a944a1822b99000f4ab1d14430e5121ec Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Thu, 22 Jul 2021 20:38:42 -0600 Subject: [PATCH 5/5] Adds small timeout to restart server API call Fixes typo in translation description for video cropping --- backend/app.js | 3 ++- src/assets/i18n/messages.en.xlf | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/app.js b/backend/app.js index 3c30dab..78dae1b 100644 --- a/backend/app.js +++ b/backend/app.js @@ -1583,7 +1583,8 @@ app.post('/api/setConfig', optionalJwt, function(req, res) { }); app.post('/api/restartServer', optionalJwt, (req, res) => { - restartServer(); + // delayed by a little bit so that the client gets a response + setTimeout(() => {restartServer()}, 100); res.send({success: true}); }); diff --git a/src/assets/i18n/messages.en.xlf b/src/assets/i18n/messages.en.xlf index e8b58dd..99e0f16 100644 --- a/src/assets/i18n/messages.en.xlf +++ b/src/assets/i18n/messages.en.xlf @@ -252,7 +252,7 @@ src/app/main/main.component.html 159 - Crom from placeholder + Crop from placeholder Crop to (seconds)