implemented suggestions, extended CMPs with series

This commit is contained in:
FlyinPancake 2024-01-12 21:45:03 +01:00
parent 12c6a1baa0
commit 3b531144cf
No known key found for this signature in database
6 changed files with 33 additions and 28 deletions

View File

@ -9,7 +9,7 @@
</ui-tooltip>
<div class="flex-grow" />
<ui-btn color="primary" small @click="setShowAddModal()">{{ $strings.ButtonAdd }}</ui-btn>
<ui-btn color="primary" small @click="setShowAddModal">{{ $strings.ButtonAdd }}</ui-btn>
</template>
<tables-custom-metadata-provider-table class="pt-2" />
@ -40,6 +40,4 @@ export default {
}
</script>
<style>
</style>
<style></style>

View File

@ -96,7 +96,6 @@
"HeaderAudiobookTools": "Audiobook File Management Tools",
"HeaderAudioTracks": "Audio Tracks",
"HeaderAuthentication": "Authentication",
"HeaderCustomMetadataProviders": "Custom metadata providers",
"HeaderBackups": "Backups",
"HeaderChangePassword": "Change Password",
"HeaderChapters": "Chapters",
@ -105,6 +104,7 @@
"HeaderCollectionItems": "Collection Items",
"HeaderCover": "Cover",
"HeaderCurrentDownloads": "Current Downloads",
"HeaderCustomMetadataProviders": "Custom metadata providers",
"HeaderDetails": "Details",
"HeaderDownloadQueue": "Download Queue",
"HeaderEbookFiles": "Ebook Files",
@ -194,6 +194,7 @@
"LabelAllUsersExcludingGuests": "All users excluding guests",
"LabelAllUsersIncludingGuests": "All users including guests",
"LabelAlreadyInYourLibrary": "Already in your library",
"LabelApiKey": "API Key",
"LabelAppend": "Append",
"LabelAuthor": "Author",
"LabelAuthorFirstLast": "Author (First Last)",
@ -526,6 +527,7 @@
"LabelUploaderDragAndDrop": "Drag & drop files or folders",
"LabelUploaderDropFiles": "Drop files",
"LabelUploaderItemFetchMetadataHelp": "Automatically fetch title, author, and series",
"LabelUrl": "URL",
"LabelUseChapterTrack": "Use chapter track",
"LabelUseFullTrack": "Use full track",
"LabelUser": "User",
@ -541,8 +543,6 @@
"LabelYourBookmarks": "Your Bookmarks",
"LabelYourPlaylists": "Your Playlists",
"LabelYourProgress": "Your Progress",
"LabelUrl": "URL",
"LabelApiKey": "API Key",
"MessageAddToPlayerQueue": "Add to player queue",
"MessageAppriseDescription": "To use this feature you will need to have an instance of <a href=\"https://github.com/caronc/apprise-api\" target=\"_blank\">Apprise API</a> running or an api that will handle those same requests. <br />The Apprise API Url should be the full URL path to send the notification, e.g., if your API instance is served at <code>http://192.168.1.1:8337</code> then you would put <code>http://192.168.1.1:8337/notify</code>.",
"MessageBackupsDescription": "Backups include users, user progress, library item details, server settings, and images stored in <code>/metadata/items</code> & <code>/metadata/authors</code>. Backups <strong>do not</strong> include any files stored in your library folders.",

View File

@ -86,7 +86,7 @@ components:
type: string
publisher:
type: string
published_year:
publishedYear:
type: string
description:
type: string
@ -107,6 +107,17 @@ components:
type: array
items:
type: string
series:
type: array
items:
type: object
properties:
series:
type: string
required: true
sequence:
type: number
format: int64
language:
type: string
duration:

View File

@ -763,7 +763,7 @@ class MiscController {
return res.sendStatus(403)
}
const { name, url, apiKey } = req.body;
const { name, url, apiKey } = req.body
if (!name || !url || !apiKey) {
return res.status(500).send(`Invalid patch data`)
@ -794,18 +794,18 @@ class MiscController {
return res.sendStatus(403)
}
const { id } = req.params;
const { id } = req.params
if (!id) {
return res.status(500).send(`Invalid delete data`)
}
const provider = await Database.customMetadataProviderModel.findByPk(id);
await Database.removeCustomMetadataProviderById(id);
const provider = await Database.customMetadataProviderModel.findByPk(id)
await Database.removeCustomMetadataProviderById(id)
SocketAuthority.adminEmitter('custom_metadata_provider_removed', provider)
res.json({})
res.sendStatus(200)
}
}
module.exports = new MiscController()

View File

@ -26,13 +26,7 @@ class CustomMetadataProvider extends Model {
}
}
static findByPk(id) {
return this.findOne({
where: {
id,
}
})
}
/**
* Initialize model
@ -47,7 +41,7 @@ class CustomMetadataProvider extends Model {
},
name: DataTypes.STRING,
url: DataTypes.STRING,
apiKey: DataTypes.STRING
apiKey: DataTypes.STRING,
}, {
sequelize,
modelName: 'customMetadataProvider'

View File

@ -1,6 +1,6 @@
const Database = require('../Database')
const axios = require("axios");
const Logger = require("../Logger");
const axios = require("axios")
const Logger = require("../Logger")
class CustomProviderAdapter {
constructor() {
@ -8,10 +8,10 @@ class CustomProviderAdapter {
async search(title, author, providerSlug) {
const providerId = providerSlug.split("custom-")[1]
const provider = await Database.customMetadataProviderModel.findByPk(providerId);
const provider = await Database.customMetadataProviderModel.findByPk(providerId)
if (!provider) {
throw new Error("Custom provider not found for the given id");
throw new Error("Custom provider not found for the given id")
}
const matches = await axios.get(`${provider.url}/search?query=${encodeURIComponent(title)}${!!author ? `&author=${encodeURIComponent(author)}` : ""}`, {
@ -27,7 +27,7 @@ class CustomProviderAdapter {
})
if (matches === null) {
throw new Error("Custom provider returned malformed response");
throw new Error("Custom provider returned malformed response")
}
// re-map keys to throw out
@ -37,13 +37,14 @@ class CustomProviderAdapter {
author,
narrator,
publisher,
published_year,
publishedYear,
description,
cover,
isbn,
asin,
genres,
tags,
series,
language,
duration,
}) => {
@ -53,13 +54,14 @@ class CustomProviderAdapter {
author,
narrator,
publisher,
publishedYear: published_year,
publishedYear,
description,
cover,
isbn,
asin,
genres,
tags: tags.join(","),
series: series.length ? series : null,
language,
duration,
}