Ignore:
Timestamp:
Nov 17, 2012, 5:05:32 PM (12 years ago)
Author:
mistic100
Message:

allow to add private dailymotion videos, remove videobb support, add tags support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/gvideo/include/functions.inc.php

    r17661 r19056  
    2121      if (empty($url['query']['v'])) return false;
    2222     
    23       $video['id'] = $url['query']['v'];
     23      $video['video_id'] = $url['query']['v'];
    2424    }
    2525   
     
    3131       
    3232        $url['path'] = explode('/', $url['path']);
    33         $video['id'] = $url['path'][1];
    34       }
    35      
    36       $api_url = 'http://gdata.youtube.com/feeds/api/videos/'.$video['id'].'?v=2&alt=json';
     33        $video['video_id'] = $url['path'][1];
     34      }
     35     
     36      $api_url = 'http://gdata.youtube.com/feeds/api/videos/'.$video['video_id'].'?v=2&alt=json';
    3737      $json = download_remote_file($api_url, true);
    3838      if ($json === false or $json == 'file_error') return false;
     
    4040      $json = json_decode($json, true);
    4141      $video = array_merge($video, array(
    42         'url' => 'http://youtube.com/watch?v='.$video['id'],
     42        'url' => 'http://youtube.com/watch?v='.$video['video_id'],
    4343        'title' => $json['entry']['title']['$t'],
    4444        'description' => $json['entry']['media$group']['media$description']['$t'],
    4545        'thumbnail' => $json['entry']['media$group']['media$thumbnail'][2]['url'],
    4646        'author' => $json['entry']['author'][0]['name']['$t'],
     47        'tags' => null,
    4748        ));
    4849      break;
     
    5556     
    5657      $url['path'] = explode('/', $url['path']);
    57       $video['id'] = $url['path'][1];
    58      
    59       $api_url = 'http://vimeo.com/api/v2/video/'.$video['id'].'.json';
     58      $video['video_id'] = $url['path'][1];
     59     
     60      $api_url = 'http://vimeo.com/api/v2/video/'.$video['video_id'].'.json';
    6061      $json = download_remote_file($api_url, true);
    6162      if ($json === false or $json == 'file_error') return false;
     
    6364      $json = json_decode($json, true);
    6465      $video = array_merge($video, array(
    65         'url' => 'http://vimeo.com/'.$video['id'],
     66        'url' => 'http://vimeo.com/'.$video['video_id'],
    6667        'title' => $json[0]['title'],
    6768        'description' => $json[0]['description'],
    6869        'thumbnail' => $json[0]['thumbnail_large'],
    6970        'author' => $json[0]['user_name'],
     71        'tags' => array_map('trim', explode(',', $json[0]['tags'])),
    7072        ));
    7173      break;
     
    7981      $url['path'] = explode('/', $url['path']);
    8082      if ($url['path'][1] != 'video') return false;
    81       $video['id'] = $url['path'][2];
    82      
    83       $api_url = 'https://api.dailymotion.com/video/'.$video['id'].'?fields=description,id,thumbnail_large_url,title,owner.username'; // DM doesn't accept non secure connection
     83      $video['video_id'] = $url['path'][2];
     84     
     85      $api_url = 'https://api.dailymotion.com/video/'.$video['video_id'].'?fields=description,thumbnail_large_url,title,owner.username,tags'; // DM doesn't accept non secure connection
    8486      $json = download_remote_file($api_url, true);
    8587      if ($json === false or $json == 'file_error') return false;
     
    8991     
    9092      $video = array_merge($video, array(
    91         'id' => $json['id'],
    92         'url' => 'http://dailymotion.com/video/'.$json['id'],
     93        'url' => 'http://dailymotion.com/video/'.$video['video_id'],
    9394        'title' => $json['title'],
    9495        'description' => $json['description'],
    9596        'thumbnail' => $json['thumbnail_large_url'],
    9697        'author' => $json['owner.username'],
     98        'tags' => $json['tags'],
    9799        ));
    98100      break;
     
    109111      preg_match('#<meta property="og:video" content="http://www.wat.tv/swf2/([^"/>]+)" />#', $html, $matches);
    110112      if (empty($matches[1])) return false;
    111       $video['id'] = $matches[1];
     113      $video['video_id'] = $matches[1];
    112114     
    113115      $video['url'] = $source_url;
     
    116118      $video['title'] = $matches[1];
    117119     
    118       preg_match('#<p class="description"([^>]*)>(.*?)</p>#s', $html, $matches);
    119       $video['description'] = $matches[2];
     120      preg_match('#<p class="description"(?:[^>]*)>(.*?)</p>#s', $html, $matches);
     121      $video['description'] = $matches[1];
    120122     
    121123      preg_match('#<meta property="og:image" content="([^">]+)" />#', $html, $matches);
     
    123125     
    124126      $video['author'] = null;
     127     
     128      preg_match_all('#<meta property="video:tag" content="([^">]+)" />#', $html, $matches);
     129      $video['tags'] = $matches[1];
    125130      break;
    126131    }
     
    132137     
    133138      $url['path'] = explode('/', $url['path']);
    134       $video['id'] = rtrim($url['path'][2], '.html');
     139      $video['video_id'] = rtrim($url['path'][2], '.html');
    135140     
    136141      $html = download_remote_file($source_url, true);
    137142      if ($html === false or $html == 'file_error') return false;
    138143     
    139       $video['url'] = 'http://wideo.fr/video/'.$video['id'].'.html';
     144      $video['url'] = 'http://wideo.fr/video/'.$video['video_id'].'.html';
    140145     
    141146      preg_match('#<meta property="og:title" content="([^">]*)" />#', $html, $matches);
     
    148153      $video['thumbnail'] = $matches[1];
    149154     
    150       preg_match('#<li id="li_author">Auteur :  <a href="\#"([^>]*)><span>(.*?)</span></a>#', $html, $matches);
    151       $video['author'] = $matches[2];
    152       break;
    153     }
    154      
    155     /* videobb */
    156     case 'videobb':
    157     {
    158       $video['type'] = 'videobb';
    159      
    160       if (!empty($url['query']))
    161       {
    162         parse_str($url['query'], $url['query']);
    163         if (empty($url['query']['v'])) return false;
    164         $video['id'] = $url['query']['v'];
    165       }
    166       else
    167       {
    168         $url['path'] = explode('/', $url['path']);
    169         if ($url['path'][1] != 'video') return false;
    170         $video['id'] = $url['path'][2];
    171       }
    172      
    173       $html = download_remote_file($source_url, true);
    174       if ($html === false or $html == 'file_error') return false;
    175      
    176       $video['url'] = 'http://www.videobb.com/video/'.$video['id'];
    177      
    178       preg_match('#<meta content="videobb - ([^">]*)"  name="title" property="" />#', $html, $matches);
    179       $video['title'] = $matches[1];
    180      
    181       $video['description'] = null;
    182      
    183       preg_match('#<link rel="image_src" href="([^">]+)" type="image/jpeg" />#', $html, $matches);
    184       $video['thumbnail'] = $matches[1];
    185      
    186       $video['author'] = null;
     155      preg_match('#<li id="li_author">Auteur :  <a href=(?:[^>]*)><span>(.*?)</span></a>#', $html, $matches);
     156      $video['author'] = $matches[1];
     157     
     158      preg_match('#<meta name="keywords" content="([^">]+)" />#', $html, $matches);
     159      $video['tags'] = array_map('trim', explode(',', $matches[1]));
    187160      break;
    188161    }
Note: See TracChangeset for help on using the changeset viewer.