Spaces:
Paused
Paused
Download use-cases/stream.js from mikmc/Internet_Archive: direct link, hf CLI and curl.
- Browser
- Download file 771 Bytes
-
https://huggingface.co/spaces/mikmc/Internet_Archive/resolve/main/use-cases/stream.js
- Command line
-
hf download hf://spaces/mikmc/Internet_Archive/use-cases/stream.js
-
curl -L -o stream.js https://huggingface.co/spaces/mikmc/Internet_Archive/resolve/main/use-cases/stream.js
771 Bytes
| const Stream = (dependencies) => { | |
| const { httpClient, env } = dependencies | |
| const getStreams = async (request) => { | |
| const { id } = request | |
| const response = await httpClient.get(`${env.url.metadata}/${id}/files`) | |
| return extractStreams({ id, result: response.data.result }) | |
| } | |
| // Returns only streams supported by Stremio | |
| const extractStreams = ({ id, result }) => { | |
| const streams = [] | |
| const subtitles = [] | |
| for (const file of result) { | |
| if (file.name.match(`${id}(.*)(.mp4|.torrent)`)) { | |
| streams.push(file) | |
| } | |
| if (file.name.match(`${id}(.*)(.srt)`)) { | |
| subtitles.push(file) | |
| } | |
| } | |
| return { | |
| streams, | |
| subtitles, | |
| } | |
| } | |
| return { | |
| getStreams, | |
| } | |
| } | |
| module.exports = Stream | |