mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-16 06:11:29 +03:00
Added audioOnlyMode, customArgs, and customFileOutput fields to the subscribe dialog
This commit is contained in:
@@ -2099,6 +2099,9 @@ app.post('/api/subscribe', optionalJwt, async (req, res) => {
|
||||
let url = req.body.url;
|
||||
let timerange = req.body.timerange;
|
||||
let streamingOnly = req.body.streamingOnly;
|
||||
let audioOnly = req.body.audioOnly;
|
||||
let customArgs = req.body.customArgs;
|
||||
let customOutput = req.body.customOutput;
|
||||
let user_uid = req.isAuthenticated() ? req.user.uid : null;
|
||||
|
||||
const new_sub = {
|
||||
@@ -2106,7 +2109,8 @@ app.post('/api/subscribe', optionalJwt, async (req, res) => {
|
||||
url: url,
|
||||
id: uuid(),
|
||||
streamingOnly: streamingOnly,
|
||||
user_uid: user_uid
|
||||
user_uid: user_uid,
|
||||
type: audioOnly ? 'audio' : 'video'
|
||||
};
|
||||
|
||||
// adds timerange if it exists, otherwise all videos will be downloaded
|
||||
@@ -2114,6 +2118,14 @@ app.post('/api/subscribe', optionalJwt, async (req, res) => {
|
||||
new_sub.timerange = timerange;
|
||||
}
|
||||
|
||||
if (customArgs && customArgs !== '') {
|
||||
sub.custom_args = customArgs;
|
||||
}
|
||||
|
||||
if (customOutput && customOutput !== '') {
|
||||
sub.custom_output = customOutput;
|
||||
}
|
||||
|
||||
const result_obj = await subscriptions_api.subscribe(new_sub, user_uid);
|
||||
|
||||
if (result_obj.success) {
|
||||
|
||||
@@ -2,6 +2,7 @@ var fs = require('fs-extra')
|
||||
var path = require('path')
|
||||
var utils = require('./utils')
|
||||
const { uuid } = require('uuidv4');
|
||||
const config_api = require('./config');
|
||||
|
||||
var logger = null;
|
||||
var db = null;
|
||||
@@ -16,7 +17,7 @@ function initialize(input_db, input_users_db, input_logger) {
|
||||
|
||||
function registerFileDB(file_path, type, multiUserMode = null, sub = null) {
|
||||
const file_id = file_path.substring(0, file_path.length-4);
|
||||
const file_object = generateFileObject(file_id, type, multiUserMode && multiUserMode.file_path);
|
||||
const file_object = generateFileObject(file_id, type, multiUserMode && multiUserMode.file_path, sub);
|
||||
if (!file_object) {
|
||||
logger.error(`Could not find associated JSON file for ${type} file ${file_id}`);
|
||||
return false;
|
||||
@@ -64,7 +65,10 @@ function registerFileDB(file_path, type, multiUserMode = null, sub = null) {
|
||||
return file_object['uid'];
|
||||
}
|
||||
|
||||
function generateFileObject(id, type, customPath = null) {
|
||||
function generateFileObject(id, type, customPath = null, sub = null) {
|
||||
if (!customPath && sub) {
|
||||
customPath = getAppendedBasePathSub(sub, config_api.getConfigItem('ytdl_subscriptions_base_path'));
|
||||
}
|
||||
var jsonobj = (type === 'audio') ? utils.getJSONMp3(id, customPath, true) : utils.getJSONMp4(id, customPath, true);
|
||||
if (!jsonobj) {
|
||||
return null;
|
||||
@@ -89,6 +93,10 @@ function generateFileObject(id, type, customPath = null) {
|
||||
return file_obj;
|
||||
}
|
||||
|
||||
function getAppendedBasePathSub(sub, base_path) {
|
||||
return path.join(base_path, (sub.isPlaylist ? 'playlists/' : 'channels/'), sub.name);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
initialize: initialize,
|
||||
registerFileDB: registerFileDB
|
||||
|
||||
@@ -31,7 +31,6 @@ async function subscribe(sub, user_uid = null) {
|
||||
return new Promise(async resolve => {
|
||||
// sub should just have url and name. here we will get isPlaylist and path
|
||||
sub.isPlaylist = sub.url.includes('playlist');
|
||||
sub.type = 'video'; // TODO: eventually change
|
||||
sub.videos = [];
|
||||
|
||||
let url_exists = false;
|
||||
|
||||
Reference in New Issue
Block a user