diff --git a/backend/appdata/default.json b/backend/appdata/default.json index 001f515..dca9eee 100644 --- a/backend/appdata/default.json +++ b/backend/appdata/default.json @@ -38,7 +38,8 @@ "Subscriptions": { "allow_subscriptions": true, "subscriptions_base_path": "subscriptions/", - "subscriptions_check_interval": "300" + "subscriptions_check_interval": "300", + "redownload_fresh_uploads": false }, "Users": { "base_path": "users/", diff --git a/backend/config.js b/backend/config.js index b2aff63..4790e34 100644 --- a/backend/config.js +++ b/backend/config.js @@ -215,7 +215,8 @@ DEFAULT_CONFIG = { "Subscriptions": { "allow_subscriptions": true, "subscriptions_base_path": "subscriptions/", - "subscriptions_check_interval": "300" + "subscriptions_check_interval": "300", + "redownload_fresh_uploads": false }, "Users": { "base_path": "users/", diff --git a/backend/consts.js b/backend/consts.js index bffe486..64e6e09 100644 --- a/backend/consts.js +++ b/backend/consts.js @@ -126,6 +126,10 @@ let CONFIG_ITEMS = { 'key': 'ytdl_subscriptions_check_interval', 'path': 'YoutubeDLMaterial.Subscriptions.subscriptions_check_interval' }, + 'ytdl_subscriptions_redownload_fresh_uploads': { + 'key': 'ytdl_subscriptions_redownload_fresh_uploads', + 'path': 'YoutubeDLMaterial.Subscriptions.redownload_fresh_uploads' + }, // Users 'ytdl_users_base_path': { diff --git a/backend/subscriptions.js b/backend/subscriptions.js index 7ce2a96..396516d 100644 --- a/backend/subscriptions.js +++ b/backend/subscriptions.js @@ -333,9 +333,13 @@ async function getVideosForSub(sub, user_uid = null) { const reset_videos = i === 0; handleOutputJSON(sub, sub_db, output_json, multiUserMode, reset_videos); + } + + if (config_api.getConfigItem('ytdl_subscriptions_redownload_fresh_uploads')) { await setFreshUploads(sub, user_uid); checkVideosForFreshUploads(sub, user_uid); } + resolve(true); } }); @@ -403,7 +407,7 @@ async function generateArgsForSubscription(sub, user_uid, redownload = false, de downloadConfig = ['-f', 'best', '--dump-json']; } - if (sub.timerange) { + if (sub.timerange && !redownload) { downloadConfig.push('--dateafter', sub.timerange); } @@ -515,14 +519,13 @@ async function checkVideosForFreshUploads(sub, user_uid) { async function checkVideoIfBetterExists(file_obj, sub, user_uid) { const new_path = file_obj['path'].substring(0, file_obj['path'].length - 4); - const downloadConfig = generateArgsForSubscription(sub, user_uid, true, new_path); + const downloadConfig = await generateArgsForSubscription(sub, user_uid, true, new_path); logger.verbose(`Checking if a better version of the fresh upload ${file_obj['id']} exists.`); // simulate a download to verify that a better version exists youtubedl.getInfo(file_obj['url'], downloadConfig, (err, output) => { if (err) { // video is not available anymore for whatever reason } else if (output) { - console.log(output); const metric_to_compare = sub.type === 'audio' ? 'abr' : 'height'; if (output[metric_to_compare] > file_obj[metric_to_compare]) { // download new video as the simulated one is better diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html index 08d4970..bd085b1 100644 --- a/src/app/settings/settings.component.html +++ b/src/app/settings/settings.component.html @@ -53,12 +53,15 @@ Base path for videos from your subscribed channels and playlists. It is relative to YTDL-Material's root folder. -
+
Unit is seconds, only include numbers.
+
+ Redownload fresh uploads +