3

I have created (yes another) YouTube Player-Module for joomla! In the Module Backend i used the Code from this answer to display the Videotitle. Unfortunately get_video_info returns for the most video ID's just the embedding forbidden text like : "This video contains content from VEVO. It is restricted from playback on certain sites or applications. Watch on YouTube".

Actually i take the info from videoinfo and search for title or reason if exists the module echo the value in the backend. My Question is - Anyone know why yt get_video_info throws this error even if its still possible to embed the Video?

an example: Video ID Y1_VsyLAGuk

if you try to get videoinfos from: http://youtube.com/get_video_info?video_id=Y1_VsyLAGuk you will get just the error that it is not possible.

but the module can create and play the video in an embedded youtube API v3 Player on the same host.

if (isset($formID)){
   $cleanedID = cleanUp($id);
   // Some Magic to get the Video Title, Thanks to Stack Overflow User Cruel for this nice Hint
   $content = file_get_contents("http://youtube.com/get_video_info?video_id=".$cleanedID);
   parse_str($content, $ytarr);
   
   if(array_key_exists('title', $ytarr)){
      return '<div style="width:220px;"><h4>'.$ytarr['title'].'</h4><img style="border-radius:4px;" src="https://img.youtube.com/vi/'.$cleanedID.'/hqdefault.jpg" width="100%" /></div>';
     
      // Credits: https://stackoverflow.com/a/5151862/4708062
   }elseif(array_key_exists('reason', $ytarr)){
      return '<div class="alert alert-danger" style="width:170px;"><p style="text-align:center">'.$ytarr['reason'].'</p></div><img style="border-radius:4px;" src="https://img.youtube.com/vi/'.$cleanedID.'/hqdefault.jpg" width="220px" />';
   }else{
         //print_r($ytarr);
   return ;
   }
}
Marco
  • 473
  • 5
  • 21
  • Did you find any solution? – mehdok Dec 09 '17 at 14:30
  • Hi mehdok -> "yes" i am used noembed for videotitle checkout my github Project here: https://github.com/marcorensch/nx-youtubebox/blob/master/models/fields/nxvideoinfo.php around Line 72: – Marco Dec 12 '17 at 08:14

2 Answers2

3

The solution was to use noembed.com service to get the video informations:

Example URL: "https://noembed.com/embed?url=https://www.youtube.com/watch?v=YXN_lNZZAZA"

Marco
  • 473
  • 5
  • 21
1

I had same issue but did not want to use an external site like noembed.com.

PHP Library chojnicki/video-platforms-parser solves the problem.

marc-medley
  • 8,931
  • 5
  • 60
  • 66
norr
  • 1,725
  • 1
  • 20
  • 33