Add full video descriptions from external sources to blog posts
Update API endpoints to fetch and include video descriptions from meta tags and the description field when retrieving video data. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 517dfa7b-26ac-463d-a6e1-a58c6df97188 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: dc16d361-8950-4dfd-8f3f-3ee8b08cce89 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/517dfa7b-26ac-463d-a6e1-a58c6df97188/VgutZ7W Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
dfdada5c84
commit
2f3b98338c
@ -162,16 +162,21 @@ export async function registerRoutes(
|
||||
let path = `/library/${LIBRARY_ID}/videos?page=${page}&itemsPerPage=${perPage}&orderBy=date`;
|
||||
if (search) path += `&search=${encodeURIComponent(search)}`;
|
||||
const data = await bunnyFetch(path);
|
||||
const videos = (data.items || []).map((v: any) => ({
|
||||
guid: v.guid,
|
||||
title: (v.title || "").replace(/\.mp4$/i, ""),
|
||||
length: v.length,
|
||||
dateUploaded: v.dateUploaded,
|
||||
thumbnail: `https://${CDN_HOST}/${v.guid}/${v.thumbnailFileName || "thumbnail.jpg"}`,
|
||||
embedUrl: `https://player.mediadelivery.net/embed/${LIBRARY_ID}/${v.guid}`,
|
||||
hlsUrl: `https://${CDN_HOST}/${v.guid}/playlist.m3u8`,
|
||||
status: v.status,
|
||||
}));
|
||||
const videos = (data.items || []).map((v: any) => {
|
||||
const descTag = (v.metaTags || []).find((t: any) => t.property === "description");
|
||||
return {
|
||||
guid: v.guid,
|
||||
title: (v.title || "").replace(/\.mp4$/i, ""),
|
||||
description: descTag?.value || v.description || "",
|
||||
length: v.length,
|
||||
dateUploaded: v.dateUploaded,
|
||||
thumbnail: `https://${CDN_HOST}/${v.guid}/${v.thumbnailFileName || "thumbnail.jpg"}`,
|
||||
embedUrl: `https://player.mediadelivery.net/embed/${LIBRARY_ID}/${v.guid}`,
|
||||
hlsUrl: `https://${CDN_HOST}/${v.guid}/playlist.m3u8`,
|
||||
status: v.status,
|
||||
category: v.category || "",
|
||||
};
|
||||
});
|
||||
res.json({ items: videos, totalItems: data.totalItems, currentPage: data.currentPage });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ message: err.message });
|
||||
@ -181,15 +186,18 @@ export async function registerRoutes(
|
||||
app.get("/api/videos/:guid", async (req, res) => {
|
||||
try {
|
||||
const data = await bunnyFetch(`/library/${LIBRARY_ID}/videos/${req.params.guid}`);
|
||||
const descTag = (data.metaTags || []).find((t: any) => t.property === "description");
|
||||
res.json({
|
||||
guid: data.guid,
|
||||
title: (data.title || "").replace(/\.mp4$/i, ""),
|
||||
description: descTag?.value || data.description || "",
|
||||
length: data.length,
|
||||
dateUploaded: data.dateUploaded,
|
||||
thumbnail: `https://${CDN_HOST}/${data.guid}/${data.thumbnailFileName || "thumbnail.jpg"}`,
|
||||
embedUrl: `https://player.mediadelivery.net/embed/${LIBRARY_ID}/${data.guid}`,
|
||||
hlsUrl: `https://${CDN_HOST}/${data.guid}/playlist.m3u8`,
|
||||
status: data.status,
|
||||
category: data.category || "",
|
||||
});
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ message: err.message });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user