Spaces:
Paused
Paused
Savestate: Fix server.js youtube-search-api -> yt-search to fix HF Space build
Browse files
server.js
CHANGED
|
@@ -114,11 +114,11 @@ app.get('/api/youtube-search', async (req, res) => {
|
|
| 114 |
const query = req.query.q;
|
| 115 |
if (!query) return res.status(400).send('Missing query');
|
| 116 |
try {
|
| 117 |
-
const { default: ytSearch } = await import('
|
| 118 |
-
const r = await ytSearch
|
| 119 |
-
const videos = r.
|
| 120 |
if (videos.length > 0) {
|
| 121 |
-
const videoId = videos[0].
|
| 122 |
if (req.query.json) {
|
| 123 |
res.setHeader('Content-Type', 'application/json');
|
| 124 |
res.json({ videoId });
|
|
|
|
| 114 |
const query = req.query.q;
|
| 115 |
if (!query) return res.status(400).send('Missing query');
|
| 116 |
try {
|
| 117 |
+
const { default: ytSearch } = await import('yt-search');
|
| 118 |
+
const r = await ytSearch(query);
|
| 119 |
+
const videos = r.videos;
|
| 120 |
if (videos.length > 0) {
|
| 121 |
+
const videoId = videos[0].videoId;
|
| 122 |
if (req.query.json) {
|
| 123 |
res.setHeader('Content-Type', 'application/json');
|
| 124 |
res.json({ videoId });
|