Spaces:
Paused
Paused
Update handlers/get-streams.js
Browse files- handlers/get-streams.js +9 -24
handlers/get-streams.js
CHANGED
|
@@ -1,28 +1,13 @@
|
|
|
|
|
| 1 |
module.exports = (dependencies) => {
|
| 2 |
-
|
| 3 |
-
dependencies
|
| 4 |
-
|
| 5 |
-
return async (args) => {
|
| 6 |
try {
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
const { streams, subtitles } = await getStreams({ id })
|
| 11 |
-
const parsedSubtitles = subtitles.map(toSubtitle)
|
| 12 |
-
|
| 13 |
-
return {
|
| 14 |
-
streams: await Promise.all(
|
| 15 |
-
streams.map((stream) =>
|
| 16 |
-
toStream({
|
| 17 |
-
id,
|
| 18 |
-
subtitles: parsedSubtitles,
|
| 19 |
-
...stream,
|
| 20 |
-
}),
|
| 21 |
-
),
|
| 22 |
-
),
|
| 23 |
-
}
|
| 24 |
} catch (error) {
|
| 25 |
-
|
|
|
|
| 26 |
}
|
| 27 |
-
}
|
| 28 |
-
}
|
|
|
|
| 1 |
+
// handlers/get-streams.js
|
| 2 |
module.exports = (dependencies) => {
|
| 3 |
+
return async function getStreams({ identifier }) {
|
|
|
|
|
|
|
|
|
|
| 4 |
try {
|
| 5 |
+
// Your logic for getting streams
|
| 6 |
+
const response = await dependencies.axios.get(`your-api-url/streams/${identifier}`);
|
| 7 |
+
return response.data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
} catch (error) {
|
| 9 |
+
console.error('Error in getStreams:', error);
|
| 10 |
+
throw new Error('Error in getStreams handler');
|
| 11 |
}
|
| 12 |
+
};
|
| 13 |
+
};
|