Closed BrianRigii closed 4 years ago
TorrentSearchApi.search() will return an array of torrent objects. TorrentSearchApi.getMagnet() expects one torrent object as a parameter.
const magnet = await TorrentSearchApi.getMagnet(torrent)
const magnet = await TorrentSearchApi.getMagnet(torrent[0])
const TorrentSearchApi = require('torrent-search-api')
TorrentSearchApi.enableProvider('1337x')
async function getTorrents() {
const torrents = await TorrentSearchApi.search('1080', 'Movies', 20)
// Get all magnets
const magnets = await Promise.all(
torrents.map(async torrent => {
let magnet = await TorrentSearchApi.getMagnet(torrent)
return magnet
})
)
// Combine torrents with magnets
torrents.map((torrent, i) => torrent.magnet = magnets[i])
return torrents
}
getTorrents().then(value => {
console.log(value)
})
.catch(e => {
console.log(e)
})
Oohh Thanks, also quick question how can you stream videos from the magnet links 😅
Check out Webtorrent
hi i keep getting this error when trying to get magnet links
// my code