mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-31 17:10:56 +03:00
Changed DB structure again
Added support for MongoDB Added tests relating to new DB system Category rules are now case insensitive Fixed playlist modification change state
This commit is contained in:
@@ -39,10 +39,9 @@ async function categorize(file_jsons) {
|
||||
if (!Array.isArray(file_jsons)) file_jsons = [file_jsons];
|
||||
|
||||
let selected_category = null;
|
||||
const categories = getCategories();
|
||||
const categories = await getCategories();
|
||||
if (!categories) {
|
||||
logger.warn('Categories could not be found. Initializing categories...');
|
||||
db.assign({categories: []}).write();
|
||||
logger.warn('Categories could not be found.');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -64,14 +63,14 @@ async function categorize(file_jsons) {
|
||||
return selected_category;
|
||||
}
|
||||
|
||||
function getCategories() {
|
||||
const categories = db.get('categories').value();
|
||||
async function getCategories() {
|
||||
const categories = await db_api.getRecords('categories');
|
||||
return categories ? categories : null;
|
||||
}
|
||||
|
||||
function getCategoriesAsPlaylists(files = null) {
|
||||
async function getCategoriesAsPlaylists(files = null) {
|
||||
const categories_as_playlists = [];
|
||||
const available_categories = getCategories();
|
||||
const available_categories = await getCategories();
|
||||
if (available_categories && files) {
|
||||
for (category of available_categories) {
|
||||
const files_that_match = utils.addUIDsToCategory(category, files);
|
||||
@@ -97,10 +96,10 @@ function applyCategoryRules(file_json, rules, category_name) {
|
||||
|
||||
switch (rule['comparator']) {
|
||||
case 'includes':
|
||||
rule_applies = file_json[rule['property']].includes(rule['value']);
|
||||
rule_applies = file_json[rule['property']].toLowerCase().includes(rule['value'].toLowerCase());
|
||||
break;
|
||||
case 'not_includes':
|
||||
rule_applies = !(file_json[rule['property']].includes(rule['value']));
|
||||
rule_applies = !(file_json[rule['property']].toLowerCase().includes(rule['value'].toLowerCase()));
|
||||
break;
|
||||
case 'equals':
|
||||
rule_applies = file_json[rule['property']] === rule['value'];
|
||||
|
||||
Reference in New Issue
Block a user