Nyaapi
Nyaapi copied to clipboard
Fix undefined scrap error
Handles an exceptional case when the download torrent file option is missing in a search.
Error
(node:157123) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'match' of undefined
at Node.<anonymous> (.../node_modules/nyaapi/src/si/scrap.js:18:67)
at LoadedCheerio.each (.../node_modules/cheerio/lib/api/traversing.js:480:26)
...
Reproduction Steps
let results = await si.search("Kidou Senshi Gundam", 75, {
category: '1_2',
sort: 'seeders',
p: 1
})
For example above would generate: https://nyaa.si/?f=0&c=1_2&q=Kidou+Senshi+Gundam&s=seeders&o=desc
With one of the entries missing the download option seen below:
