mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-02 22:51:29 +03:00
Added tests for arg generation and laid some plumbing for better arg simulation in the UI
This commit is contained in:
@@ -190,7 +190,7 @@ async function collectInfo(download_uid) {
|
|||||||
options.customFileFolderPath = user_path + path.sep;
|
options.customFileFolderPath = user_path + path.sep;
|
||||||
}
|
}
|
||||||
|
|
||||||
let args = await generateArgs(url, type, options, download['user_uid']);
|
let args = await exports.generateArgs(url, type, options, download['user_uid']);
|
||||||
|
|
||||||
// get video info prior to download
|
// get video info prior to download
|
||||||
let info = await getVideoInfoByURL(url, args, download_uid);
|
let info = await getVideoInfoByURL(url, args, download_uid);
|
||||||
@@ -209,7 +209,7 @@ async function collectInfo(download_uid) {
|
|||||||
if (category && category['custom_output']) {
|
if (category && category['custom_output']) {
|
||||||
options.customOutput = category['custom_output'];
|
options.customOutput = category['custom_output'];
|
||||||
options.noRelativePath = true;
|
options.noRelativePath = true;
|
||||||
args = await generateArgs(url, type, options, download['user_uid']);
|
args = await exports.generateArgs(url, type, options, download['user_uid']);
|
||||||
info = await getVideoInfoByURL(url, args, download_uid);
|
info = await getVideoInfoByURL(url, args, download_uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ async function downloadQueuedFile(download_uid) {
|
|||||||
|
|
||||||
// helper functions
|
// helper functions
|
||||||
|
|
||||||
async function generateArgs(url, type, options, user_uid = null) {
|
exports.generateArgs = async (url, type, options, user_uid = null) => {
|
||||||
const audioFolderPath = config_api.getConfigItem('ytdl_audio_folder_path');
|
const audioFolderPath = config_api.getConfigItem('ytdl_audio_folder_path');
|
||||||
const videoFolderPath = config_api.getConfigItem('ytdl_video_folder_path');
|
const videoFolderPath = config_api.getConfigItem('ytdl_video_folder_path');
|
||||||
|
|
||||||
|
|||||||
@@ -543,5 +543,6 @@ module.exports = {
|
|||||||
deleteSubscriptionFile : deleteSubscriptionFile,
|
deleteSubscriptionFile : deleteSubscriptionFile,
|
||||||
getVideosForSub : getVideosForSub,
|
getVideosForSub : getVideosForSub,
|
||||||
initialize : initialize,
|
initialize : initialize,
|
||||||
updateSubscriptionPropertyMultiple : updateSubscriptionPropertyMultiple
|
updateSubscriptionPropertyMultiple : updateSubscriptionPropertyMultiple,
|
||||||
|
generateOptionsForSubscriptionDownload: generateOptionsForSubscriptionDownload
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -293,6 +293,7 @@ describe('Downloader', function() {
|
|||||||
const downloader_api = require('../downloader');
|
const downloader_api = require('../downloader');
|
||||||
downloader_api.initialize(db_api);
|
downloader_api.initialize(db_api);
|
||||||
const url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
|
const url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
|
||||||
|
const sub_id = 'dc834388-3454-41bf-a618-e11cb8c7de1c';
|
||||||
const options = {
|
const options = {
|
||||||
ui_uid: uuid(),
|
ui_uid: uuid(),
|
||||||
user: 'admin'
|
user: 'admin'
|
||||||
@@ -325,4 +326,17 @@ describe('Downloader', function() {
|
|||||||
it('Pause file', async function() {
|
it('Pause file', async function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Generate args', async function() {
|
||||||
|
const args = await downloader_api.generateArgs(url, 'video', options);
|
||||||
|
console.log(args);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Generate args - subscription', async function() {
|
||||||
|
subscriptions_api.initialize(db_api, logger);
|
||||||
|
const sub = await subscriptions_api.getSubscription(sub_id);
|
||||||
|
const sub_options = subscriptions_api.generateOptionsForSubscriptionDownload(sub, 'admin');
|
||||||
|
const args = await downloader_api.generateArgs(url, 'video', sub_options, 'admin');
|
||||||
|
console.log(args);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user