diff --git a/backend/app.js b/backend/app.js
index 04edd6a..1a65d47 100644
--- a/backend/app.js
+++ b/backend/app.js
@@ -1133,7 +1133,7 @@ async function downloadFileByURL_exec(url, type, options, sessionID = null) {
return;
} else if (info) {
// check if it fits into a category. If so, then get info again using new downloadConfig
- if (!Array.isArray(info)) category = await categories_api.categorize(info);
+ if (!Array.isArray(info) || config_api.getConfigItem('ytdl_allow_playlist_categorization')) category = await categories_api.categorize(info);
// set custom output if the category has one and re-retrieve info so the download manager has the right file name
if (category && category['custom_output']) {
diff --git a/backend/appdata/default.json b/backend/appdata/default.json
index dca9eee..5bd5c54 100644
--- a/backend/appdata/default.json
+++ b/backend/appdata/default.json
@@ -20,7 +20,8 @@
"allow_quality_select": true,
"download_only_mode": false,
"allow_multi_download_mode": true,
- "enable_downloads_manager": true
+ "enable_downloads_manager": true,
+ "allow_playlist_categorization": true
},
"API": {
"use_API_key": false,
diff --git a/backend/categories.js b/backend/categories.js
index d0b249a..d2af431 100644
--- a/backend/categories.js
+++ b/backend/categories.js
@@ -33,27 +33,31 @@ Rules:
*/
-async function categorize(file_json) {
+async function categorize(file_jsons) {
+ // to make the logic easier, let's assume the file metadata is an array
+ if (!Array.isArray(file_jsons)) file_jsons = [file_jsons];
+
let selected_category = null;
const categories = getCategories();
if (!categories) {
logger.warn('Categories could not be found. Initializing categories...');
db.assign({categories: []}).write();
return null;
- return;
}
- for (let i = 0; i < categories.length; i++) {
- const category = categories[i];
- const rules = category['rules'];
-
- // if rules for current category apply, then that is the selected category
- if (applyCategoryRules(file_json, rules, category['name'])) {
- selected_category = category;
- logger.verbose(`Selected category ${category['name']} for ${file_json['webpage_url']}`);
- return selected_category;
- }
- }
+ file_jsons.forEach(file_json => {
+ categories.forEach(category => {
+ const rules = category['rules'];
+
+ // if rules for current category apply, then that is the selected category
+ if (applyCategoryRules(file_json, rules, category['name'])) {
+ selected_category = category;
+ logger.verbose(`Selected category ${category['name']} for ${file_json['webpage_url']}`);
+ return selected_category;
+ }
+ });
+ });
+
return selected_category;
}
diff --git a/backend/config.js b/backend/config.js
index 4790e34..cb3e8b3 100644
--- a/backend/config.js
+++ b/backend/config.js
@@ -197,7 +197,8 @@ DEFAULT_CONFIG = {
"allow_quality_select": true,
"download_only_mode": false,
"allow_multi_download_mode": true,
- "enable_downloads_manager": true
+ "enable_downloads_manager": true,
+ "allow_playlist_categorization": true
},
"API": {
"use_API_key": false,
diff --git a/backend/consts.js b/backend/consts.js
index fa14171..fc29fcf 100644
--- a/backend/consts.js
+++ b/backend/consts.js
@@ -68,6 +68,10 @@ let CONFIG_ITEMS = {
'key': 'ytdl_enable_downloads_manager',
'path': 'YoutubeDLMaterial.Extra.enable_downloads_manager'
},
+ 'ytdl_allow_playlist_categorization': {
+ 'key': 'ytdl_allow_playlist_categorization',
+ 'path': 'YoutubeDLMaterial.Extra.allow_playlist_categorization'
+ },
// API
'ytdl_use_api_key': {
diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html
index bd085b1..a7d69d6 100644
--- a/src/app/settings/settings.component.html
+++ b/src/app/settings/settings.component.html
@@ -140,7 +140,7 @@