Replaced /audio and /video APIs with /stream that now requires a type parameter to simplify future code changes

getSubscription can now accept a subscription name instead of just an ID

Added API call to delete a category

Categories can now have a custom path

Minor code cleanup
This commit is contained in:
Isaac Abadi
2020-10-15 16:57:45 -04:00
parent dff4b141b0
commit fe7303a191
4 changed files with 74 additions and 110 deletions

View File

@@ -34,30 +34,27 @@ Rules:
*/
async function categorize(file_json) {
return new Promise(resolve => {
let selected_category = null;
const categories = getCategories();
if (!categories) {
logger.warn('Categories could not be found. Initializing categories...');
db.assign({categories: []}).write();
resolve(null);
return;
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;
}
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']}`);
}
}
resolve(selected_category);
});
}
return selected_category;
}
function getCategories() {