2

I'm using the youtube api to check if a channel is streaming or not, but actualy i reach my limit of quota, i'm using the search method (https://www.googleapis.com/youtube/v3/search) which is awfully expensive.. It cost 100 quota units. Which mean you only get 100 requests per day which is terrible...

I can request an increase in the quota request but that seems like a brute forcing the problem.

I would like to know if there is another simpler method to just check if a channel is streaming or not. ?

My actual php code to check if there is a live stream :

$informationChaine = 'https://www.googleapis.com/youtube/v3/videos?part=snippet&channelId='.$ChannelID.'&type=video&eventType=live&key='.$API_KEY;
$extractInfo = file_get_contents($informationChaine);
$extractInfo = str_replace('},]',"}]",$extractInfo);
$showInfo = json_decode($extractInfo, true);


if($showInfo['pageInfo']['totalResults'] === 0){
?>
<style>
.live > a::before {
 content: " ";
 animation: blinker 0.5s step-start infinite;
}
@keyframes blinker {
  50% {
    opacity: 0;
  }
}
</style><?php
}

Thanks, Best regards.

LeSultan
  • 21
  • 2
  • Have you tried to use their [quota calculator](https://developers.google.com/youtube/v3/determine_quota_cost)? Perhaps there are some items that you can remove from your request that will minimize the cost per request. – Cooper Feb 22 '20 at 18:49
  • Yes :/ as you can see on this picture "https://i.ibb.co/CV2csjC/Youtube-API.png", there isn't option.. – LeSultan Feb 22 '20 at 20:48
  • I must admit 100 a day seems like more than enough to me. – Cooper Feb 22 '20 at 20:56
  • 1
    You think ? every time a user will refresh the page it will be counted as a request ? I have maybe to add a limit or something like this ? – LeSultan Feb 22 '20 at 21:24
  • Oh so your providing this to users of your website. Why should Google Provide free services to your users. – Cooper Feb 22 '20 at 21:35
  • Yes not false ^^ i just want to put a little red point on my website when a youtuber is on live ^^ .. – LeSultan Feb 22 '20 at 21:45
  • @LeSultan other option is described in [this answer](https://stackoverflow.com/a/56510879/12511801) or in the accepted answer in the same link. – Marco Aurelio Fernandez Reyes Feb 24 '20 at 13:22
  • 1
    Thanks @MarcoAurelioFernandezReyes – LeSultan Feb 24 '20 at 19:25

0 Answers0