Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YouTube - Title & Description Scrape Error #193

Closed
bearded-avenger opened this issue Aug 12, 2020 · 4 comments
Closed

YouTube - Title & Description Scrape Error #193

bearded-avenger opened this issue Aug 12, 2020 · 4 comments

Comments

@bearded-avenger
Copy link

Hey, thanks for the work on this gem. Really helpful.

I think something may have changed with YouTube, as the title and description now error. I was using the HTML scraper version, but tried with an API key and I get the same result. It happens with multiple videos, ruling out a single video issue.

When not using an API key, the error returned is:

undefined method `value' for nil:NilClass
video_info (2.7) lib/video_info/providers/youtube_scraper.rb:63:in `block in meta_node_value'

When I use an API key it returns nil.

Here's a full example:

 => #<VideoInfo:0x00007fe5bb4190a8 @provider=#<VideoInfo::Providers::Youtube:0x00007fe5bb4183d8 @options={"User-Agent"=>"VideoInfo/2.8.0"}, @url="http://www.youtube.com/watch?v=mZqGqE0D0n4", @video_id="mZqGqE0D0n4">> 
2.6.2 :007 > VideoInfo::VERSION
 => "2.8.0" 
2.6.2 :008 > video.title
vid => nil 
2.6.2 :009 > video.description
video => nil 
2.6.2 :010 > video.video_id
 => "mZqGqE0D0n4" 
2.6.2 :011 > ```


VideoInfo Version - 2.8.0
Ruby Version - 2.6.2
@thibaudgg
Copy link
Owner

Hi @bearded-avenger, thanks for the issue, it certainly possible that Youtube changed something.

I'm not actively maintaining this gem, but pull requests to fix such issues are definitely welcomed. Please let me know if you need some help to submit one.

@joaocv3
Copy link
Collaborator

joaocv3 commented Aug 28, 2020

I can help with this one

@joaocv3
Copy link
Collaborator

joaocv3 commented Aug 29, 2020

Hi @bearded-avenger, thanks for the issue.

It seems like an extra step is necessary for Youtube now.

Besides generating the API key, it is necessary to enable the YouTube Data API for the project which your API key was generated. You can enable it here:
https://console.developers.google.com/apis/library/youtube.googleapis.com

Before enabling it for my project, I was getting this error too:

curl "https://www.googleapis.com/youtube/v3/videos?id=mZqGqE0D0n4&part=snippet,statistics,status,contentDetails&fields=items(id,snippet,statistics,status,contentDetails)&key=<api_key>"

{
  "error": {
    "code": 403,
    "message": "YouTube Data API v3 has not been used in project 239085110097 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=239085110097 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "errors": [
      {
        "message": "YouTube Data API v3 has not been used in project 239085110097 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=239085110097 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
        "domain": "usageLimits",
        "reason": "accessNotConfigured",
        "extendedHelp": "https://console.developers.google.com"
      }
    ],
    "status": "PERMISSION_DENIED"
  }
}

No code changes are necessary, but I'll add this extra step to the Readme

@joaocv3
Copy link
Collaborator

joaocv3 commented Nov 30, 2020

Hi @bearded-avenger!

V3 has been released, solving this issue 🎉

@joaocv3 joaocv3 closed this as completed Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants