1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Extends the MediaYouTubeStreamWrapper class to make it suitable for local testing.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Create an instance like this:
|
10
|
* $youtube = new MediaYouTubeTestStreamWrapper('youtube://v/[video-code]');
|
11
|
*/
|
12
|
class MediaYouTubeTestStreamWrapper extends MediaYouTubeStreamWrapper {
|
13
|
function getOriginalThumbnailPath() {
|
14
|
$parts = $this->get_parameters();
|
15
|
$uri = file_stream_wrapper_uri_normalize('youtube://v/' . check_plain($parts['v']));
|
16
|
$external_url = file_create_url($uri);
|
17
|
$oembed_url = url('media-youtube-test/oembed', array('query' => array('url' => $external_url, 'format' => 'json'), 'absolute' => TRUE));
|
18
|
$response = drupal_http_request($oembed_url);
|
19
|
|
20
|
if (!isset($response->error)) {
|
21
|
$data = drupal_json_decode($response->data);
|
22
|
return $data['thumbnail_url'];
|
23
|
}
|
24
|
else {
|
25
|
throw new Exception(t('Error Processing Request. (Error: %code, %error)', array('%code' => $response->code, '%error' => $response->error)));
|
26
|
}
|
27
|
}
|
28
|
}
|