Search code examples
phpvideovideo-thumbnailsyouku

Get youku video thumbnail in PHP


I've been trying to find information for obtaining a video thumbnail from a youku video. Most search results are unsurprisingly in Chinese. The best solution I've found so far basically scrapes the entire page:

preg_match_all( '~youku.com/embed/(.*?)\"~si',$embed_string,$M);
if (!empty($M[1]))  $video_id = ($M[1][0]);
$request = "http://v.youku.com/player/getPlayList/VideoIDS/$video_id/";
$response = file_get_contents($request);
$result = json_decode($response);
$youku_img_path = $result->data[0]->logo;

The problem is that if I want to include more than one thumbnail on the page, it very quickly starts to slow down performance. Also, Youku sometimes seems to not allow the request, making this solution unreliable at best. Does anyone know any better solutions?


Solution

  • I don't know chinese, but they've an open API to get video info: http://open.youku.com/docs/api/videos/show for a single video and http://open.youku.com/docs/api/videos/show_batch for more than one video.

    You'll have to register with them here to get an API key to use in each request.