mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-22 08:33:21 +03:00
Subscription videos being downloaded will get registered into the database as they are added to avoid having to wait until the subscription completes
This commit is contained in:
@@ -213,6 +213,29 @@ async function importUnregisteredFiles() {
|
||||
|
||||
}
|
||||
|
||||
async function preimportUnregisteredSubscriptionFile(sub, appendedBasePath) {
|
||||
const preimported_file_paths = [];
|
||||
|
||||
let dbPath = null;
|
||||
if (sub.user_uid)
|
||||
dbPath = users_db.get('users').find({uid: sub.user_uid}).get('subscriptions').find({id: sub.id}).get('videos');
|
||||
else
|
||||
dbPath = db.get('subscriptions').find({id: sub.id}).get('videos');
|
||||
|
||||
const files = await utils.getDownloadedFilesByType(appendedBasePath, sub.type);
|
||||
files.forEach(file => {
|
||||
// check if file exists in db, if not add it
|
||||
const file_is_registered = !!(dbPath.find({id: file.id}).value())
|
||||
if (!file_is_registered) {
|
||||
// add additional info
|
||||
registerFileDBManual(dbPath, file);
|
||||
preimported_file_paths.push(file['path']);
|
||||
logger.verbose(`Preemptively added subscription file to the database: ${file.id}`);
|
||||
}
|
||||
});
|
||||
return preimported_file_paths;
|
||||
}
|
||||
|
||||
async function getVideo(file_uid, uuid, sub_id) {
|
||||
const base_db_path = uuid ? users_db.get('users').find({uid: uuid}) : db;
|
||||
const sub_db_path = sub_id ? base_db_path.get('subscriptions').find({id: sub_id}).get('videos') : base_db_path.get('files');
|
||||
@@ -235,6 +258,7 @@ module.exports = {
|
||||
updatePlaylist: updatePlaylist,
|
||||
getFileDirectoriesAndDBs: getFileDirectoriesAndDBs,
|
||||
importUnregisteredFiles: importUnregisteredFiles,
|
||||
preimportUnregisteredSubscriptionFile: preimportUnregisteredSubscriptionFile,
|
||||
getVideo: getVideo,
|
||||
setVideoProperty: setVideoProperty
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user