mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-03 20:31:26 +03:00
Archive improvements
Began UI for viewing/modifying archives
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const { uuid } = require('uuidv4');
|
||||
|
||||
const db_api = require('./db');
|
||||
|
||||
@@ -11,8 +12,8 @@ exports.generateArchive = async (type = null, user_uid = null, sub_id = null) =>
|
||||
return archive_item_lines.join('\n');
|
||||
}
|
||||
|
||||
exports.addToArchive = async (extractor, id, type, user_uid = null, sub_id = null) => {
|
||||
const archive_item = createArchiveItem(extractor, id, type, user_uid, sub_id);
|
||||
exports.addToArchive = async (extractor, id, type, title, user_uid = null, sub_id = null) => {
|
||||
const archive_item = createArchiveItem(extractor, id, type, title, user_uid, sub_id);
|
||||
const success = await db_api.insertRecordIntoTable('archives', archive_item, {extractor: extractor, id: id, type: type});
|
||||
return success;
|
||||
}
|
||||
@@ -43,7 +44,7 @@ exports.importArchiveFile = async (archive_text, type, user_uid = null, sub_id =
|
||||
|
||||
// we can't do a bulk write because we need to avoid duplicate archive items existing in db
|
||||
|
||||
const archive_item = createArchiveItem(extractor, id, type, user_uid, sub_id);
|
||||
const archive_item = createArchiveItem(extractor, id, type, null, user_uid, sub_id);
|
||||
await db_api.insertRecordIntoTable('archives', archive_item, {extractor: extractor, id: id});
|
||||
archive_import_count++;
|
||||
}
|
||||
@@ -76,12 +77,15 @@ exports.importArchives = async () => {
|
||||
return imported_archives;
|
||||
}
|
||||
|
||||
const createArchiveItem = (extractor, id, type, user_uid = null, sub_id = null) => {
|
||||
const createArchiveItem = (extractor, id, type, title = null, user_uid = null, sub_id = null) => {
|
||||
return {
|
||||
extractor: extractor,
|
||||
id: id,
|
||||
type: type,
|
||||
title: title,
|
||||
user_uid: user_uid ? user_uid : null,
|
||||
sub_id: sub_id ? sub_id : null
|
||||
sub_id: sub_id ? sub_id : null,
|
||||
timestamp: Date.now() / 1000,
|
||||
uid: uuid()
|
||||
}
|
||||
}
|
||||
@@ -369,7 +369,7 @@ async function downloadQueuedFile(download_uid) {
|
||||
const file_obj = await db_api.registerFileDB(full_file_path, type, download['user_uid'], category, download['sub_id'] ? download['sub_id'] : null, options.cropFileSettings);
|
||||
|
||||
const useYoutubeDLArchive = config_api.getConfigItem('ytdl_use_youtubedl_archive');
|
||||
if (useYoutubeDLArchive && !options.ignoreArchive) await archive_api.addToArchive(output_json['extractor'], output_json['id'], type, download['user_uid'], download['sub_id']);
|
||||
if (useYoutubeDLArchive && !options.ignoreArchive) await archive_api.addToArchive(output_json['extractor'], output_json['id'], type, output_json['title'], download['user_uid'], download['sub_id']);
|
||||
|
||||
notifications_api.sendDownloadNotification(file_obj, download['user_uid']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user