Ignore:
Timestamp:
Feb 18, 2013, 2:45:55 PM (11 years ago)
Author:
mistic100
Message:

better handle of private videos, show info about privacy

File:
1 edited

Legend:

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

    r20804 r20809  
    4343     
    4444      $video['url'] = 'http://youtube.com/watch?v='.$video['video_id'];
     45      $video['title'] = 'YouTube #'.$video['video_id'];
    4546     
    4647      if (!$safe_mode)
    4748      {
    48         $fields = 'entry(id,author,media:group(media:title(text()),media:description(text()),media:thumbnail(@url),media:keywords))';
    49         $api_url = 'http://gdata.youtube.com/feeds/api/videos/'.$video['video_id'].'?v=2&alt=json&fields='.$fields;
     49        $api_url = 'http://gdata.youtube.com/feeds/api/videos/'.$video['video_id'].'?v=2&alt=json';
    5050        $json = gvideo_download_remote_file($api_url, true);
    5151       
    5252        if ($json===false || $json=='file_error') return false;
     53        if (strip_tags($json) == 'GDataInvalidRequestUriExceptionInvalid id') return false; // unknown video
     54        if (strip_tags($json) == 'GDataServiceForbiddenExceptionPrivate video') return false; // private video
    5355       
    5456        $json = json_decode($json, true);
     
    5658          'title' => $json['entry']['media$group']['media$title']['$t'],
    5759          'description' => $json['entry']['media$group']['media$description']['$t'],
    58           'thumbnail' => $json['entry']['media$group']['media$thumbnail'][0]['url'],
     60          'thumbnail' => $json['entry']['media$group']['media$thumbnail'][2]['url'],
    5961          'author' => $json['entry']['author'][0]['name']['$t'],
    6062          ));
     
    6466        }
    6567      }
    66       else
    67       {
    68         $video['title'] = 'YouTube #'.$video['video_id'];
    69       }
    7068     
    7169      break;
     
    8179     
    8280      $video['url'] = 'http://vimeo.com/'.$video['video_id'];
     81      $video['title'] = 'Vimeo #'.$video['video_id'];
    8382     
    8483      if (!$safe_mode)
     
    116115        }
    117116      }
    118       else
    119       {
    120         $video['title'] = 'Vimeo #'.$video['video_id'];
    121       }
    122117     
    123118      break;
     
    134129     
    135130      $video['url'] = 'http://dailymotion.com/video/'.$video['video_id'];
     131      $video['title'] = $video['video_id'];
    136132     
    137133      if (!$safe_mode)
     
    143139       
    144140        $json = json_decode($json, true);
     141        if (@$json['error']['type'] == 'access_forbidden') return false; // private video
    145142        $json['thumbnail_large_url'] = preg_replace('#\?([0-9]+)$#', null, $json['thumbnail_large_url']);
    146143       
     
    153150          ));
    154151      }
    155       else
    156       {
    157         $video['title'] = $video['video_id'];
    158       }
    159152     
    160153      break;
     
    164157    case 'wat':
    165158    {
     159      if (!$safe_mode) return false; // no safe_mode for wat.tv, must connect to get the video id
     160     
    166161      $video['type'] = 'wat';
    167162     
    168       // no safe_mode for wat.tv
    169163      $html = gvideo_download_remote_file($source_url, true);
    170164     
     
    202196     
    203197      $video['url'] = 'http://wideo.fr/video/'.$video['video_id'].'.html';
     198      $video['title'] = $video['video_id'];
    204199     
    205200      if (!$safe_mode)
     
    223218        preg_match('#<meta name="keywords" content="([^">]+)" />#', $html, $matches);
    224219        $video['tags'] = $matches[1];
    225       }
    226       else
    227       {
    228         $video['title'] = $video['video_id'];
    229220      }
    230221     
Note: See TracChangeset for help on using the changeset viewer.