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?

有帮助吗?

解决方案

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.

其他提示

Now youku has english version website, you can easily apply an api key through:http://open.youku.com/app

function youkuapi($vid){
$url="https://openapi.youku.com/v2/videos/show_basic.json?video_id=".$vid."&client_id=your_api_key";
$data=file_get_contents($url);
$json=json_decode($data,true);
return $json;
}

Try this

http://events.youku.com/global/api/video-thumb.php?vid=YOUKU_VIDEO_ID

Swap out YOUKU_VIDEO_ID with your video ID.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top