mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-23 12:33:19 +03:00
JSON metadata files are no longer kept if the associated setting is not enabled
This commit is contained in:
@@ -26,10 +26,7 @@ function registerFileDB(file_path, type, multiUserMode = null, sub = null) {
|
|||||||
|
|
||||||
utils.fixVideoMetadataPerms(file_id, type, multiUserMode && multiUserMode.file_path);
|
utils.fixVideoMetadataPerms(file_id, type, multiUserMode && multiUserMode.file_path);
|
||||||
|
|
||||||
// add additional info
|
// add thumbnail path
|
||||||
file_object['uid'] = uuid();
|
|
||||||
file_object['registered'] = Date.now();
|
|
||||||
file_object['path'] = path.format(path.parse(file_object['path']));
|
|
||||||
file_object['thumbnailPath'] = utils.getDownloadedThumbnail(file_id, type, multiUserMode && multiUserMode.file_path);
|
file_object['thumbnailPath'] = utils.getDownloadedThumbnail(file_id, type, multiUserMode && multiUserMode.file_path);
|
||||||
|
|
||||||
if (!sub) {
|
if (!sub) {
|
||||||
@@ -48,7 +45,13 @@ function registerFileDB(file_path, type, multiUserMode = null, sub = null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const file_uid = registerFileDBManual(db_path, file_object)
|
const file_uid = registerFileDBManual(db_path, file_object);
|
||||||
|
|
||||||
|
// remove metadata JSON if needed
|
||||||
|
if (!config_api.getConfigItem('ytdl_include_metadata')) {
|
||||||
|
utils.deleteJSONFile(file_id, type, multiUserMode && multiUserMode.file_path)
|
||||||
|
}
|
||||||
|
|
||||||
return file_uid;
|
return file_uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,6 +145,19 @@ function fixVideoMetadataPerms(name, type, customPath = null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteJSONFile(name, type, customPath = null) {
|
||||||
|
if (!customPath) customPath = type === 'audio' ? config_api.getConfigItem('ytdl_audio_folder_path')
|
||||||
|
: config_api.getConfigItem('ytdl_video_folder_path');
|
||||||
|
|
||||||
|
const ext = type === 'audio' ? '.mp3' : '.mp4';
|
||||||
|
let json_path = path.join(customPath, name + '.info.json');
|
||||||
|
let alternate_json_path = path.join(customPath, name + ext + '.info.json');
|
||||||
|
|
||||||
|
if (fs.existsSync(json_path)) fs.unlinkSync(json_path);
|
||||||
|
if (fs.existsSync(alternate_json_path)) fs.unlinkSync(alternate_json_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function recFindByExt(base,ext,files,result)
|
function recFindByExt(base,ext,files,result)
|
||||||
{
|
{
|
||||||
files = files || fs.readdirSync(base)
|
files = files || fs.readdirSync(base)
|
||||||
@@ -191,6 +204,7 @@ module.exports = {
|
|||||||
getDownloadedThumbnail: getDownloadedThumbnail,
|
getDownloadedThumbnail: getDownloadedThumbnail,
|
||||||
getExpectedFileSize: getExpectedFileSize,
|
getExpectedFileSize: getExpectedFileSize,
|
||||||
fixVideoMetadataPerms: fixVideoMetadataPerms,
|
fixVideoMetadataPerms: fixVideoMetadataPerms,
|
||||||
|
deleteJSONFile: deleteJSONFile,
|
||||||
getDownloadedFilesByType: getDownloadedFilesByType,
|
getDownloadedFilesByType: getDownloadedFilesByType,
|
||||||
recFindByExt: recFindByExt,
|
recFindByExt: recFindByExt,
|
||||||
File: File
|
File: File
|
||||||
|
|||||||
Reference in New Issue
Block a user