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
9 stars 3 forks source link

[BUG] error 302 #11

Closed SteeledSlagle13 closed 4 years ago

SteeledSlagle13 commented 4 years ago

Describe the bug Getting an error 302 after running a test script with 1 video search on an aws instance

To Reproduce create aws ec2 instance run

scrapeYt.getVideo("84N7ZOnXB6").then(videos => {
    console.log(videos);
}).catch(error => {
        console.log(error);
});

Expected behavior should return the video information

Screenshots If applicable, add screenshots to help explain your problem. image

Additional context im running fine on my windows pc but from my ec2 instance in aws its getting this error

SuspiciousLookingOwl commented 4 years ago

Does this always happen? Or is it random?

I don't think this is an issue from my library, but rather an issue from the http request & response.

I checked https://www.youtube.com/watch?v=84N7ZOnXB6 and it's an unavailable video, try other valid video ID and see if it still return 302.

If its still returning 302, try creating a simple script to send a request to youtube from your aws and check if still return 302. You can use node-fetch Install with npm i node-fetch then in your script

const fetch = require("node-fetch");

const videoId = "84N7ZOnXB6"; // Try to use invalid and valid video ID to see if it gives the same result
fetch(`https://www.youtube.com/watch?v=${videoId}`)
  .then((res) => { 
    console.log(res.status); // Check what's the status code
  })
SteeledSlagle13 commented 4 years ago

i think it is from a diff lib ill try that fetch tho!

SteeledSlagle13 commented 4 years ago

it may have been from doing a search and then attepmting to download the first video.... which was a paid video XD

SteeledSlagle13 commented 4 years ago

whoops

SteeledSlagle13 commented 4 years ago

i regened my ip so ill keep testing it!!!

SteeledSlagle13 commented 4 years ago

is there a way to see if the video is a paid video?

SuspiciousLookingOwl commented 4 years ago

I will look into it, for now, getting invalid / premium video id and if there's a scraping error, it will throw an error.