Canalblog
Suivre ce blog Administration + Créer mon blog

VENTE MAISON LEVIGNEN

19 mai 2010

/* SCRIPT EDITE SUR L'EDITEUR JAVASCRIPT

Publicité
Publicité
19 mai 2010

/* SCRIPT EDITE SUR L'EDITEUR JAVASCRIPT

16 mai 2010

home

  1. /*

  2. $hostpage doit être l'adresse complète de la page Youtube où est diffusée la vidéo désirée.

  3. e.g. http://www.youtube.com/watch?v=i4h02CaJMxw

  4. $output doit être une adresse à laquelle PHP a accès en écriture (voir la documentation de file_put_contents() pour plus d'information).

  5. Les vidéos sur Youtube sont au format flash, l'extension de fichier correspondante est donc .flv

  6. e.g. /var/www/ytvid1.flv

  7. */

  8. function getYoutubeVideo($hostpage, $output)

  9. {

  10.   $hostpage .= "&";

  11.   // Obtention de l'identifiant du video

  12.   preg_match('/v=(.+?)&+/', $hostpage, $match);

  13.   $var_id = $match[1];

  14.   // Lecture de la page hôte et extraction de l'élément "t"

  15.   $hostcontent = file_get_contents($hostpage);

  16.   preg_match('/"t": "(.*?)"/', $hostcontent, $match);

  17.   $var_t = $match[1];

  18.   // Lecture du fichier distant

  19.   $input = file_get_contents("http://www.youtube.com/get_video?video_id=" . $var_id . "&t=" . $var_t);

  20.   if (!$input)

  21.   {

  22.     // Si une erreur survient

  23.     echo "Fichier introuvable";

  24.   }

  25.   else

  26.   {

  27.     // Écriture du fichier local

  28.     file_put_contents($output, $input);

  29.   }

  30. }

Publicité
Publicité
VENTE MAISON LEVIGNEN
Publicité
Publicité