Compare commits

..

16 Commits

Author SHA1 Message Date
Isaac Abadi
51512a60da Fixed docker build issues 2022-05-01 00:22:28 -04:00
GlassedSilver
960c545f37 Dockerfile uses Ubuntu 20.04, fix obtain ffmpeg 2022-05-01 05:14:31 +02:00
Isaac Abadi
5e3eb68b03 Fixed issue where setting sub downloads as 'fresh' was not working properly (#567) 2022-04-30 00:58:12 -04:00
Glassed Silver
4dd3b97515 Merge pull request #566 from GlassedSilver/master
Fixing DNS issues caused by outdated musl version
2022-04-26 06:39:26 +02:00
Glassed Silver
701066eec1 Merge pull request #562 from Tzahi12345/GlassedSilver-add-security-policy
Added Security Policy
2022-04-26 06:39:16 +02:00
GlassedSilver
7f61ccb5f5 Use fixed version of musl to fix DNS errors 2022-04-26 04:46:05 +02:00
Glassed Silver
4f227ca442 Delete extensions.json 2022-04-26 04:28:47 +02:00
Glassed Silver
666bd2057d Merge branch 'Tzahi12345:master' into master 2022-04-26 04:25:50 +02:00
Isaac Abadi
37c858f950 Revert "Updated ffmpeg link in docker-build.sh to use release builds"
This reverts commit 768ec59f30.
2022-04-24 06:16:43 -04:00
Isaac Abadi
ebb7f6a2b0 Revert "Fixed mangled ffmpeg link"
This reverts commit 48e46db071.
2022-04-24 06:16:02 -04:00
Isaac Abadi
48e46db071 Fixed mangled ffmpeg link 2022-04-24 05:51:04 -04:00
Isaac Abadi
768ec59f30 Updated ffmpeg link in docker-build.sh to use release builds 2022-04-24 05:49:09 -04:00
Isaac Abadi
d5c1361e64 Fixed issue where roles were not properly initialized 2022-04-24 05:02:02 -04:00
Isaac Abadi
901a96aada Fixed issue where use_local_db may be out of sync when first starting youtubedl-material 2022-04-24 05:01:45 -04:00
Glassed Silver
60e8973f52 Merge branch 'Tzahi12345:master' into master 2022-04-24 00:40:58 +02:00
GlassedSilver
c008171850 add color picker to WS recs 2022-04-21 22:33:01 +02:00
5 changed files with 92 additions and 37 deletions

View File

@@ -1,12 +1,16 @@
FROM alpine:latest AS ffmpeg FROM ubuntu:20.04 AS ffmpeg
RUN apt-get update && apt-get -y install curl xz-utils
COPY docker-build.sh . COPY docker-build.sh .
RUN sh ./docker-build.sh RUN sh ./docker-build.sh
FROM alpine:latest as frontend FROM ubuntu:20.04 as frontend
RUN apk add --no-cache \ ENV DEBIAN_FRONTEND=noninteractive
npm RUN apt-get update
RUN apt-get -y install curl gnupg
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get -y install nodejs
RUN npm install -g @angular/cli RUN npm install -g @angular/cli
@@ -20,35 +24,35 @@ RUN npm run build
#--------------# #--------------#
FROM alpine:latest FROM ubuntu:20.04
ENV UID=1000 \ ENV UID=1000 \
GID=1000 \ GID=1000 \
USER=youtube USER=youtube \
NO_UPDATE_NOTIFIER=true
ENV NO_UPDATE_NOTIFIER=true RUN groupadd -g $GID $USER && useradd --system -g $USER --uid $UID $USER
RUN addgroup -S $USER -g $GID && adduser -D -S $USER -G $USER -u $UID RUN apt-get update && apt-get -y install curl
RUN apk add --no-cache \ RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
npm \ RUN apt-get update && apt-get -y install \
nodejs \
python2 \ python2 \
python3 \ python3 \
su-exec \ atomicparsley
&& apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ \
atomicparsley
WORKDIR /app WORKDIR /app
COPY --from=ffmpeg /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg COPY --from=ffmpeg /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
COPY --from=ffmpeg /usr/local/bin/ffprobe /usr/local/bin/ffprobe COPY --from=ffmpeg /usr/local/bin/ffprobe /usr/local/bin/ffprobe
COPY --chown=$UID:$GID [ "backend/package.json", "backend/package-lock.json", "/app/" ] COPY --chown=$UID:$GID [ "backend/package.json", "backend/package-lock.json", "/app/" ]
ENV PM2_HOME=/app/pm2 ENV PM2_HOME=/app/pm2
RUN npm install pm2 -g RUN npm install pm2 -g && \
RUN npm install && chown -R $UID:$GID ./ npm install && chown -R $UID:$GID ./
COPY --chown=$UID:$GID --from=frontend [ "/build/backend/public/", "/app/public/" ] COPY --chown=$UID:$GID --from=frontend [ "/build/backend/public/", "/app/public/" ]
COPY --chown=$UID:$GID [ "/backend/", "/app/" ] COPY --chown=$UID:$GID [ "/backend/", "/app/" ]
EXPOSE 17442 EXPOSE 17442
ENTRYPOINT [ "/app/entrypoint.sh" ] # ENTRYPOINT [ "/app/entrypoint.sh" ]
CMD [ "pm2-runtime", "pm2.config.js" ] CMD [ "pm2-runtime", "pm2.config.js" ]

View File

@@ -18,10 +18,19 @@ let JWT_EXPIRATION = null;
let opts = null; let opts = null;
let saltRounds = null; let saltRounds = null;
exports.initialize = function() { exports.initialize = function () {
/************************* /*************************
* Authentication module * Authentication module
************************/ ************************/
if (db_api.database_initialized) {
setupRoles();
} else {
db_api.database_initialized_bs.subscribe(init => {
if (init) setupRoles();
});
}
saltRounds = 10; saltRounds = 10;
JWT_EXPIRATION = config_api.getConfigItem('ytdl_jwt_expiration'); JWT_EXPIRATION = config_api.getConfigItem('ytdl_jwt_expiration');
@@ -49,6 +58,41 @@ exports.initialize = function() {
})); }));
} }
const setupRoles = async () => {
const required_roles = {
admin: {
permissions: [
'filemanager',
'settings',
'subscriptions',
'sharing',
'advanced_download',
'downloads_manager'
]
},
user: {
permissions: [
'filemanager',
'subscriptions',
'sharing'
]
}
}
const role_keys = Object.keys(required_roles);
for (let i = 0; i < role_keys.length; i++) {
const role_key = role_keys[i];
const role_in_db = await db_api.getRecord('roles', {key: role_key});
if (!role_in_db) {
// insert task metadata into table if missing
await db_api.insertRecordIntoTable('roles', {
key: role_key,
permissions: required_roles[role_key]['permissions']
});
}
}
}
exports.passport = require('passport'); exports.passport = require('passport');
exports.passport.serializeUser(function(user, done) { exports.passport.serializeUser(function(user, done) {

View File

@@ -85,6 +85,7 @@ exports.initialize = (input_db, input_users_db) => {
} }
exports.connectToDB = async (retries = 5, no_fallback = false, custom_connection_string = null) => { exports.connectToDB = async (retries = 5, no_fallback = false, custom_connection_string = null) => {
using_local_db = config_api.getConfigItem('ytdl_use_local_db'); // verify
if (using_local_db && !custom_connection_string) return; if (using_local_db && !custom_connection_string) return;
const success = await exports._connectToDB(custom_connection_string); const success = await exports._connectToDB(custom_connection_string);
if (success) return true; if (success) return true;

View File

@@ -266,11 +266,17 @@ async function getVideosForSub(sub, user_uid = null) {
} }
resolve(false); resolve(false);
} else if (output) { } else if (output) {
if (config_api.getConfigItem('ytdl_subscriptions_redownload_fresh_uploads')) {
await setFreshUploads(sub, user_uid);
checkVideosForFreshUploads(sub, user_uid);
}
if (output.length === 0 || (output.length === 1 && output[0] === '')) { if (output.length === 0 || (output.length === 1 && output[0] === '')) {
logger.verbose('No additional videos to download for ' + sub.name); logger.verbose('No additional videos to download for ' + sub.name);
resolve(true); resolve(true);
return; return;
} }
const output_jsons = []; const output_jsons = [];
for (let i = 0; i < output.length; i++) { for (let i = 0; i < output.length; i++) {
let output_json = null; let output_json = null;
@@ -294,14 +300,7 @@ async function getVideosForSub(sub, user_uid = null) {
} }
resolve(files_to_download); resolve(files_to_download);
}
if (config_api.getConfigItem('ytdl_subscriptions_redownload_fresh_uploads')) {
await setFreshUploads(sub, user_uid);
checkVideosForFreshUploads(sub, user_uid);
}
resolve(true);
}
}); });
}, err => { }, err => {
logger.error(err); logger.error(err);
@@ -473,22 +472,24 @@ async function updateSubscriptionProperty(sub, assignment_obj) {
return true; return true;
} }
async function setFreshUploads(sub, user_uid) { async function setFreshUploads(sub) {
const sub_files = await db_api.getRecords('files', {sub_id: sub.id});
const current_date = new Date().toISOString().split('T')[0].replace(/-/g, ''); const current_date = new Date().toISOString().split('T')[0].replace(/-/g, '');
sub.videos.forEach(async video => { sub_files.forEach(async file => {
if (current_date === video['upload_date'].replace(/-/g, '')) { if (current_date === file['upload_date'].replace(/-/g, '')) {
// set upload as fresh // set upload as fresh
const video_uid = video['uid']; const file_uid = file['uid'];
await db_api.setVideoProperty(video_uid, {'fresh_upload': true}, user_uid, sub['id']); await db_api.setVideoProperty(file_uid, {'fresh_upload': true});
} }
}); });
} }
async function checkVideosForFreshUploads(sub, user_uid) { async function checkVideosForFreshUploads(sub, user_uid) {
const sub_files = await db_api.getRecords('files', {sub_id: sub.id});
const current_date = new Date().toISOString().split('T')[0].replace(/-/g, ''); const current_date = new Date().toISOString().split('T')[0].replace(/-/g, '');
sub.videos.forEach(async video => { sub_files.forEach(async file => {
if (video['fresh_upload'] && current_date > video['upload_date'].replace(/-/g, '')) { if (file['fresh_upload'] && current_date > file['upload_date'].replace(/-/g, '')) {
await checkVideoIfBetterExists(video, sub, user_uid) await checkVideoIfBetterExists(file, sub, user_uid)
} }
}); });
} }
@@ -510,13 +511,13 @@ async function checkVideoIfBetterExists(file_obj, sub, user_uid) {
logger.verbose(`Failed to download better version of video ${file_obj['id']}`); logger.verbose(`Failed to download better version of video ${file_obj['id']}`);
} else if (output) { } else if (output) {
logger.verbose(`Successfully upgraded video ${file_obj['id']}'s ${metric_to_compare} from ${file_obj[metric_to_compare]} to ${output[metric_to_compare]}`); logger.verbose(`Successfully upgraded video ${file_obj['id']}'s ${metric_to_compare} from ${file_obj[metric_to_compare]} to ${output[metric_to_compare]}`);
await db_api.setVideoProperty(file_obj['uid'], {[metric_to_compare]: output[metric_to_compare]}, user_uid, sub['id']); await db_api.setVideoProperty(file_obj['uid'], {[metric_to_compare]: output[metric_to_compare]});
} }
}); });
} }
} }
}); });
await db_api.setVideoProperty(file_obj['uid'], {'fresh_upload': false}, user_uid, sub['id']); await db_api.setVideoProperty(file_obj['uid'], {'fresh_upload': false});
} }
// helper functions // helper functions

View File

@@ -4,7 +4,7 @@
# and also optimizing some code with this commit. # and also optimizing some code with this commit.
# xoxo :D # xoxo :D
set -xeuo pipefail # set -xeuo pipefail
case $(uname -m) in case $(uname -m) in
x86_64) x86_64)
@@ -23,7 +23,12 @@ case $(uname -m) in
esac esac
echo "Architecture: $ARCH" echo "Architecture: $ARCH"
wget "https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-${ARCH}-static.tar.xz" -O ffmpeg.txz curl --connect-timeout 5 \
--max-time 10 \
--retry 5 \
--retry-delay 0 \
--retry-max-time 40 \
"https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-${ARCH}-static.tar.xz" -o ffmpeg.txz
mkdir /tmp/ffmpeg mkdir /tmp/ffmpeg
tar xf ffmpeg.txz -C /tmp/ffmpeg tar xf ffmpeg.txz -C /tmp/ffmpeg
cp /tmp/ffmpeg/*/ffmpeg /usr/local/bin/ffmpeg cp /tmp/ffmpeg/*/ffmpeg /usr/local/bin/ffmpeg