Video Thumbnails - Version 2.9

Version Description

  • Added Tudou support
  • Added SAPO support
  • Updated Justin.tv to support the live player now that archives are being removed
Download this release

Release Info

Developer sutherlandboswell
Plugin Icon 128x128 Video Thumbnails
Version 2.9
Comparing to
See all releases

Code changes from version 2.8 to 2.9

php/providers/class-justintv-thumbnails.php CHANGED
@@ -35,18 +35,18 @@ class Justintv_Thumbnails extends Video_Thumbnails_Providers {
35
 
36
  // Regex strings
37
  public $regexes = array(
38
- '#archive_id=([0-9]+)#' // Archive ID
39
  );
40
 
41
  // Thumbnail URL
42
  public function get_thumbnail_url( $id ) {
43
- $request = "http://api.justin.tv/api/clip/show/$id.xml";
44
  $response = wp_remote_get( $request, array( 'sslverify' => false ) );
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->object->image_url_large;
50
  }
51
  return $result;
52
  }
@@ -55,9 +55,9 @@ class Justintv_Thumbnails extends Video_Thumbnails_Providers {
55
  public static function get_test_cases() {
56
  return array(
57
  array(
58
- 'markup' => '<object type="application/x-shockwave-flash" height="300" width="400" id="clip_embed_player_flash" data="http://www-cdn.justin.tv/widgets/archive_embed_player.swf" bgcolor="#000000"><param name="movie" value="http://www-cdn.justin.tv/widgets/archive_embed_player.swf" /><param name="allowScriptAccess" value="always" /><param name="allowNetworking" value="all" /><param name="allowFullScreen" value="true" /><param name="flashvars" value="auto_play=false&start_volume=25&title=Title&channel=scamschoolbrian&archive_id=392481524" /></object>',
59
- 'expected' => 'http://static-cdn.jtvnw.net/jtv.thumbs/archive-392481524-320x240.jpg',
60
- 'expected_hash' => '7f260a2ce6ae75a3c2e5012108f161b7',
61
  'name' => __( 'Flash Embed', 'video-thumbnails' )
62
  ),
63
  );
35
 
36
  // Regex strings
37
  public $regexes = array(
38
+ '#//(?:www\.)?justin\.tv/swflibs/JustinPlayer\.swf\?channel=([a-zA-Z0-9_]+)#' // Channel player
39
  );
40
 
41
  // Thumbnail URL
42
  public function get_thumbnail_url( $id ) {
43
+ $request = "http://api.justin.tv/api/channel/show/$id.json";
44
  $response = wp_remote_get( $request, array( 'sslverify' => false ) );
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->screen_cap_url_huge;
50
  }
51
  return $result;
52
  }
55
  public static function get_test_cases() {
56
  return array(
57
  array(
58
+ 'markup' => '<object type="application/x-shockwave-flash" data="http://www.justin.tv/swflibs/JustinPlayer.swf?channel=twit" id="live_embed_player_flash" height="300" width="400" bgcolor="#000000"><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always" /><param name="allowNetworking" value="all" /><param name="movie" value="http://www.justin.tv/swflibs/JustinPlayer.swf" /><param name="flashvars" value="hostname=www.justin.tv&channel=twit&auto_play=false&start_volume=25" /></object>',
59
+ 'expected' => 'http://static-cdn.jtvnw.net/previews/live_user_twit-630x473.jpg',
60
+ 'expected_hash' => 'b8c0dd6565f34e6bfbbddbb07ff0df74',
61
  'name' => __( 'Flash Embed', 'video-thumbnails' )
62
  ),
63
  );
php/providers/class-sapo-thumbnails.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Copyright 2014 Sutherland Boswell (email : sutherland.boswell@gmail.com)
4
+
5
+ This program is free software; you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License, version 2, as
7
+ published by the Free Software Foundation.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+ */
18
+
19
+ // Require thumbnail provider class
20
+ require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
21
+
22
+ class SAPO_Thumbnails extends Video_Thumbnails_Providers {
23
+
24
+ // Human-readable name of the video provider
25
+ public $service_name = 'SAPO';
26
+ const service_name = 'SAPO';
27
+ // Slug for the video provider
28
+ public $service_slug = 'sapo';
29
+ const service_slug = 'sapo';
30
+
31
+ public static function register_provider( $providers ) {
32
+ $providers[self::service_slug] = new self;
33
+ return $providers;
34
+ }
35
+
36
+ // Regex strings
37
+ public $regexes = array(
38
+ '#videos\.sapo\.pt/([A-Za-z0-9]+)/mov#', // iFrame SRC
39
+ );
40
+
41
+ // Thumbnail URL
42
+ public function get_thumbnail_url( $id ) {
43
+ $request = "http://videos.sapo.pt/$id";
44
+ $response = wp_remote_get( $request, array( 'sslverify' => false ) );
45
+ if( is_wp_error( $response ) ) {
46
+ $result = $this->construct_info_retrieval_error( $request, $response );
47
+ } else {
48
+ $doc = new DOMDocument();
49
+ @$doc->loadHTML( $response['body'] );
50
+ $metas = $doc->getElementsByTagName( 'meta' );
51
+ for ( $i = 0; $i < $metas->length; $i++ ) {
52
+ $meta = $metas->item( $i );
53
+ if ( $meta->getAttribute( 'property' ) == 'og:image' ) {
54
+ $result = $meta->getAttribute( 'content' );
55
+ break;
56
+ }
57
+ }
58
+ }
59
+ return $result;
60
+ }
61
+
62
+ // Test cases
63
+ public static function get_test_cases() {
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://cache12.stormap.sapo.pt/vidstore14/thumbnais/74/5f/4c/7038488_tf9s9.jpg',
68
+ 'expected_hash' => '0f95b2d32f3989a5d10d4d249f40b989',
69
+ 'name' => __( 'iFrame Embed', 'video-thumbnails' )
70
+ ),
71
+ );
72
+ }
73
+
74
+ }
75
+
76
+ // Add to provider array
77
+ add_filter( 'video_thumbnail_providers', array( 'SAPO_Thumbnails', 'register_provider' ) );
78
+
79
+ ?>
php/providers/class-tudou-thumbnails.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Copyright 2014 Sutherland Boswell (email : sutherland.boswell@gmail.com)
4
+
5
+ This program is free software; you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License, version 2, as
7
+ published by the Free Software Foundation.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+ */
18
+
19
+ // Require thumbnail provider class
20
+ require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
21
+
22
+ class Tudou_Thumbnails extends Video_Thumbnails_Providers {
23
+
24
+ // Human-readable name of the video provider
25
+ public $service_name = 'Tudou';
26
+ const service_name = 'Tudou';
27
+ // Slug for the video provider
28
+ public $service_slug = 'tudou';
29
+ const service_slug = 'tudou';
30
+
31
+ public $options_section = array(
32
+ 'description' => '<p><strong>Optional</strong>: Only required if using videos from Tudou.</p><p><strong>Directions</strong>: Go to <a href="http://open.tudou.com/">open.tudou.com</a> and create an application, then copy and paste your app key below.</p>',
33
+ 'fields' => array(
34
+ 'app_key' => array(
35
+ 'name' => 'App Key',
36
+ 'type' => 'text',
37
+ 'description' => ''
38
+ )
39
+ )
40
+ );
41
+
42
+ public static function register_provider( $providers ) {
43
+ $providers[self::service_slug] = new self;
44
+ return $providers;
45
+ }
46
+
47
+ // Regex strings
48
+ public $regexes = array(
49
+ '#//(?:www\.)?tudou\.com/programs/view/html5embed\.action\?type=(?:[0-9]+)(?:&|&\#038;|&amp;)code=([A-Za-z0-9\-_]+)#', // iFrame SRC
50
+ );
51
+
52
+ // Thumbnail URL
53
+ public function get_thumbnail_url( $id ) {
54
+ // Get our API key
55
+ $app_key = ( isset( $this->options['app_key'] ) && $this->options['app_key'] != '' ? $this->options['app_key'] : false );
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, array( 'sslverify' => false ) );
60
+ if( is_wp_error( $response ) ) {
61
+ $result = $this->construct_info_retrieval_error( $request, $response );
62
+ } else {
63
+ $result = json_decode( $response['body'] );
64
+ if ( isset( $result->error_info ) ) {
65
+ $result = new WP_Error( 'tudou_api_error', $result->error_info );
66
+ } elseif ( !isset( $result->results[0]->bigPicUrl ) ) {
67
+ $result = new WP_Error( 'tudou_not_found', sprintf( __( 'Unable to retrieve thumbnail for Tudou video with an ID of %s', 'video-thumbnails' ), $id ) );
68
+ } else {
69
+ $result = $result->results[0]->bigPicUrl;
70
+ }
71
+ }
72
+ } else {
73
+ $result = new WP_Error( 'tudou_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 Tudou.', 'video-thumbnails' ) );
74
+ }
75
+ return $result;
76
+ }
77
+
78
+ // Test cases
79
+ public static function get_test_cases() {
80
+ return array(
81
+ array(
82
+ 'markup' => '<iframe src="http://www.tudou.com/programs/view/html5embed.action?type=1&code=V-TeNdhKVCA&lcode=eNoG-G9OkrQ&resourceId=0_06_05_99" allowtransparency="true" scrolling="no" border="0" frameborder="0" style="width:480px;height:400px;"></iframe>',
83
+ 'expected' => 'http://g3.tdimg.com/83fedbc41cf9055dce9182a0c07da601/w_2.jpg',
84
+ 'expected_hash' => '3a5e656f8c302ae5b23665f22d296ae1',
85
+ 'name' => __( 'iFrame Embed', 'video-thumbnails' )
86
+ ),
87
+ );
88
+ }
89
+
90
+ }
91
+
92
+ // Add to provider array
93
+ add_filter( 'video_thumbnail_providers', array( 'Tudou_Thumbnails', 'register_provider' ) );
94
+
95
+ ?>
php/providers/class-video-thumbnails-providers.php CHANGED
@@ -115,8 +115,10 @@ require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-mpora-thumbnails.php
115
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-wistia-thumbnails.php' );
116
  // require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-kaltura-thumbnails.php' );
117
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-youku-thumbnails.php' );
 
118
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-collegehumor-thumbnails.php' );
119
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-rutube-thumbnails.php' );
 
120
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-ted-thumbnails.php' );
121
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-twitch-thumbnails.php' );
122
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-googledrive-thumbnails.php' );
115
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-wistia-thumbnails.php' );
116
  // require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-kaltura-thumbnails.php' );
117
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-youku-thumbnails.php' );
118
+ require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-tudou-thumbnails.php' );
119
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-collegehumor-thumbnails.php' );
120
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-rutube-thumbnails.php' );
121
+ require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-sapo-thumbnails.php' );
122
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-ted-thumbnails.php' );
123
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-twitch-thumbnails.php' );
124
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-googledrive-thumbnails.php' );
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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: 3.9
7
- Stable tag: 2.8
8
 
9
  Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
10
 
@@ -35,6 +35,8 @@ Video Thumbnails makes it easy to automatically display video thumbnails in your
35
  * MPORA
36
  * Wistia
37
  * Youku
 
 
38
  * Rutube
39
 
40
  Video Thumbnails even works with most video plugins, including:
@@ -131,6 +133,11 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
131
 
132
  == Changelog ==
133
 
 
 
 
 
 
134
  = 2.8 =
135
  * Added support for TED Talks
136
  * Improved error handling for AJAX on settings page
4
  Tags: Video, Thumbnails, YouTube, Vimeo, Vine, Twitch, Dailymotion, Youku, Rutube, Featured Image
5
  Requires at least: 3.2
6
  Tested up to: 3.9
7
+ Stable tag: 2.9
8
 
9
  Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
10
 
35
  * MPORA
36
  * Wistia
37
  * Youku
38
+ * Tudou
39
+ * SAPO
40
  * Rutube
41
 
42
  Video Thumbnails even works with most video plugins, including:
133
 
134
  == Changelog ==
135
 
136
+ = 2.9 =
137
+ * Added Tudou support
138
+ * Added SAPO support
139
+ * Updated Justin.tv to support the live player now that archives are being removed
140
+
141
  = 2.8 =
142
  * Added support for TED Talks
143
  * Improved error handling for AJAX on settings page
screenshot-1.gif CHANGED
Binary file
screenshot-2.gif CHANGED
Binary file
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.8
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.8' );
34
 
35
  // Providers
36
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
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.9
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.9' );
34
 
35
  // Providers
36
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );