mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-09 08:41:30 +03:00
Merge pull request #316 from Tzahi12345/categories-playlist-fix
Categories playlist download fix
This commit is contained in:
@@ -1133,7 +1133,7 @@ async function downloadFileByURL_exec(url, type, options, sessionID = null) {
|
|||||||
return;
|
return;
|
||||||
} else if (info) {
|
} else if (info) {
|
||||||
// check if it fits into a category. If so, then get info again using new downloadConfig
|
// 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
|
// 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']) {
|
if (category && category['custom_output']) {
|
||||||
@@ -2244,7 +2244,7 @@ app.post('/api/createCategory', optionalJwt, async (req, res) => {
|
|||||||
name: name,
|
name: name,
|
||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
rules: [],
|
rules: [],
|
||||||
custom_putput: ''
|
custom_output: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
db.get('categories').push(new_category).write();
|
db.get('categories').push(new_category).write();
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
"allow_quality_select": true,
|
"allow_quality_select": true,
|
||||||
"download_only_mode": false,
|
"download_only_mode": false,
|
||||||
"allow_multi_download_mode": true,
|
"allow_multi_download_mode": true,
|
||||||
"enable_downloads_manager": true
|
"enable_downloads_manager": true,
|
||||||
|
"allow_playlist_categorization": true
|
||||||
},
|
},
|
||||||
"API": {
|
"API": {
|
||||||
"use_API_key": false,
|
"use_API_key": false,
|
||||||
|
|||||||
@@ -33,27 +33,33 @@ 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;
|
let selected_category = null;
|
||||||
const categories = getCategories();
|
const categories = getCategories();
|
||||||
if (!categories) {
|
if (!categories) {
|
||||||
logger.warn('Categories could not be found. Initializing categories...');
|
logger.warn('Categories could not be found. Initializing categories...');
|
||||||
db.assign({categories: []}).write();
|
db.assign({categories: []}).write();
|
||||||
return null;
|
return null;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < categories.length; i++) {
|
for (let i = 0; i < file_jsons.length; i++) {
|
||||||
const category = categories[i];
|
const file_json = file_jsons[i];
|
||||||
const rules = category['rules'];
|
for (let j = 0; j < categories.length; j++) {
|
||||||
|
const category = categories[i];
|
||||||
// if rules for current category apply, then that is the selected category
|
const rules = category['rules'];
|
||||||
if (applyCategoryRules(file_json, rules, category['name'])) {
|
|
||||||
selected_category = category;
|
// if rules for current category apply, then that is the selected category
|
||||||
logger.verbose(`Selected category ${category['name']} for ${file_json['webpage_url']}`);
|
if (applyCategoryRules(file_json, rules, category['name'])) {
|
||||||
return selected_category;
|
selected_category = category;
|
||||||
|
logger.verbose(`Selected category ${category['name']} for ${file_json['webpage_url']}`);
|
||||||
|
return selected_category;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return selected_category;
|
return selected_category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,8 @@ DEFAULT_CONFIG = {
|
|||||||
"allow_quality_select": true,
|
"allow_quality_select": true,
|
||||||
"download_only_mode": false,
|
"download_only_mode": false,
|
||||||
"allow_multi_download_mode": true,
|
"allow_multi_download_mode": true,
|
||||||
"enable_downloads_manager": true
|
"enable_downloads_manager": true,
|
||||||
|
"allow_playlist_categorization": true
|
||||||
},
|
},
|
||||||
"API": {
|
"API": {
|
||||||
"use_API_key": false,
|
"use_API_key": false,
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ let CONFIG_ITEMS = {
|
|||||||
'key': 'ytdl_enable_downloads_manager',
|
'key': 'ytdl_enable_downloads_manager',
|
||||||
'path': 'YoutubeDLMaterial.Extra.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
|
// API
|
||||||
'ytdl_use_api_key': {
|
'ytdl_use_api_key': {
|
||||||
|
|||||||
@@ -140,7 +140,7 @@
|
|||||||
<mat-divider></mat-divider>
|
<mat-divider></mat-divider>
|
||||||
<div *ngIf="new_config" class="container-fluid">
|
<div *ngIf="new_config" class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 mt-3 mb-2">
|
<div class="col-12 mt-3">
|
||||||
<h6 i18n="Categories">Categories</h6>
|
<h6 i18n="Categories">Categories</h6>
|
||||||
<div cdkDropList class="category-list" (cdkDropListDropped)="dropCategory($event)">
|
<div cdkDropList class="category-list" (cdkDropListDropped)="dropCategory($event)">
|
||||||
<div class="category-box" *ngFor="let category of postsService.categories" cdkDrag>
|
<div class="category-box" *ngFor="let category of postsService.categories" cdkDrag>
|
||||||
@@ -154,6 +154,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<button style="margin-top: 10px;" mat-mini-fab (click)="openAddCategoryDialog()"><mat-icon>add</mat-icon></button>
|
<button style="margin-top: 10px;" mat-mini-fab (click)="openAddCategoryDialog()"><mat-icon>add</mat-icon></button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-12 mt-2 mb-2">
|
||||||
|
<mat-checkbox [(ngModel)]="new_config['Extra']['allow_playlist_categorization']" matTooltip="With this setting enabled, if a single video matches a category, the entire playlist will receive that category." i18n-matTooltip="Allow playlist categorization setting tooltip"><ng-container i18n="Allow playlist categorization setting label">Allow playlist categorization</ng-container></mat-checkbox>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<mat-divider></mat-divider>
|
<mat-divider></mat-divider>
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
"download_only_mode": false,
|
"download_only_mode": false,
|
||||||
"allow_multi_download_mode": true,
|
"allow_multi_download_mode": true,
|
||||||
"settings_pin_required": false,
|
"settings_pin_required": false,
|
||||||
"enable_downloads_manager": true
|
"enable_downloads_manager": true,
|
||||||
|
"allow_playlist_categorization": true
|
||||||
},
|
},
|
||||||
"API": {
|
"API": {
|
||||||
"use_API_key": false,
|
"use_API_key": false,
|
||||||
|
|||||||
Reference in New Issue
Block a user