Révision 3acd948f
Ajouté par Assos Assos il y a plus de 6 ans
drupal7/sites/all/modules/media_youtube/includes/MediaYouTubeStreamWrapper.inc | ||
---|---|---|
10 | 10 |
* $youtube = new MediaYouTubeStreamWrapper('youtube://v/[video-code]'); |
11 | 11 |
*/ |
12 | 12 |
class MediaYouTubeStreamWrapper extends MediaReadOnlyStreamWrapper { |
13 |
protected $base_url = 'http://www.youtube.com/watch'; |
|
13 |
protected $base_url = 'https://www.youtube.com/watch';
|
|
14 | 14 |
|
15 | 15 |
static function getMimeType($uri, $mapping = NULL) { |
16 | 16 |
return 'video/youtube'; |
... | ... | |
18 | 18 |
|
19 | 19 |
function getOriginalThumbnailPath() { |
20 | 20 |
$parts = $this->get_parameters(); |
21 |
$thumbnail_url = 'http://img.youtube.com/vi/' . check_plain($parts['v']) . "/maxresdefault.jpg"; |
|
21 |
$thumbnail_url = 'https://img.youtube.com/vi/' . check_plain($parts['v']) . "/maxresdefault.jpg";
|
|
22 | 22 |
$response = drupal_http_request($thumbnail_url); |
23 |
if ($response->code == 404) { |
|
24 |
$thumbnail_url = 'https://img.youtube.com/vi/' . check_plain($parts['v']) . "/hqdefault.jpg"; |
|
25 |
$response = drupal_http_request($thumbnail_url); |
|
26 |
} |
|
23 | 27 |
if (!isset($response->error)) { |
24 | 28 |
return $thumbnail_url; |
25 | 29 |
} |
... | ... | |
27 | 31 |
throw new MediaInternetValidationException("Embedding has been disabled for this video."); |
28 | 32 |
} |
29 | 33 |
elseif ($response->code == 404) { |
30 |
return "http://s.ytimg.com/yts/img/image-hh-404-vflvCykRp.png"; |
|
34 |
return "https://s.ytimg.com/yts/img/image-hh-404-vflvCykRp.png";
|
|
31 | 35 |
} |
32 | 36 |
elseif ($response->code != 200) { |
33 | 37 |
throw new MediaInternetValidationException("The YouTube video ID is invalid or the video was deleted."); |
... | ... | |
35 | 39 |
else { |
36 | 40 |
$uri = file_stream_wrapper_uri_normalize('youtube://v/' . check_plain($parts['v'])); |
37 | 41 |
$external_url = file_create_url($uri); |
38 |
$oembed_url = url('http://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json'))); |
|
42 |
$oembed_url = url('https://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json')));
|
|
39 | 43 |
$response = drupal_http_request($oembed_url); |
40 | 44 |
|
41 | 45 |
if (!isset($response->error)) { |
... | ... | |
65 | 69 |
file_unmanaged_save_data($response->data, $local_path, TRUE); |
66 | 70 |
} |
67 | 71 |
else { |
68 |
@copy($this->getOriginalThumbnailPath(), $local_path);
|
|
72 |
system_retrieve_file($this->getOriginalThumbnailPath(), $local_path, FALSE, FILE_EXISTS_REPLACE);
|
|
69 | 73 |
} |
70 | 74 |
} |
71 | 75 |
catch (Exception $e) { |
... | ... | |
86 | 90 |
function setBaseUrl($parameters) { |
87 | 91 |
if (isset($parameters['l'])) { |
88 | 92 |
if (!isset($parameters['v'])) { |
89 |
$this->base_url = 'http://youtube.com/playlist'; |
|
93 |
$this->base_url = 'https://youtube.com/playlist';
|
|
90 | 94 |
} |
91 | 95 |
$parameters['list'] = $parameters['l']; |
92 | 96 |
unset($parameters['l']); |
Formats disponibles : Unified diff
Weekly update of contrib modules