SuspiciousLookingOwl / scrape-yt

Simple lib to scrape information from youtube such as search results, video information, related videos, playlist information and up next video
https://www.npmjs.com/package/scrape-yt
MIT License
10 stars 3 forks source link

[BUG] #27

Closed Wolletje01 closed 3 years ago

Wolletje01 commented 3 years ago

Describe the bug The getVideo isnt working with a id with a "-"

To Reproduce have this piece of code

var scrapeYt = require("scrape-yt");
scrapeYt.getVideo("DEXTLC-rPI4").then(videos => {
    console.log(videos);
    console.log(videos.title);
});

and run it. The id is valid but it doesn't work because it has a - in it.

Expected behavior I expected that everything works normal.

Wolletje01 commented 3 years ago

BTW this is the yt video with the - id in it. https://www.youtube.com/watch?v=DEXTLC-rPI4

SteeledSlagle13 commented 3 years ago

What output do you get?

Wolletje01 commented 3 years ago

No normal output it just craches.

node bot.js D:\aajie vps\scrape yt\node_modules\scrape-yt\dist\common\parser.js:357 var videoDetails = JSON.parse(html.split("var ytInitialPlayerResponse = ")[1].split(";")[0]).videoDetails; ^

SyntaxError: Unexpected token ; in JSON at position 77462 at JSON.parse () at Object.parseGetVideo (D:\aajie vps\scrape yt\node_modules\scrape-yt\dist\common\parser.js:357:33) at D:\aajie vps\scrape yt\node_modules\scrape-yt\dist\index.js:204:64 at step (D:\aajie vps\scrape yt\node_modules\scrape-yt\dist\index.js:54:23) at Object.next (D:\aajie vps\scrape yt\node_modules\scrape-yt\dist\index.js:35:53) at fulfilled (D:\aajie vps\scrape yt\node_modules\scrape-yt\dist\index.js:26:58) at processTicksAndRejections (node:internal/process/task_queues:93:5)

Wolletje01 commented 3 years ago

The same applies to a _ in the id. https://www.youtube.com/watch?v=OGt7UIL6S_I id = OGt7UIL6S_I error: D:\aajie vps\scrape yt\node_modules\scrape-yt\dist\common\parser.js:374 title: videoInfo.title.runs[0].text, ^

TypeError: Cannot read property 'runs' of undefined at Object.parseGetVideo (D:\aajie vps\scrape yt\node_modules\scrape-yt\dist\common\parser.js:374:36) at D:\aajie vps\scrape yt\node_modules\scrape-yt\dist\index.js:204:64 at step (D:\aajie vps\scrape yt\node_modules\scrape-yt\dist\index.js:54:23) at Object.next (D:\aajie vps\scrape yt\node_modules\scrape-yt\dist\index.js:35:53) at fulfilled (D:\aajie vps\scrape yt\node_modules\scrape-yt\dist\index.js:26:58) at processTicksAndRejections (node:internal/process/task_queues:93:5)

SuspiciousLookingOwl commented 3 years ago

Can reproduce, going to take a look at this soon.

SuspiciousLookingOwl commented 3 years ago

Try updating to 1.4.8

SuspiciousLookingOwl commented 3 years ago

On another note, I will stop adding features to this library and only will do bug fixes. I was working for v2 of this library but I figured that it will be better to make a new library instead because the v2 doesn't scrape data from Youtube page anymore, instead sending a request to (what I assume to be) Youtube internal API for Youtube Web App.

It's called Youtubei, it's still in early stage but should be stable. It also should be faster than scrape-yt. Go check it out 😁