mirror of
https://github.com/IrosTheBeggar/mStream.git
synced 2025-10-27 07:31:02 +00:00
audio book folders on server
This commit is contained in:
parent
21565a42cb
commit
5706ec8647
@ -164,11 +164,17 @@ exports.setup = (mstream) => {
|
||||
const schema = Joi.object({
|
||||
directory: Joi.string().required(),
|
||||
vpath: Joi.string().pattern(/[a-zA-Z0-9-]+/).required(),
|
||||
autoAccess: Joi.boolean().default(false)
|
||||
autoAccess: Joi.boolean().default(false),
|
||||
isAudioBooks: Joi.boolean().default(false)
|
||||
});
|
||||
const input = joiValidate(schema, req.body);
|
||||
|
||||
await admin.addDirectory(input.value.directory, input.value.vpath, input.value.autoAccess, mstream);
|
||||
await admin.addDirectory(
|
||||
input.value.directory,
|
||||
input.value.vpath,
|
||||
input.value.autoAccess,
|
||||
input.value.isAudioBooks,
|
||||
mstream);
|
||||
res.json({});
|
||||
|
||||
try {
|
||||
|
||||
@ -15,11 +15,22 @@ exports.setup = (mstream) => {
|
||||
}
|
||||
}
|
||||
|
||||
res.json({
|
||||
const returnThis = {
|
||||
vpaths: req.user.vpaths,
|
||||
playlists: getPlaylists(req.user.username),
|
||||
transcode
|
||||
transcode,
|
||||
vpathMetaData: {}
|
||||
};
|
||||
|
||||
req.user.vpaths.forEach(p => {
|
||||
if (config.program.folders[p]) {
|
||||
returnThis.vpathMetaData[p] = {
|
||||
type: config.program.folders[p].type
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
res.json(returnThis);
|
||||
});
|
||||
|
||||
mstream.post('/api/v1/playlist/delete', (req, res) => {
|
||||
|
||||
@ -79,7 +79,7 @@ const schema = Joi.object({
|
||||
Joi.string(),
|
||||
Joi.object({
|
||||
root: Joi.string().required(),
|
||||
type: Joi.string().valid('music', 'audiobook').default('music'),
|
||||
type: Joi.string().valid('music', 'audio-books').default('music'),
|
||||
})
|
||||
).default({}),
|
||||
users: Joi.object().pattern(
|
||||
|
||||
@ -18,7 +18,7 @@ exports.saveFile = async (saveData, file) => {
|
||||
return await fs.writeFile(file, JSON.stringify(saveData, null, 2), 'utf8')
|
||||
}
|
||||
|
||||
exports.addDirectory = async (directory, vpath, autoAccess, mstream) => {
|
||||
exports.addDirectory = async (directory, vpath, autoAccess, isAudioBooks, mstream) => {
|
||||
// confirm directory is real
|
||||
const stat = await fs.stat(directory);
|
||||
if (!stat.isDirectory()) { throw `${directory} is not a directory` };
|
||||
@ -30,6 +30,7 @@ exports.addDirectory = async (directory, vpath, autoAccess, mstream) => {
|
||||
// Once the file save is complete, the new user will be added
|
||||
const memClone = JSON.parse(JSON.stringify(config.program.folders));
|
||||
memClone[vpath] = { root: directory };
|
||||
if (isAudioBooks) { memClone[vpath].type = 'audio-books'; }
|
||||
|
||||
// add directory to config file
|
||||
const loadConfig = await this.loadFile(config.configFile);
|
||||
@ -44,7 +45,7 @@ exports.addDirectory = async (directory, vpath, autoAccess, mstream) => {
|
||||
await this.saveFile(loadConfig, config.configFile);
|
||||
|
||||
// add directory to program
|
||||
config.program.folders[vpath] = { root: directory };
|
||||
config.program.folders[vpath] = memClone;
|
||||
|
||||
if (autoAccess === true) {
|
||||
Object.values(config.program.users).forEach(user => {
|
||||
|
||||
@ -262,6 +262,10 @@ const foldersView = Vue.component('folders-view', {
|
||||
<input id="folder-auto-access" type="checkbox" checked/>
|
||||
<span>Give Access To All Users</span>
|
||||
</label></div>
|
||||
<div class="pad-checkbox"><label>
|
||||
<input id="folder-is-audiobooks" type="checkbox"/>
|
||||
<span>Audiobooks & Podcasts</span>
|
||||
</label></div>
|
||||
</div>
|
||||
<button class="btn green waves-effect waves-light col m6 s12" type="submit" :disabled="submitPending === true">
|
||||
{{submitPending === false ? 'Add Folder' : 'Adding...'}}
|
||||
@ -345,7 +349,8 @@ const foldersView = Vue.component('folders-view', {
|
||||
data: {
|
||||
directory: this.folder.value,
|
||||
vpath: this.dirName,
|
||||
autoAccess: document.getElementById('folder-auto-access').checked
|
||||
autoAccess: document.getElementById('folder-auto-access').checked,
|
||||
isAudioBooks: document.getElementById('folder-is-audiobooks').checked
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user