JimmyLaurent / torrent-search-api

Yet another node torrent scraper (supports iptorrents, torrentleech, torrent9, torrentz2, 1337x, thepiratebay, Yggtorrent, TorrentProject, Eztv, Yts, LimeTorrents)
MIT License
395 stars 99 forks source link

TypeError: TorrentSearchApi is not a function #105

Closed ajanjairam closed 4 years ago

ajanjairam commented 4 years ago

const TorrentSearchApi = require('torrent-search-api'); TorrentSearchApi.enableProvider('Torrent9'); async function getTorrents() { const torrents = await TorrentSearchApi('1080', 'Movies', 20); const result = await TorrentSearchApi.getTorrentDetails(torrents); console.log(result); } getTorrents()

The above code gives the below error

(node:38300) UnhandledPromiseRejectionWarning: TypeError: TorrentSearchApi is not a function

JimmyLaurent commented 4 years ago

You have an error in your code:

const TorrentSearchApi = require('torrent-search-api');

TorrentSearchApi.enableProvider('Torrent9');
async function getTorrents() {
    const torrents = await TorrentSearchApi('1080', 'Movies', 20); // <= TorrentSearchApi.search('1080', 'Movies', 20)
    const result = await TorrentSearchApi.getTorrentDetails(torrents);
    console.log(result);
}
getTorrents()
ajanjairam commented 4 years ago

You have an error in your code:

const TorrentSearchApi = require('torrent-search-api');

TorrentSearchApi.enableProvider('Torrent9');
async function getTorrents() {
    const torrents = await TorrentSearchApi('1080', 'Movies', 20); // <= TorrentSearchApi.search('1080', 'Movies', 20)
    const result = await TorrentSearchApi.getTorrentDetails(torrents);
    console.log(result);
}
getTorrents()

Can you specify the error ?

JimmyLaurent commented 4 years ago

There's a comment on this line ;)

 const torrents = await TorrentSearchApi('1080', 'Movies', 20); // <= TorrentSearchApi.search('1080', 'Movies', 20)
ajanjairam commented 4 years ago

There's a comment on this line ;)

 const torrents = await TorrentSearchApi('1080', 'Movies', 20); // <= TorrentSearchApi.search('1080', 'Movies', 20)

const TorrentSearchApi = require('torrent-search-api'); TorrentSearchApi.enableProvider('Torrent9'); async function getTorrents() { const torrents = await TorrentSearchApi.search('1080', 'Movies', 20); const result = await TorrentSearchApi.getTorrentDetails(torrents); console.log(result); } getTorrents()

i corrected the error code to the above code, and this gives an new error !

(node:11940) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'toLowerCase' of undefined

JimmyLaurent commented 4 years ago

There's also an error on the getTorrentDetails line, this function returns the details of only one torrent:

    const result = await TorrentSearchApi.getTorrentDetails(torrents[0]);
    console.log(result);
ajanjairam commented 4 years ago

There's also an error on the getTorrentDetails line, this function returns the details of only one torrent:

    const result = await TorrentSearchApi.getTorrentDetails(torrents[0]);
    console.log(result);

Thanks for your support, where can i find the syntax examples for all different torrent providers, i'm asking this because when i use torrent providers except Torrent9, i get the below error

(node:8144) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'provider' of undefined

JimmyLaurent commented 4 years ago

It's the same syntax for all providers. From what I can see in the stacktrace, I think you're passing an undefined value to the getTorrentDetails function. I assume you didn't have any result from the search.

ajanjairam commented 4 years ago

It's the same syntax for all providers. From what I can see in the stacktrace, I think you're passing an undefined value to the getTorrentDetails function. I assume you didn't have any result from the search.

whenever i use pirate bay i get this error

(node:13924) UnhandledPromiseRejectionWarning: RequestError: Error: getaddrinfo ENOTFOUND thepiratebay.vip

JimmyLaurent commented 4 years ago

ThePirateBay.vip is blocked by your ISP, try to find another tpb proxy that works for you and change it like this:

TorrentSearchApi.overrideConfig('thepiratebay', { baseUrl: 'https://pirateproxy.surf' });
ajanjairam commented 4 years ago

ThePirateBay.vip is blocked by your ISP, try to find another tpb proxy that works for you and change it like this:

TorrentSearchApi.overrideConfig('thepiratebay', { baseUrl: 'https://pirateproxy.surf' });

I used the same code and got the below error (https://pirateproxy.surf is accessible in my ISP)

(node:19232) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'provider' of undefined

JimmyLaurent commented 4 years ago

I updated TPB provide, with a new api (apibay). You should be good to go with the last version 2.1.2.