mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-19 19:19:50 +00:00
Run pre-commit hooks over existing codebase
Co-Authored-By: Ben Phelps <ben@phelps.io>
This commit is contained in:
parent
fa50bbad9c
commit
19c25713c4
387 changed files with 4785 additions and 4109 deletions
|
@ -10,11 +10,10 @@ export default function Component({ service }) {
|
|||
const { widget } = service;
|
||||
const { data: librariesData, error: librariesError } = useWidgetAPI(widget, "libraries");
|
||||
|
||||
|
||||
if (librariesError) {
|
||||
return <Container service={service} error={librariesError} />;
|
||||
}
|
||||
|
||||
|
||||
if (!librariesData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
|
@ -25,9 +24,9 @@ export default function Component({ service }) {
|
|||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
const podcastLibraries = librariesData.filter(l => l.mediaType === "podcast");
|
||||
const bookLibraries = librariesData.filter(l => l.mediaType === "book");
|
||||
|
||||
const podcastLibraries = librariesData.filter((l) => l.mediaType === "podcast");
|
||||
const bookLibraries = librariesData.filter((l) => l.mediaType === "book");
|
||||
|
||||
const totalPodcasts = podcastLibraries.reduce((total, pL) => parseInt(pL.stats?.totalItems, 10) + total, 0);
|
||||
const totalBooks = bookLibraries.reduce((total, bL) => parseInt(bL.stats?.totalItems, 10) + total, 0);
|
||||
|
@ -38,9 +37,25 @@ export default function Component({ service }) {
|
|||
return (
|
||||
<Container service={service}>
|
||||
<Block label="audiobookshelf.podcasts" value={t("common.number", { value: totalPodcasts })} />
|
||||
<Block label="audiobookshelf.podcastsDuration" value={t("common.number", { value: totalPodcastsDuration / 60, maximumFractionDigits: 0, style: "unit", unit: "minute" })} />
|
||||
<Block
|
||||
label="audiobookshelf.podcastsDuration"
|
||||
value={t("common.number", {
|
||||
value: totalPodcastsDuration / 60,
|
||||
maximumFractionDigits: 0,
|
||||
style: "unit",
|
||||
unit: "minute",
|
||||
})}
|
||||
/>
|
||||
<Block label="audiobookshelf.books" value={t("common.number", { value: totalBooks })} />
|
||||
<Block label="audiobookshelf.booksDuration" value={t("common.number", { value: totalBooksDuration / 60, maximumFractionDigits: 0, style: "unit", unit: "minute" })} />
|
||||
<Block
|
||||
label="audiobookshelf.booksDuration"
|
||||
value={t("common.number", {
|
||||
value: totalBooksDuration / 60,
|
||||
maximumFractionDigits: 0,
|
||||
style: "unit",
|
||||
unit: "minute",
|
||||
})}
|
||||
/>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ const logger = createLogger(proxyName);
|
|||
async function retrieveFromAPI(url, key) {
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
"Authorization": `Bearer ${key}`
|
||||
Authorization: `Bearer ${key}`,
|
||||
};
|
||||
|
||||
const [status, , data] = await httpProxy(url, { headers });
|
||||
|
@ -48,17 +48,22 @@ export default async function audiobookshelfProxyHandler(req, res) {
|
|||
const url = new URL(formatApiCall(apiURL, { endpoint, ...widget }));
|
||||
const libraryData = await retrieveFromAPI(url, widget.key);
|
||||
|
||||
const libraryStats = await Promise.all(libraryData.libraries.map(async l => {
|
||||
const stats = await retrieveFromAPI(new URL(formatApiCall(apiURL, { endpoint: `libraries/${l.id}/stats`, ...widget })), widget.key);
|
||||
return {
|
||||
...l,
|
||||
stats
|
||||
};
|
||||
}));
|
||||
|
||||
const libraryStats = await Promise.all(
|
||||
libraryData.libraries.map(async (l) => {
|
||||
const stats = await retrieveFromAPI(
|
||||
new URL(formatApiCall(apiURL, { endpoint: `libraries/${l.id}/stats`, ...widget })),
|
||||
widget.key,
|
||||
);
|
||||
return {
|
||||
...l,
|
||||
stats,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return res.status(200).send(libraryStats);
|
||||
} catch (e) {
|
||||
logger.error(e.message);
|
||||
return res.status(500).send({error: {message: e.message}});
|
||||
return res.status(500).send({ error: { message: e.message } });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,4 +11,4 @@ const widget = {
|
|||
},
|
||||
};
|
||||
|
||||
export default widget;
|
||||
export default widget;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue