Spaces:
Paused
Paused
Download commons/parseTorrent.js from mikmc/Internet_Archive: direct link, hf CLI and curl.
- Browser
- Download file 518 Bytes
-
https://huggingface.co/spaces/mikmc/Internet_Archive/resolve/main/commons/parseTorrent.js
- Command line
-
hf download hf://spaces/mikmc/Internet_Archive/commons/parseTorrent.js
-
curl -L -o parseTorrent.js https://huggingface.co/spaces/mikmc/Internet_Archive/resolve/main/commons/parseTorrent.js
518 Bytes
| const parse = require('parse-torrent') | |
| module.exports = () => { | |
| const parseTorrent = (link) => { | |
| return new Promise((resolve, reject) => { | |
| parse.remote(link, (error, torrentInfo) => { | |
| if (error) return reject(error) | |
| if (!torrentInfo.files) return resolve(undefined) | |
| const fileIdx = torrentInfo.files.findIndex((file) => | |
| file.name.includes('.mp4'), | |
| ) | |
| resolve(fileIdx === -1 ? undefined : fileIdx) | |
| }) | |
| }) | |
| } | |
| return { | |
| parseTorrent, | |
| } | |
| } | |