OpenByteDev/SourceScraper

Cannot read property 'scrap' of undefined

OpenByteDev opened this issue · 1 comments

nils at nilsdigital in ~/C/JavaScript
» cat test.js
const { scrapers } = require('source-scraper');

(async () => {
    const url = 'https://vidstreaming.io/videos/kaze-ga-tsuyoku-fuiteiru-episode-5';
    const scraper = scrapers.all.getFirstApplicable(url);
    const scrap = await scraper.scrap(url);
    if (scrap.success)
        console.log(scrap.data);
})();
nils at nilsdigital in ~/C/JavaScript
» node test.js
(node:6853) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'scrap' of undefined
    at /Users/nils/Code/JavaScript/test.js:6:33
    at Object.<anonymous> (/Users/nils/Code/JavaScript/test.js:9:3)
    at Module._compile (internal/modules/cjs/loader.js:707:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
    at Function.Module._load (internal/modules/cjs/loader.js:536:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:760:12)
    at startup (internal/bootstrap/node.js:303:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:872:3)
(node:6853) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6853) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Originally posted by @thistehneisen in #3 (comment)

scrapers.all.getFirstApplicable(url); tries to find an applicable scraper by matching the provided url against each scrapers url pattern. If no scraper can be found undefined is returned.
In this case vidstreaming is not detected, because the VidstreamingScraper currently only works for the embeded version.