Changeset 3697


Ignore:
Timestamp:
Jul 29, 2009, 9:15:06 PM (15 years ago)
Author:
patdenice
Message:

Allow to add videos from Wat.tv.

Location:
extensions/gvideo
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/gvideo/admin/add_page.php

    r3609 r3697  
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44
    5 $video_types = array('google', 'youtube', 'dailymotion', 'wideo', 'vimeo');
     5$video_types = array('google', 'youtube', 'dailymotion', 'wideo', 'vimeo', 'wat');
    66
    77function get_video_infos($url, $type)
     
    6868    return $video;
    6969
     70  case "wat":
     71    if (fetchRemote($url, $source))
     72    {
     73      @preg_match('#link rel="video_src" href="http://www.wat.tv/swf2/(.*?)"#i', $source, $id);
     74      if (empty($id[1])) return false;
     75      $video['id'] = $id[1];
     76      $video['ext'] = 'wat';
     77      if ($_POST['thumbnail'] == 'thumb_from_server')
     78      {
     79        @preg_match('#link rel="image_src" href="(.*?)"#', $source, $matches);
     80        $video['thumb_url'] = @str_replace('120x90', '320x240', $matches[1]);
     81      }
     82      return $video;
     83    }
     84
    7085  default:
    7186    return false;
    72   }
    73 }
    74 
    75 /* MUST BE REMOVED WITH PIWIGO 2.0.0 */
    76 if (!function_exists('fetchRemote'))
    77 {
    78   function fetchRemote($src, &$dest, $user_agent='Piwigo', $step=0)
    79   {
    80     // After 3 redirections, return false
    81     if ($step > 3) return false;
    82 
    83     // Initialize $dest
    84     is_resource($dest) or $dest = '';
    85 
    86     // Try curl to read remote file
    87     if (function_exists('curl_init'))
    88     {
    89       $ch = @curl_init();
    90       @curl_setopt($ch, CURLOPT_URL, $src);
    91       @curl_setopt($ch, CURLOPT_HEADER, 1);
    92       @curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
    93       @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    94       $content = @curl_exec($ch);
    95       $header_length = @curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    96       $status = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
    97       @curl_close($ch);
    98       if ($content !== false and $status >= 200 and $status < 400)
    99       {
    100         if (preg_match('/Location:\s+?(.+)/', substr($content, 0, $header_length), $m))
    101         {
    102           return fetchRemote($m[1], $dest, $user_agent, $step+1);
    103         }
    104         $content = substr($content, $header_length);
    105         is_resource($dest) ? @fwrite($dest, $content) : $dest = $content;
    106         return true;
    107       }
    108     }
    109 
    110     // Try file_get_contents to read remote file
    111     if (ini_get('allow_url_fopen'))
    112     {
    113       $content = @file_get_contents($src);
    114       if ($content !== false)
    115       {
    116         is_resource($dest) ? @fwrite($dest, $content) : $dest = $content;
    117         return true;
    118       }
    119     }
    120 
    121     // Try fsockopen to read remote file
    122     $src = parse_url($src);
    123     $host = $src['host'];
    124     $path = isset($src['path']) ? $src['path'] : '/';
    125     $path .= isset($src['query']) ? '?'.$src['query'] : '';
    126    
    127     if (($s = @fsockopen($host,80,$errno,$errstr,5)) === false)
    128     {
    129       return false;
    130     }
    131 
    132     fwrite($s,
    133       "GET ".$path." HTTP/1.0\r\n"
    134       ."Host: ".$host."\r\n"
    135       ."User-Agent: ".$user_agent."\r\n"
    136       ."Accept: */*\r\n"
    137       ."\r\n"
    138     );
    139 
    140     $i = 0;
    141     $in_content = false;
    142     while (!feof($s))
    143     {
    144       $line = fgets($s);
    145 
    146       if (rtrim($line,"\r\n") == '' && !$in_content)
    147       {
    148         $in_content = true;
    149         $i++;
    150         continue;
    151       }
    152       if ($i == 0)
    153       {
    154         if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/',rtrim($line,"\r\n"), $m))
    155         {
    156           fclose($s);
    157           return false;
    158         }
    159         $status = (integer) $m[2];
    160         if ($status < 200 || $status >= 400)
    161         {
    162           fclose($s);
    163           return false;
    164         }
    165       }
    166       if (!$in_content)
    167       {
    168         if (preg_match('/Location:\s+?(.+)$/',rtrim($line,"\r\n"),$m))
    169         {
    170           fclose($s);
    171           return fetchRemote(trim($m[1]),$dest,$user_agent,$step+1);
    172         }
    173         $i++;
    174         continue;
    175       }
    176       is_resource($dest) ? @fwrite($dest, $line) : $dest .= $line;
    177       $i++;
    178     }
    179     fclose($s);
    180     return true;
    18187  }
    18288}
  • extensions/gvideo/admin/config.php

    r3609 r3697  
    3030      $_POST['pywaie_vimeo_h'],
    3131      $_POST['pywaie_vimeo_w'],
    32       $_POST['pywaie_vimeo_autoplay'])
     32      $_POST['pywaie_vimeo_autoplay']),
     33    'wat' => array(
     34      $_POST['pywaie_wat_h'],
     35      $_POST['pywaie_wat_w'],
     36      $_POST['pywaie_wat_autoplay'])
    3337    );
    3438 
     
    5458  'PYWAIE_WIDEO_W' => $params['wideo'][1],
    5559  'PYWAIE_VIMEO_H' => $params['vimeo'][0],
    56   'PYWAIE_VIMEO_W' => $params['vimeo'][1]));
     60  'PYWAIE_VIMEO_W' => $params['vimeo'][1],
     61  'PYWAIE_WAT_H' => $params['wat'][0],
     62  'PYWAIE_WAT_W' => $params['wat'][1]));
    5763
    5864if ($params['gvideo'][2] == 'true')
     
    96102  $template->assign(array('PYWAIE_VIMEO_AUTOPLAY_FALSE' => 'checked="checked"'));
    97103}
     104if ($params['wat'][2] == 'true')
     105{
     106  $template->assign(array('PYWAIE_WAT_AUTOPLAY_TRUE' => 'checked="checked"'));
     107}
     108else
     109{
     110  $template->assign(array('PYWAIE_WAT_AUTOPLAY_FALSE' => 'checked="checked"'));
     111}
    98112
    99113$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/config.tpl'));
  • extensions/gvideo/admin/config.tpl

    r3609 r3697  
    134134                        </table>
    135135                        </fieldset> </td>   
    136         </table>
     136       
     137                        <td><fieldset>
     138                        <legend>Wat</legend>
     139                        <table>
     140                                <tr>
     141                                        <td>{'py_width'|@translate}</td>
     142                                        <td>&nbsp;
     143                                        <input type="text" size="3" maxlength="3" value="{$PYWAIE_WAT_W}" name="pywaie_wat_w" /></td>
     144                                </tr>
     145                                <tr>
     146                                        <td>{'py_height'|@translate}</td>
     147                                        <td>&nbsp;
     148                                        <input type="text" size="3" maxlength="3" value="{$PYWAIE_WAT_H}" name="pywaie_wat_h" /></td>
     149                                </tr>
     150                                <tr>
     151                                        <td>{'py_autostart'|@translate}</td>
     152                                        <td>&nbsp;
     153                                        <input type="radio" value="true" name="pywaie_wat_autoplay" {$PYWAIE_WAT_AUTOPLAY_TRUE} />
     154                                        On
     155                                        <input type="radio" value="false" name="pywaie_wat_autoplay" {$PYWAIE_WAT_AUTOPLAY_FALSE} />
     156                                        Off </td>
     157                                </tr>
     158                        </table>
     159                        </fieldset> </td> 
     160 
     161  </table>
    137162        <div align="center">
    138163                <input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></div>
  • extensions/gvideo/language/en_UK/plugin.lang.php

    r3609 r3697  
    2323
    2424// Infobulles
    25 $lang['pybulle_reference'] = "Paste here a linkpage of the video.<br>You can use GoogleVideo, YouTube, DailyMotion, Wideo or Vimeo. Examples:<br><br>- http://video.google.fr/videoplay?docid=4600755234172037942<br>- http://www.youtube.com/watch?v=eUvApC0bwUk<br>- http://www.dailymotion.com/video/x29fys_doorway<br>- http://www.wideo.fr/video/iLyROoaftYvl.html<br>- http://www.vimeo.com/1747316";
     25$lang['pybulle_reference'] = "Paste here a linkpage of the video.<br>You can use GoogleVideo, YouTube, DailyMotion, Wideo, Vimeo or Wat. Examples:<br><br>- http://video.google.fr/videoplay?docid=4600755234172037942<br>- http://www.youtube.com/watch?v=eUvApC0bwUk<br>- http://www.dailymotion.com/video/x29fys_doorway<br>- http://www.wideo.fr/video/iLyROoaftYvl.html<br>- http://www.vimeo.com/1747316<br>- http://www.wat.tv/video/abcd.html";
    2626$lang['pybulle_start'] = "Choose the starting point (in seconds) of the video.<br>This option can be use only with GoogleVideo.";
    2727$lang['pybulle_categorie'] = "Category where the file will be created: only real categories are listed. If you wanft to link this file to a virtual category, you have to link after.";
  • extensions/gvideo/language/fr_FR/plugin.lang.php

    r3609 r3697  
    2323
    2424// Infobulles
    25 $lang['pybulle_reference'] = "Collez ici le lien de la page où se trouve la vidéo.<br>Vous pouvez utiliser des vidéos de Google, YouTube, DailyMotion, Wideo et Vimeo. Exemples:<br><br>- http://video.google.fr/videoplay?docid=4600755234172037942<br>- http://www.youtube.com/watch?v=eUvApC0bwUk<br>- http://www.dailymotion.com/video/x29fys_doorway<br>- http://www.wideo.fr/video/iLyROoaftYvl.html<br>- http://www.vimeo.com/1747316";
     25$lang['pybulle_reference'] = "Collez ici le lien de la page où se trouve la vidéo.<br>Vous pouvez utiliser des vidéos de Google, YouTube, DailyMotion, Wideo, Vimeo et Wat. Exemples:<br><br>- http://video.google.fr/videoplay?docid=4600755234172037942<br>- http://www.youtube.com/watch?v=eUvApC0bwUk<br>- http://www.dailymotion.com/video/x29fys_doorway<br>- http://www.wideo.fr/video/iLyROoaftYvl.html<br>- http://www.vimeo.com/1747316<br>- http://www.wat.tv/video/abcd.html";
    2626$lang['pybulle_start'] = "Définie le point de départ (en secondes) de la vidéo.<br>Cette option n'est active qu'avec Google Vidéo.";
    2727$lang['pybulle_categorie'] = "Catégorie où sera écrit le fichier: seules les catégories réelles sont listées ici. Si vous souhaitez avoir le fichier dans une catégorie virtuelle, il faudra l'associer après.";
  • extensions/gvideo/main.inc.php

    r3609 r3697  
    22/*
    33Plugin Name: PY GVideo
    4 Version: 2.0.g
    5 Description: Adds some videos from Google Video, Dailymotion, Youtube, Wideo or Vimeo.
     4Version: auto
     5Description: Adds some videos from Google Video, Dailymotion, Youtube, Wideo, Vimeo or Wat.
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=136
    77Author: PYwaie & P@t
     
    1313
    1414global $conf, $py_addext;
    15 $py_addext = array("gvideo", "dm", "ytube", "wideo", "vimeo");
     15$py_addext = array("gvideo", "dm", "ytube", "wideo", "vimeo", "wat");
    1616$conf['file_ext'] = array_merge($conf['file_ext'], $py_addext);
    1717
  • extensions/gvideo/maintain.inc.php

    r3609 r3697  
    88    'dm' =>  array('480','640','1'),
    99    'wideo' => array('480', '640', 'true'),
    10     'vimeo' => array('480', '640', '1')
     10    'vimeo' => array('480', '640', '1'),
     11    'wat' => array('480', '640', 'true'),
    1112    );
    1213
     
    2930  // Vérification des nouveaux paramètres
    3031  if (!isset($conf['PY_GVideo'])
    31     or ($params = unserialize($conf['PY_GVideo']) and !isset($params['vimeo'])))
     32    or ($params = unserialize($conf['PY_GVideo']) and !isset($params['wat'])))
    3233  {
    3334    plugin_install();
Note: See TracChangeset for help on using the changeset viewer.