Version Description
- Various updates to providers
- Removed "sslverify" => false in wp_remote_get() (may cause errors on WordPress versions before 3.7)
- Better error messages for Google Drive
Download this release
Release Info
Developer | sutherlandboswell |
Plugin | Video Thumbnails |
Version | 2.10.3 |
Comparing to | |
See all releases |
Code changes from version 2.10.2 to 2.10.3
- php/class-video-thumbnails-settings.php +1 -3
- php/providers/class-blip-thumbnails.php +1 -1
- php/providers/class-collegehumor-thumbnails.php +1 -1
- php/providers/class-dailymotion-thumbnails.php +1 -1
- php/providers/class-facebook-thumbnails.php +13 -6
- php/providers/class-funnyordie-thumbnails.php +1 -1
- php/providers/class-googledrive-thumbnails.php +7 -3
- php/providers/class-kaltura-thumbnails.php +2 -2
- php/providers/class-metacafe-thumbnails.php +3 -2
- php/providers/class-rutube-thumbnails.php +1 -1
- php/providers/class-sapo-thumbnails.php +6 -4
- php/providers/class-ted-thumbnails.php +2 -2
- php/providers/class-tudou-thumbnails.php +1 -1
- php/providers/class-twitch-thumbnails.php +8 -7
- php/providers/class-video-thumbnails-provider.php +10 -0
- php/providers/class-vimeo-thumbnails.php +3 -3
- php/providers/class-vine-thumbnails.php +1 -1
- php/providers/class-vk-thumbnails.php +1 -1
- php/providers/class-wistia-thumbnails.php +2 -2
- php/providers/class-youku-thumbnails.php +1 -1
- readme.txt +7 -2
- video-thumbnails.php +3 -3
php/class-video-thumbnails-settings.php
CHANGED
@@ -206,7 +206,7 @@ class Video_Thumbnails_Settings {
|
|
206 |
}
|
207 |
|
208 |
function get_file_hash( $url ) {
|
209 |
-
$response = wp_remote_get( $url
|
210 |
if( is_wp_error( $response ) ) {
|
211 |
$result = false;
|
212 |
} else {
|
@@ -246,8 +246,6 @@ class Video_Thumbnails_Settings {
|
|
246 |
echo '</td>';
|
247 |
$failed++;
|
248 |
} else {
|
249 |
-
$result = explode( '?', $result );
|
250 |
-
$result = $result[0];
|
251 |
$result_hash = false;
|
252 |
if ( $result == $test_case['expected'] ) {
|
253 |
$matched = true;
|
206 |
}
|
207 |
|
208 |
function get_file_hash( $url ) {
|
209 |
+
$response = wp_remote_get( $url );
|
210 |
if( is_wp_error( $response ) ) {
|
211 |
$result = false;
|
212 |
} else {
|
246 |
echo '</td>';
|
247 |
$failed++;
|
248 |
} else {
|
|
|
|
|
249 |
$result_hash = false;
|
250 |
if ( $result == $test_case['expected'] ) {
|
251 |
$matched = true;
|
php/providers/class-blip-thumbnails.php
CHANGED
@@ -41,7 +41,7 @@ class Blip_Thumbnails extends Video_Thumbnails_Provider {
|
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $url ) {
|
43 |
$request = "http://blip.tv/oembed?url=$url";
|
44 |
-
$response = wp_remote_get( $request
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $url ) {
|
43 |
$request = "http://blip.tv/oembed?url=$url";
|
44 |
+
$response = wp_remote_get( $request );
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
php/providers/class-collegehumor-thumbnails.php
CHANGED
@@ -41,7 +41,7 @@ class CollegeHumor_Thumbnails extends Video_Thumbnails_Provider {
|
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "http://www.collegehumor.com/oembed.json?url=http%3A%2F%2Fwww.collegehumor.com%2Fvideo%2F$id";
|
44 |
-
$response = wp_remote_get( $request
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "http://www.collegehumor.com/oembed.json?url=http%3A%2F%2Fwww.collegehumor.com%2Fvideo%2F$id";
|
44 |
+
$response = wp_remote_get( $request );
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
php/providers/class-dailymotion-thumbnails.php
CHANGED
@@ -43,7 +43,7 @@ class Dailymotion_Thumbnails extends Video_Thumbnails_Provider {
|
|
43 |
// Thumbnail URL
|
44 |
public function get_thumbnail_url( $id ) {
|
45 |
$request = "https://api.dailymotion.com/video/$id?fields=thumbnail_url";
|
46 |
-
$response = wp_remote_get( $request
|
47 |
if( is_wp_error( $response ) ) {
|
48 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
49 |
} else {
|
43 |
// Thumbnail URL
|
44 |
public function get_thumbnail_url( $id ) {
|
45 |
$request = "https://api.dailymotion.com/video/$id?fields=thumbnail_url";
|
46 |
+
$response = wp_remote_get( $request );
|
47 |
if( is_wp_error( $response ) ) {
|
48 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
49 |
} else {
|
php/providers/class-facebook-thumbnails.php
CHANGED
@@ -36,13 +36,14 @@ class Facebook_Thumbnails extends Video_Thumbnails_Provider {
|
|
36 |
// Regex strings
|
37 |
public $regexes = array(
|
38 |
'#http://www\.facebook\.com/v/([0-9]+)#', // Flash Embed
|
39 |
-
'#https?://www\.facebook\.com/video/embed\?video_id=([0-9]+)#' // iFrame Embed
|
|
|
40 |
);
|
41 |
|
42 |
// Thumbnail URL
|
43 |
public function get_thumbnail_url( $id ) {
|
44 |
$request = 'https://graph.facebook.com/' . $id . '/picture?redirect=false';
|
45 |
-
$response = wp_remote_get( $request
|
46 |
if( is_wp_error( $response ) ) {
|
47 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
48 |
} else {
|
@@ -64,16 +65,22 @@ class Facebook_Thumbnails extends Video_Thumbnails_Provider {
|
|
64 |
return array(
|
65 |
array(
|
66 |
'markup' => '<object width=420 height=180><param name=allowfullscreen value=true></param><param name=allowscriptaccess value=always></param><param name=movie value="http://www.facebook.com/v/2560032632599"></param><embed src="http://www.facebook.com/v/2560032632599" type="application/x-shockwave-flash" allowscriptaccess=always allowfullscreen=true width=420 height=180></embed></object>',
|
67 |
-
'expected' => 'https://
|
68 |
-
'expected_hash' => '
|
69 |
'name' => __( 'Flash Embed', 'video-thumbnails' )
|
70 |
),
|
71 |
array(
|
72 |
'markup' => '<iframe src="https://www.facebook.com/video/embed?video_id=2560032632599" width="960" height="720" frameborder="0"></iframe>',
|
73 |
-
'expected' => 'https://
|
74 |
-
'expected_hash' => '
|
75 |
'name' => __( 'iFrame Embed', 'video-thumbnails' )
|
76 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
);
|
78 |
}
|
79 |
|
36 |
// Regex strings
|
37 |
public $regexes = array(
|
38 |
'#http://www\.facebook\.com/v/([0-9]+)#', // Flash Embed
|
39 |
+
'#https?://www\.facebook\.com/video/embed\?video_id=([0-9]+)#', // iFrame Embed
|
40 |
+
'#https?://www\.facebook\.com/video\.php\?v=([0-9]+)#'
|
41 |
);
|
42 |
|
43 |
// Thumbnail URL
|
44 |
public function get_thumbnail_url( $id ) {
|
45 |
$request = 'https://graph.facebook.com/' . $id . '/picture?redirect=false';
|
46 |
+
$response = wp_remote_get( $request );
|
47 |
if( is_wp_error( $response ) ) {
|
48 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
49 |
} else {
|
65 |
return array(
|
66 |
array(
|
67 |
'markup' => '<object width=420 height=180><param name=allowfullscreen value=true></param><param name=allowscriptaccess value=always></param><param name=movie value="http://www.facebook.com/v/2560032632599"></param><embed src="http://www.facebook.com/v/2560032632599" type="application/x-shockwave-flash" allowscriptaccess=always allowfullscreen=true width=420 height=180></embed></object>',
|
68 |
+
'expected' => 'https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-xap1/v/t15.0-10/p160x160/50796_2560034672650_2560032632599_65313_313_b.jpg?oh=e8c767b1efafa6d8a4b672bad7be38d6&oe=55364081&__gda__=1428807476_a4d83140019b11ad602f2ef9960a364e',
|
69 |
+
'expected_hash' => '6b033d8f16dbf273048c5771d32ede64',
|
70 |
'name' => __( 'Flash Embed', 'video-thumbnails' )
|
71 |
),
|
72 |
array(
|
73 |
'markup' => '<iframe src="https://www.facebook.com/video/embed?video_id=2560032632599" width="960" height="720" frameborder="0"></iframe>',
|
74 |
+
'expected' => 'https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-xap1/v/t15.0-10/p160x160/50796_2560034672650_2560032632599_65313_313_b.jpg?oh=e8c767b1efafa6d8a4b672bad7be38d6&oe=55364081&__gda__=1428807476_a4d83140019b11ad602f2ef9960a364e',
|
75 |
+
'expected_hash' => '6b033d8f16dbf273048c5771d32ede64',
|
76 |
'name' => __( 'iFrame Embed', 'video-thumbnails' )
|
77 |
),
|
78 |
+
array(
|
79 |
+
'markup' => '<div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\'));</script><div class="fb-post" data-href="https://www.facebook.com/video.php?v=10150326323406807" data-width="466"><div class="fb-xfbml-parse-ignore"><a href="https://www.facebook.com/video.php?v=10150326323406807">Post</a> by <a href="https://www.facebook.com/PeterJacksonNZ">Peter Jackson</a>.</div></div>',
|
80 |
+
'expected' => 'https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-xfa1/v/t15.0-10/p128x128/244423_10150326375786807_10150326323406807_4366_759_b.jpg?oh=013ce21bb54de51c383071598b269a91&oe=552CD270&__gda__=1428479462_339647870ec32227c391e98000935aec',
|
81 |
+
'expected_hash' => '184d20db21ac8edef9c9cee291be5ee6',
|
82 |
+
'name' => __( 'FBML Embed', 'video-thumbnails' )
|
83 |
+
),
|
84 |
);
|
85 |
}
|
86 |
|
php/providers/class-funnyordie-thumbnails.php
CHANGED
@@ -42,7 +42,7 @@ class Funnyordie_Thumbnails extends Video_Thumbnails_Provider {
|
|
42 |
// Thumbnail URL
|
43 |
public function get_thumbnail_url( $id ) {
|
44 |
$request = "http://www.funnyordie.com/oembed.json?url=http%3A%2F%2Fwww.funnyordie.com%2Fvideos%2F$id";
|
45 |
-
$response = wp_remote_get( $request
|
46 |
if( is_wp_error( $response ) ) {
|
47 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
48 |
} else {
|
42 |
// Thumbnail URL
|
43 |
public function get_thumbnail_url( $id ) {
|
44 |
$request = "http://www.funnyordie.com/oembed.json?url=http%3A%2F%2Fwww.funnyordie.com%2Fvideos%2F$id";
|
45 |
+
$response = wp_remote_get( $request );
|
46 |
if( is_wp_error( $response ) ) {
|
47 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
48 |
} else {
|
php/providers/class-googledrive-thumbnails.php
CHANGED
@@ -58,13 +58,17 @@ class Googledrive_Thumbnails extends Video_Thumbnails_Provider {
|
|
58 |
|
59 |
if ( $api_key ) {
|
60 |
$request = "https://www.googleapis.com/drive/v2/files/$id?fields=thumbnailLink&key=$api_key";
|
61 |
-
$response = wp_remote_get( $request
|
62 |
if( is_wp_error( $response ) ) {
|
63 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
64 |
} else {
|
65 |
$json = json_decode( $response['body'] );
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
68 |
}
|
69 |
} else {
|
70 |
$result = new WP_Error( 'googledrive_api_key', __( 'You must enter an API key in the <a href="' . admin_url( 'options-general.php?page=video_thumbnails&tab=provider_settings' ) . '">provider settings</a> to retrieve thumbnails from Google Drive.', 'video-thumbnails' ) );
|
58 |
|
59 |
if ( $api_key ) {
|
60 |
$request = "https://www.googleapis.com/drive/v2/files/$id?fields=thumbnailLink&key=$api_key";
|
61 |
+
$response = wp_remote_get( $request );
|
62 |
if( is_wp_error( $response ) ) {
|
63 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
64 |
} else {
|
65 |
$json = json_decode( $response['body'] );
|
66 |
+
if ( isset( $json->error ) ) {
|
67 |
+
$result = new WP_Error( 'googledrive_info_retrieval', $json->error->message );
|
68 |
+
} else {
|
69 |
+
$result = $json->thumbnailLink;
|
70 |
+
$result = str_replace( '=s220', '=s480', $result );
|
71 |
+
}
|
72 |
}
|
73 |
} else {
|
74 |
$result = new WP_Error( 'googledrive_api_key', __( 'You must enter an API key in the <a href="' . admin_url( 'options-general.php?page=video_thumbnails&tab=provider_settings' ) . '">provider settings</a> to retrieve thumbnails from Google Drive.', 'video-thumbnails' ) );
|
php/providers/class-kaltura-thumbnails.php
CHANGED
@@ -41,14 +41,14 @@ class Kaltura_Thumbnails extends Video_Thumbnails_Provider {
|
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "http://www.kaltura.com/api_v3/?service=thumbAsset&action=getbyentryid&entryId=$id";
|
44 |
-
$response = wp_remote_get( $request
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
48 |
$xml = new SimpleXMLElement( $response['body'] );
|
49 |
$result = (string) $xml->result->item->id;
|
50 |
$request = "http://www.kaltura.com/api_v3/?service=thumbAsset&action=geturl&id=$result";
|
51 |
-
$response = wp_remote_get( $request
|
52 |
if( is_wp_error( $response ) ) {
|
53 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
54 |
} else {
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "http://www.kaltura.com/api_v3/?service=thumbAsset&action=getbyentryid&entryId=$id";
|
44 |
+
$response = wp_remote_get( $request );
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
48 |
$xml = new SimpleXMLElement( $response['body'] );
|
49 |
$result = (string) $xml->result->item->id;
|
50 |
$request = "http://www.kaltura.com/api_v3/?service=thumbAsset&action=geturl&id=$result";
|
51 |
+
$response = wp_remote_get( $request );
|
52 |
if( is_wp_error( $response ) ) {
|
53 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
54 |
} else {
|
php/providers/class-metacafe-thumbnails.php
CHANGED
@@ -41,13 +41,14 @@ class Metacafe_Thumbnails extends Video_Thumbnails_Provider {
|
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "http://www.metacafe.com/api/item/$id/";
|
44 |
-
$response = wp_remote_get( $request
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
48 |
$xml = new SimpleXMLElement( $response['body'] );
|
49 |
$result = $xml->xpath( "/rss/channel/item/media:thumbnail/@url" );
|
50 |
$result = (string) $result[0]['url'];
|
|
|
51 |
}
|
52 |
return $result;
|
53 |
}
|
@@ -58,7 +59,7 @@ class Metacafe_Thumbnails extends Video_Thumbnails_Provider {
|
|
58 |
array(
|
59 |
'markup' => '<embed flashVars="playerVars=autoPlay=no" src="http://www.metacafe.com/fplayer/8456223/men_in_black_3_trailer_2.swf" width="440" height="248" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_8456223" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>',
|
60 |
'expected' => 'http://s4.mcstatic.com/thumb/8456223/22479418/4/catalog_item5/0/1/men_in_black_3_trailer_2.jpg',
|
61 |
-
'expected_hash' => '
|
62 |
'name' => __( 'Flash Embed', 'video-thumbnails' )
|
63 |
),
|
64 |
);
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "http://www.metacafe.com/api/item/$id/";
|
44 |
+
$response = wp_remote_get( $request );
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
48 |
$xml = new SimpleXMLElement( $response['body'] );
|
49 |
$result = $xml->xpath( "/rss/channel/item/media:thumbnail/@url" );
|
50 |
$result = (string) $result[0]['url'];
|
51 |
+
$result = $this->drop_url_parameters( $result );
|
52 |
}
|
53 |
return $result;
|
54 |
}
|
59 |
array(
|
60 |
'markup' => '<embed flashVars="playerVars=autoPlay=no" src="http://www.metacafe.com/fplayer/8456223/men_in_black_3_trailer_2.swf" width="440" height="248" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_8456223" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>',
|
61 |
'expected' => 'http://s4.mcstatic.com/thumb/8456223/22479418/4/catalog_item5/0/1/men_in_black_3_trailer_2.jpg',
|
62 |
+
'expected_hash' => '977187bfb00df55b39724d7de284f617',
|
63 |
'name' => __( 'Flash Embed', 'video-thumbnails' )
|
64 |
),
|
65 |
);
|
php/providers/class-rutube-thumbnails.php
CHANGED
@@ -45,7 +45,7 @@ class Rutube_Thumbnails extends Video_Thumbnails_Provider {
|
|
45 |
} else {
|
46 |
$request = "http://rutube.ru/api/video/$id/?format=json";
|
47 |
}
|
48 |
-
$response = wp_remote_get( $request
|
49 |
if( is_wp_error( $response ) ) {
|
50 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
51 |
} else {
|
45 |
} else {
|
46 |
$request = "http://rutube.ru/api/video/$id/?format=json";
|
47 |
}
|
48 |
+
$response = wp_remote_get( $request );
|
49 |
if( is_wp_error( $response ) ) {
|
50 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
51 |
} else {
|
php/providers/class-sapo-thumbnails.php
CHANGED
@@ -41,7 +41,7 @@ class Sapo_Thumbnails extends Video_Thumbnails_Provider {
|
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "http://videos.sapo.pt/$id";
|
44 |
-
$response = wp_remote_get( $request
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
@@ -51,7 +51,9 @@ class Sapo_Thumbnails extends Video_Thumbnails_Provider {
|
|
51 |
for ( $i = 0; $i < $metas->length; $i++ ) {
|
52 |
$meta = $metas->item( $i );
|
53 |
if ( $meta->getAttribute( 'property' ) == 'og:image' ) {
|
54 |
-
$
|
|
|
|
|
55 |
break;
|
56 |
}
|
57 |
}
|
@@ -64,8 +66,8 @@ class Sapo_Thumbnails extends Video_Thumbnails_Provider {
|
|
64 |
return array(
|
65 |
array(
|
66 |
'markup' => '<iframe src="http://rd3.videos.sapo.pt/playhtml?file=http://rd3.videos.sapo.pt/ddACsFSuDEZZRWfNHTTy/mov/1" frameborder="0" scrolling="no" width="640" height="360" webkitallowfullscreen mozallowfullscreen allowfullscreen ></iframe>',
|
67 |
-
'expected' => 'http://
|
68 |
-
'expected_hash' => '
|
69 |
'name' => __( 'iFrame Embed', 'video-thumbnails' )
|
70 |
),
|
71 |
);
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "http://videos.sapo.pt/$id";
|
44 |
+
$response = wp_remote_get( $request );
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
51 |
for ( $i = 0; $i < $metas->length; $i++ ) {
|
52 |
$meta = $metas->item( $i );
|
53 |
if ( $meta->getAttribute( 'property' ) == 'og:image' ) {
|
54 |
+
$og_image = $meta->getAttribute( 'content' );
|
55 |
+
parse_str( parse_url( $og_image, PHP_URL_QUERY ), $image_array );
|
56 |
+
$result = $image_array['pic'];
|
57 |
break;
|
58 |
}
|
59 |
}
|
66 |
return array(
|
67 |
array(
|
68 |
'markup' => '<iframe src="http://rd3.videos.sapo.pt/playhtml?file=http://rd3.videos.sapo.pt/ddACsFSuDEZZRWfNHTTy/mov/1" frameborder="0" scrolling="no" width="640" height="360" webkitallowfullscreen mozallowfullscreen allowfullscreen ></iframe>',
|
69 |
+
'expected' => 'http://cache02.stormap.sapo.pt/vidstore14/thumbnais/e9/08/37/7038489_l5VMt.jpg',
|
70 |
+
'expected_hash' => 'd8a74c3d4e054263a37abe9ceed782fd',
|
71 |
'name' => __( 'iFrame Embed', 'video-thumbnails' )
|
72 |
),
|
73 |
);
|
php/providers/class-ted-thumbnails.php
CHANGED
@@ -41,12 +41,12 @@ class Ted_Thumbnails extends Video_Thumbnails_Provider {
|
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "http://www.ted.com/talks/oembed.json?url=http%3A%2F%2Fwww.ted.com%2Ftalks%2F$id";
|
44 |
-
$response = wp_remote_get( $request
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
48 |
$result = json_decode( $response['body'] );
|
49 |
-
$result = $result->thumbnail_url;
|
50 |
}
|
51 |
return $result;
|
52 |
}
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "http://www.ted.com/talks/oembed.json?url=http%3A%2F%2Fwww.ted.com%2Ftalks%2F$id";
|
44 |
+
$response = wp_remote_get( $request );
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
48 |
$result = json_decode( $response['body'] );
|
49 |
+
$result = str_replace( '240x180.jpg', '480x360.jpg', $result->thumbnail_url );
|
50 |
}
|
51 |
return $result;
|
52 |
}
|
php/providers/class-tudou-thumbnails.php
CHANGED
@@ -56,7 +56,7 @@ class Tudou_Thumbnails extends Video_Thumbnails_Provider {
|
|
56 |
|
57 |
if ( $app_key ) {
|
58 |
$request = "http://api.tudou.com/v6/video/info?app_key=$app_key&format=json&itemCodes=$id";
|
59 |
-
$response = wp_remote_get( $request
|
60 |
if( is_wp_error( $response ) ) {
|
61 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
62 |
} else {
|
56 |
|
57 |
if ( $app_key ) {
|
58 |
$request = "http://api.tudou.com/v6/video/info?app_key=$app_key&format=json&itemCodes=$id";
|
59 |
+
$response = wp_remote_get( $request );
|
60 |
if( is_wp_error( $response ) ) {
|
61 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
62 |
} else {
|
php/providers/class-twitch-thumbnails.php
CHANGED
@@ -37,12 +37,13 @@ class Twitch_Thumbnails extends Video_Thumbnails_Provider {
|
|
37 |
public $regexes = array(
|
38 |
'#(?:www\.)?twitch\.tv/(?:[A-Za-z0-9_]+)/c/([0-9]+)#', // Video URL
|
39 |
'#<object[^>]+>.+?http://www\.twitch\.tv/widgets/archive_embed_player\.swf.+?chapter_id=([0-9]+).+?</object>#s', // Flash embed
|
|
|
40 |
);
|
41 |
|
42 |
// Thumbnail URL
|
43 |
public function get_thumbnail_url( $id ) {
|
44 |
$request = "https://api.twitch.tv/kraken/videos/c$id";
|
45 |
-
$response = wp_remote_get( $request
|
46 |
if( is_wp_error( $response ) ) {
|
47 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
48 |
} else {
|
@@ -56,15 +57,15 @@ class Twitch_Thumbnails extends Video_Thumbnails_Provider {
|
|
56 |
public static function get_test_cases() {
|
57 |
return array(
|
58 |
array(
|
59 |
-
'markup' => 'http://www.twitch.tv/
|
60 |
-
'expected' => 'http://static-cdn.jtvnw.net/jtv.thumbs/archive-
|
61 |
-
'expected_hash' => '
|
62 |
'name' => __( 'Video URL', 'video-thumbnails' )
|
63 |
),
|
64 |
array(
|
65 |
-
'markup' => '<object bgcolor="#000000" data="http://www.twitch.tv/
|
66 |
-
'expected' => 'http://static-cdn.jtvnw.net/jtv.thumbs/archive-
|
67 |
-
'expected_hash' => '
|
68 |
'name' => __( 'Flash Embed', 'video-thumbnails' )
|
69 |
),
|
70 |
);
|
37 |
public $regexes = array(
|
38 |
'#(?:www\.)?twitch\.tv/(?:[A-Za-z0-9_]+)/c/([0-9]+)#', // Video URL
|
39 |
'#<object[^>]+>.+?http://www\.twitch\.tv/widgets/archive_embed_player\.swf.+?chapter_id=([0-9]+).+?</object>#s', // Flash embed
|
40 |
+
'#<object[^>]+>.+?http://www\.twitch\.tv/swflibs/TwitchPlayer\.swf.+?videoId=c([0-9]+).+?</object>#s', // Newer Flash embed
|
41 |
);
|
42 |
|
43 |
// Thumbnail URL
|
44 |
public function get_thumbnail_url( $id ) {
|
45 |
$request = "https://api.twitch.tv/kraken/videos/c$id";
|
46 |
+
$response = wp_remote_get( $request );
|
47 |
if( is_wp_error( $response ) ) {
|
48 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
49 |
} else {
|
57 |
public static function get_test_cases() {
|
58 |
return array(
|
59 |
array(
|
60 |
+
'markup' => 'http://www.twitch.tv/jodenstone/c/5793313',
|
61 |
+
'expected' => 'http://static-cdn.jtvnw.net/jtv.thumbs/archive-605904705-320x240.jpg',
|
62 |
+
'expected_hash' => '1b2c51fc7380c74d1b2d34751d73e4cb',
|
63 |
'name' => __( 'Video URL', 'video-thumbnails' )
|
64 |
),
|
65 |
array(
|
66 |
+
'markup' => '<object bgcolor="#000000" data="http://www.twitch.tv/swflibs/TwitchPlayer.swf" height="378" id="clip_embed_player_flash" type="application/x-shockwave-flash" width="620"><param name="movie" value="http://www.twitch.tv/swflibs/TwitchPlayer.swf" /><param name="allowScriptAccess" value="always" /><param name="allowNetworking" value="all" /><param name="allowFullScreen" value="true" /><param name="flashvars" value="channel=jodenstone&auto_play=false&start_volume=25&videoId=c5793313&device_id=bbe9fbac133ab340" /></object>',
|
67 |
+
'expected' => 'http://static-cdn.jtvnw.net/jtv.thumbs/archive-605904705-320x240.jpg',
|
68 |
+
'expected_hash' => '1b2c51fc7380c74d1b2d34751d73e4cb',
|
69 |
'name' => __( 'Flash Embed', 'video-thumbnails' )
|
70 |
),
|
71 |
);
|
php/providers/class-video-thumbnails-provider.php
CHANGED
@@ -81,6 +81,16 @@ class Video_Thumbnails_Provider {
|
|
81 |
return $videos;
|
82 |
}
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
/**
|
85 |
* Constructs a WP_Error object after failed API retrieval
|
86 |
* @param string $request The URL wp_remote_get() failed to retrieve
|
81 |
return $videos;
|
82 |
}
|
83 |
|
84 |
+
/**
|
85 |
+
* Drops the parameters from a thumbnail URL
|
86 |
+
* @param string $url
|
87 |
+
* @return string
|
88 |
+
*/
|
89 |
+
static function drop_url_parameters( $url ) {
|
90 |
+
$url = explode( '?', $url );
|
91 |
+
return $url[0];
|
92 |
+
}
|
93 |
+
|
94 |
/**
|
95 |
* Constructs a WP_Error object after failed API retrieval
|
96 |
* @param string $request The URL wp_remote_get() failed to retrieve
|
php/providers/class-vimeo-thumbnails.php
CHANGED
@@ -85,7 +85,7 @@ class Vimeo_Thumbnails extends Video_Thumbnails_Provider {
|
|
85 |
$result = $response->thumbnails->thumbnail[count($response->thumbnails->thumbnail)-1]->_content;
|
86 |
} else {
|
87 |
$request = "http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/$id";
|
88 |
-
$response = wp_remote_get( $request
|
89 |
if( is_wp_error( $response ) ) {
|
90 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
91 |
} elseif ( $response['response']['code'] == 404 ) {
|
@@ -117,8 +117,8 @@ class Vimeo_Thumbnails extends Video_Thumbnails_Provider {
|
|
117 |
),
|
118 |
array(
|
119 |
'markup' => 'https://vimeo.com/channels/soundworkscollection/44520894',
|
120 |
-
'expected' => 'http://i.vimeocdn.com/video/
|
121 |
-
'expected_hash' => '
|
122 |
'name' => __( 'Channel URL', 'video-thumbnails' )
|
123 |
),
|
124 |
);
|
85 |
$result = $response->thumbnails->thumbnail[count($response->thumbnails->thumbnail)-1]->_content;
|
86 |
} else {
|
87 |
$request = "http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/$id";
|
88 |
+
$response = wp_remote_get( $request );
|
89 |
if( is_wp_error( $response ) ) {
|
90 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
91 |
} elseif ( $response['response']['code'] == 404 ) {
|
117 |
),
|
118 |
array(
|
119 |
'markup' => 'https://vimeo.com/channels/soundworkscollection/44520894',
|
120 |
+
'expected' => 'http://i.vimeocdn.com/video/502998892_1280.jpg',
|
121 |
+
'expected_hash' => 'fde254d7ef7b6463cbd2451a99f2ddb1',
|
122 |
'name' => __( 'Channel URL', 'video-thumbnails' )
|
123 |
),
|
124 |
);
|
php/providers/class-vine-thumbnails.php
CHANGED
@@ -41,7 +41,7 @@ class Vine_Thumbnails extends Video_Thumbnails_Provider {
|
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "https://vine.co/v/$id";
|
44 |
-
$response = wp_remote_get( $request
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
41 |
// Thumbnail URL
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "https://vine.co/v/$id";
|
44 |
+
$response = wp_remote_get( $request );
|
45 |
if( is_wp_error( $response ) ) {
|
46 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
} else {
|
php/providers/class-vk-thumbnails.php
CHANGED
@@ -42,7 +42,7 @@ class Vk_Thumbnails extends Video_Thumbnails_Provider {
|
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "http:$id";
|
44 |
$request = html_entity_decode( $request );
|
45 |
-
$response = wp_remote_get( $request
|
46 |
$result = false;
|
47 |
if( is_wp_error( $response ) ) {
|
48 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
42 |
public function get_thumbnail_url( $id ) {
|
43 |
$request = "http:$id";
|
44 |
$request = html_entity_decode( $request );
|
45 |
+
$response = wp_remote_get( $request );
|
46 |
$result = false;
|
47 |
if( is_wp_error( $response ) ) {
|
48 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
php/providers/class-wistia-thumbnails.php
CHANGED
@@ -63,12 +63,12 @@ class Wistia_Thumbnails extends Video_Thumbnails_Provider {
|
|
63 |
// ID should now be an embed URL, use oEmbed to find thumbnail URL
|
64 |
$id = urlencode( $id );
|
65 |
$request = "http://fast.wistia.com/oembed?url=$id";
|
66 |
-
$response = wp_remote_get( $request
|
67 |
if( is_wp_error( $response ) ) {
|
68 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
69 |
} else {
|
70 |
$result = json_decode( $response['body'] );
|
71 |
-
$result = $result->thumbnail_url;
|
72 |
}
|
73 |
|
74 |
return $result;
|
63 |
// ID should now be an embed URL, use oEmbed to find thumbnail URL
|
64 |
$id = urlencode( $id );
|
65 |
$request = "http://fast.wistia.com/oembed?url=$id";
|
66 |
+
$response = wp_remote_get( $request );
|
67 |
if( is_wp_error( $response ) ) {
|
68 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
69 |
} else {
|
70 |
$result = json_decode( $response['body'] );
|
71 |
+
$result = $this->drop_url_parameters( $result->thumbnail_url );
|
72 |
}
|
73 |
|
74 |
return $result;
|
php/providers/class-youku-thumbnails.php
CHANGED
@@ -43,7 +43,7 @@ class Youku_Thumbnails extends Video_Thumbnails_Provider {
|
|
43 |
// Thumbnail URL
|
44 |
public function get_thumbnail_url( $id ) {
|
45 |
$request = "http://v.youku.com/player/getPlayList/VideoIDS/$id/";
|
46 |
-
$response = wp_remote_get( $request
|
47 |
if( is_wp_error( $response ) ) {
|
48 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
49 |
} else {
|
43 |
// Thumbnail URL
|
44 |
public function get_thumbnail_url( $id ) {
|
45 |
$request = "http://v.youku.com/player/getPlayList/VideoIDS/$id/";
|
46 |
+
$response = wp_remote_get( $request );
|
47 |
if( is_wp_error( $response ) ) {
|
48 |
$result = $this->construct_info_retrieval_error( $request, $response );
|
49 |
} else {
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: sutherlandboswell
|
|
3 |
Donate link: http://wie.ly/u/donate
|
4 |
Tags: Video, Thumbnails, YouTube, Vimeo, Vine, Twitch, Dailymotion, Youku, Rutube, Featured Image
|
5 |
Requires at least: 3.2
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 2.10.
|
8 |
|
9 |
Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
|
10 |
|
@@ -131,6 +131,11 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
|
|
131 |
|
132 |
== Changelog ==
|
133 |
|
|
|
|
|
|
|
|
|
|
|
134 |
= 2.10.2 =
|
135 |
* Added actions hooks before and after generating attachment metadata
|
136 |
|
3 |
Donate link: http://wie.ly/u/donate
|
4 |
Tags: Video, Thumbnails, YouTube, Vimeo, Vine, Twitch, Dailymotion, Youku, Rutube, Featured Image
|
5 |
Requires at least: 3.2
|
6 |
+
Tested up to: 4.1
|
7 |
+
Stable tag: 2.10.3
|
8 |
|
9 |
Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
|
10 |
|
131 |
|
132 |
== Changelog ==
|
133 |
|
134 |
+
= 2.10.3 =
|
135 |
+
* Various updates to providers
|
136 |
+
* Removed "sslverify" => false in wp_remote_get() (may cause errors on WordPress versions before 3.7)
|
137 |
+
* Better error messages for Google Drive
|
138 |
+
|
139 |
= 2.10.2 =
|
140 |
* Added actions hooks before and after generating attachment metadata
|
141 |
|
video-thumbnails.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://refactored.co/plugins/video-thumbnails
|
|
5 |
Description: Automatically retrieve video thumbnails for your posts and display them in your theme. Supports YouTube, Vimeo, Facebook, Vine, Justin.tv, Twitch, Dailymotion, Metacafe, VK, Blip, Google Drive, Funny or Die, CollegeHumor, MPORA, Wistia, Youku, and Rutube.
|
6 |
Author: Sutherland Boswell
|
7 |
Author URI: http://sutherlandboswell.com
|
8 |
-
Version: 2.10.
|
9 |
License: GPL2
|
10 |
Text Domain: video-thumbnails
|
11 |
Domain Path: /languages/
|
@@ -30,7 +30,7 @@ Domain Path: /languages/
|
|
30 |
|
31 |
define( 'VIDEO_THUMBNAILS_PATH', dirname(__FILE__) );
|
32 |
define( 'VIDEO_THUMBNAILS_FIELD', '_video_thumbnail' );
|
33 |
-
define( 'VIDEO_THUMBNAILS_VERSION', '2.10.
|
34 |
|
35 |
// Providers
|
36 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/providers.php' );
|
@@ -344,7 +344,7 @@ class Video_Thumbnails {
|
|
344 |
public static function save_to_media_library( $image_url, $post_id ) {
|
345 |
|
346 |
$error = '';
|
347 |
-
$response = wp_remote_get( $image_url
|
348 |
if( is_wp_error( $response ) ) {
|
349 |
$error = new WP_Error( 'thumbnail_retrieval', sprintf( __( 'Error retrieving a thumbnail from the URL <a href="%1$s">%1$s</a> using <code>wp_remote_get()</code><br />If opening that URL in your web browser returns anything else than an error page, the problem may be related to your web server and might be something your host administrator can solve.', 'video-thumbnails' ), $image_url ) . '<br>' . __( 'Error Details:', 'video-thumbnails' ) . ' ' . $response->get_error_message() );
|
350 |
} else {
|
5 |
Description: Automatically retrieve video thumbnails for your posts and display them in your theme. Supports YouTube, Vimeo, Facebook, Vine, Justin.tv, Twitch, Dailymotion, Metacafe, VK, Blip, Google Drive, Funny or Die, CollegeHumor, MPORA, Wistia, Youku, and Rutube.
|
6 |
Author: Sutherland Boswell
|
7 |
Author URI: http://sutherlandboswell.com
|
8 |
+
Version: 2.10.3
|
9 |
License: GPL2
|
10 |
Text Domain: video-thumbnails
|
11 |
Domain Path: /languages/
|
30 |
|
31 |
define( 'VIDEO_THUMBNAILS_PATH', dirname(__FILE__) );
|
32 |
define( 'VIDEO_THUMBNAILS_FIELD', '_video_thumbnail' );
|
33 |
+
define( 'VIDEO_THUMBNAILS_VERSION', '2.10.3' );
|
34 |
|
35 |
// Providers
|
36 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/providers.php' );
|
344 |
public static function save_to_media_library( $image_url, $post_id ) {
|
345 |
|
346 |
$error = '';
|
347 |
+
$response = wp_remote_get( $image_url );
|
348 |
if( is_wp_error( $response ) ) {
|
349 |
$error = new WP_Error( 'thumbnail_retrieval', sprintf( __( 'Error retrieving a thumbnail from the URL <a href="%1$s">%1$s</a> using <code>wp_remote_get()</code><br />If opening that URL in your web browser returns anything else than an error page, the problem may be related to your web server and might be something your host administrator can solve.', 'video-thumbnails' ), $image_url ) . '<br>' . __( 'Error Details:', 'video-thumbnails' ) . ' ' . $response->get_error_message() );
|
350 |
} else {
|