I am using this code in PHP to get the Youtube server url
curl_setopt($ch, CURLOPT_URL, 'https://www.youtube.com/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8');curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, '{"videoId": "'.$yt_video_id.'","context": {"client": {"clientName": "ANDROID","clientVersion": "16.13.34" },"device": {"platform": "ANDROID","platformVersion": "11" } },"playbackMode": "EMBEDDED","playerParams": {"autoplay": 1 }}');It is working fine and returns me the video info along with the formats and adaptive formats. The returned server url also has the expire field in the url itself which means the returned media url will expire after that time.
Therefore I have added the logic to save expire in db and rerun the above code again to fetch new media url when the current time is greater than the previous expire time.
Problem is that sometime the above curl returns error as below but when I refresh, it works.
"reason": {"runs": [ {"text": "The following content is not available on this app." } ] },I am scared that this can happen with my live videos and user will not be able to watch video.Could you expert guys help me here. What am I doing wrong and what is the other best way to handle the expiration. What catch I am missing here? I have seen many other video players are working absolutely fine without any errors.
I am in danger of asking the wrong format question. Please ignore my mistakes in questions and suggest me to improve it, I will quickly update the format of question? But I really do need help from community here to solve this issue.Thanks!