alaouy / YouTube

🔥 Laravel PHP Facade/Wrapper for the Youtube Data API
MIT License
778 stars 204 forks source link

Too much quote usage #140

Closed Nevermind23 closed 4 years ago

Nevermind23 commented 4 years ago

Just checked and my script is sending too many queries

$video = Youtube::getVideoInfo($videoId); // 9 queries $channel = Youtube::getChannelById($video->snippet->channelId); // 9 queries $relatedVideos = Youtube::getRelatedVideos($videoId); // 101 queries

Calling those 3 functions uses approximately 120 queries, that's abnormal quantity, rate exceeds in few minutes, what could be wrong ?

ossigeno commented 4 years ago

Those are inline with the Google documentation:

E.g. Search: list (which getRelatedVideos is a wrapper around) https://developers.google.com/youtube/v3/docs/search/list Quota impact: A call to this method has a quota cost of 100 units.

Korko commented 4 years ago

And each getVideoInfo/getChannelById by default fetch all parts. If you want to reduce your quota usage, define the parts argument and limit to what you really need getVideoInfo($vId, $part = ['id', 'snippet', 'contentDetails', 'player', 'statistics', 'status']) getChannelById($id, $optionalParams = [], $part = ['id', 'snippet', 'contentDetails', 'statistics', 'invideoPromotion'])

acidjazz commented 4 years ago

@Nevermind23 @ossigeno @Korko FYI due to this new quota issue with youtube, I've built https://github.com/acidjazz/tubestrip

Nevermind23 commented 4 years ago

@Nevermind23 @ossigeno @Korko FYI due to this new quota issue with youtube, I've built https://github.com/acidjazz/tubestrip

This is not issue, it's just the price for request. I have built similar library by myself to reduce requests, but it's using almost same amount, so it's not package's fault

acidjazz commented 4 years ago

@Nevermind23 Correct, I am not saying anything is wrong, just giving a solution for the quota limit issue