Video Thumbnails - Version 2.3

Version Description

  • Added support for archived Twitch videos
  • Fixed issue with Funny or Die thumbnails
Download this release

Release Info

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

Code changes from version 2.2 to 2.3

php/providers/class-funnyordie-thumbnails.php CHANGED
@@ -41,19 +41,27 @@ class Funnyordie_Thumbnails extends Video_Thumbnails_Providers {
41
 
42
  // Thumbnail URL
43
  public function get_thumbnail_url( $id ) {
44
- return 'http://assets0.ordienetworks.com/tmbs/' . $id . '/large_11.jpg';
 
 
 
 
 
 
 
 
45
  }
46
 
47
  // Test cases
48
  public $test_cases = array(
49
  array(
50
  'markup' => '<iframe src="http://www.funnyordie.com/embed/5325b03b52" width="640" height="400" frameborder="0"></iframe>',
51
- 'expected' => 'http://assets0.ordienetworks.com/tmbs/5325b03b52/large_11.jpg',
52
  'name' => 'iFrame player'
53
  ),
54
  array(
55
  'markup' => '<object width="640" height="400" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="ordie_player_5325b03b52"><param name="movie" value="http://player.ordienetworks.com/flash/fodplayer.swf" /><param name="flashvars" value="key=5325b03b52" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always"><embed width="640" height="400" flashvars="key=5325b03b52" allowfullscreen="true" allowscriptaccess="always" quality="high" src="http://player.ordienetworks.com/flash/fodplayer.swf" name="ordie_player_5325b03b52" type="application/x-shockwave-flash"></embed></object>',
56
- 'expected' => 'http://assets0.ordienetworks.com/tmbs/5325b03b52/large_11.jpg',
57
  'name' => 'Flash player'
58
  ),
59
  );
41
 
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, array( 'sslverify' => false ) );
46
+ if( is_wp_error( $response ) ) {
47
+ $result = new WP_Error( 'funnyordie_info_retrieval', __( 'Error retrieving video information from the URL <a href="' . $request . '">' . $request . '</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.<br />Details: ' . $response->get_error_message() ) );
48
+ } else {
49
+ $result = json_decode( $response['body'] );
50
+ $result = $result->thumbnail_url;
51
+ }
52
+ return $result;
53
  }
54
 
55
  // Test cases
56
  public $test_cases = array(
57
  array(
58
  'markup' => '<iframe src="http://www.funnyordie.com/embed/5325b03b52" width="640" height="400" frameborder="0"></iframe>',
59
+ 'expected' => 'http://t.fod4.com/t/5325b03b52/c480x270_17.jpg',
60
  'name' => 'iFrame player'
61
  ),
62
  array(
63
  'markup' => '<object width="640" height="400" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="ordie_player_5325b03b52"><param name="movie" value="http://player.ordienetworks.com/flash/fodplayer.swf" /><param name="flashvars" value="key=5325b03b52" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always"><embed width="640" height="400" flashvars="key=5325b03b52" allowfullscreen="true" allowscriptaccess="always" quality="high" src="http://player.ordienetworks.com/flash/fodplayer.swf" name="ordie_player_5325b03b52" type="application/x-shockwave-flash"></embed></object>',
64
+ 'expected' => 'http://t.fod4.com/t/5325b03b52/c480x270_17.jpg',
65
  'name' => 'Flash player'
66
  ),
67
  );
php/providers/class-twitch-thumbnails.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Twitch_Thumbnails extends Video_Thumbnails_Providers {
23
+
24
+ // Human-readable name of the video provider
25
+ public $service_name = 'Twitch';
26
+ const service_name = 'Twitch';
27
+ // Slug for the video provider
28
+ public $service_slug = 'twitch';
29
+ const service_slug = 'twitch';
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
+ '#(?: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, array( 'sslverify' => false ) );
46
+ if( is_wp_error( $response ) ) {
47
+ $result = new WP_Error( 'twitch_info_retrieval', __( 'Error retrieving video information from the URL <a href="' . $request . '">' . $request . '</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.<br />Details: ' . $response->get_error_message() ) );
48
+ } else {
49
+ $result = json_decode( $response['body'] );
50
+ $result = $result->preview;
51
+ }
52
+ return $result;
53
+ }
54
+
55
+ // Test cases
56
+ public $test_cases = array(
57
+ array(
58
+ 'markup' => 'http://www.twitch.tv/vanillatv/c/1537974',
59
+ 'expected' => 'http://static-cdn.jtvnw.net/jtv.thumbs/archive-328087483-320x240.jpg',
60
+ 'name' => 'Video link'
61
+ ),
62
+ array(
63
+ 'markup' => '<object bgcolor="#000000" data="http://www.twitch.tv/widgets/archive_embed_player.swf" height="378" id="clip_embed_player_flash" type="application/x-shockwave-flash" width="620"><param name="movie" value="http://www.twitch.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="title=VanillaTV%2B-%2BSweden%2Bvs%2BRussia%2B-%2BETF2L%2BNations%2BCup%2B-%2BSnakewater%2B%255BMap3%255D%2B-%2BPart%2B3&amp;channel=vanillatv&amp;auto_play=false&amp;start_volume=25&amp;chapter_id=1537974"></object>',
64
+ 'expected' => 'http://static-cdn.jtvnw.net/jtv.thumbs/archive-328087483-320x240.jpg',
65
+ 'name' => 'Flash embed'
66
+ ),
67
+ );
68
+
69
+ }
70
+
71
+ // Add to provider array
72
+ add_filter( 'video_thumbnail_providers', array( 'Twitch_Thumbnails', 'register_provider' ) );
73
+
74
+ ?>
php/providers/class-video-thumbnails-providers.php CHANGED
@@ -103,5 +103,6 @@ require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-wistia-thumbnails.ph
103
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-youku-thumbnails.php' );
104
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-collegehumor-thumbnails.php' );
105
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-rutube-thumbnails.php' );
 
106
 
107
  ?>
103
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-youku-thumbnails.php' );
104
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-collegehumor-thumbnails.php' );
105
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-rutube-thumbnails.php' );
106
+ require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-twitch-thumbnails.php' );
107
 
108
  ?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://wie.ly/u/donate
4
  Tags: Video, Thumbnails, YouTube, Vimeo, Blip, Justin.tv, Dailymotion, Metacafe, Image, Featured Image, Post Thumbnail
5
  Requires at least: 3.1
6
  Tested up to: 3.8
7
- Stable tag: 2.2
8
 
9
  Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
10
 
@@ -27,6 +27,7 @@ Video Thumbnails currently supports these video services:
27
  * Youku
28
  * CollegeHumor
29
  * Rutube
 
30
 
31
  Video Thumbnails even works with most video embedding plugins, including:
32
 
@@ -98,6 +99,10 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
98
 
99
  == Changelog ==
100
 
 
 
 
 
101
  = 2.2 =
102
  * Added support for Rutube
103
 
4
  Tags: Video, Thumbnails, YouTube, Vimeo, Blip, Justin.tv, Dailymotion, Metacafe, Image, Featured Image, Post Thumbnail
5
  Requires at least: 3.1
6
  Tested up to: 3.8
7
+ Stable tag: 2.3
8
 
9
  Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
10
 
27
  * Youku
28
  * CollegeHumor
29
  * Rutube
30
+ * Twitch
31
 
32
  Video Thumbnails even works with most video embedding plugins, including:
33
 
99
 
100
  == Changelog ==
101
 
102
+ = 2.3 =
103
+ * Added support for archived Twitch videos
104
+ * Fixed issue with Funny or Die thumbnails
105
+
106
  = 2.2 =
107
  * Added support for Rutube
108
 
video-thumbnails.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://refactored.co/plugins/video-thumbnails
5
  Description: Automatically retrieve video thumbnails for your posts and display them in your theme. Currently supports YouTube, Vimeo, Facebook, Blip.tv, Justin.tv, Dailymotion, Metacafe, Wistia, Youku, Funny or Die, and MPORA.
6
  Author: Sutherland Boswell
7
  Author URI: http://sutherlandboswell.com
8
- Version: 2.2
9
  License: GPL2
10
  */
11
  /* Copyright 2013 Sutherland Boswell (email : sutherland.boswell@gmail.com)
@@ -28,7 +28,7 @@ License: GPL2
28
 
29
  define( 'VIDEO_THUMBNAILS_PATH', dirname(__FILE__) );
30
  define( 'VIDEO_THUMBNAILS_FIELD', '_video_thumbnail' );
31
- define( 'VIDEO_THUMBNAILS_VERSION', '2.2' );
32
 
33
  // Providers
34
  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. Currently supports YouTube, Vimeo, Facebook, Blip.tv, Justin.tv, Dailymotion, Metacafe, Wistia, Youku, Funny or Die, and MPORA.
6
  Author: Sutherland Boswell
7
  Author URI: http://sutherlandboswell.com
8
+ Version: 2.3
9
  License: GPL2
10
  */
11
  /* Copyright 2013 Sutherland Boswell (email : sutherland.boswell@gmail.com)
28
 
29
  define( 'VIDEO_THUMBNAILS_PATH', dirname(__FILE__) );
30
  define( 'VIDEO_THUMBNAILS_FIELD', '_video_thumbnail' );
31
+ define( 'VIDEO_THUMBNAILS_VERSION', '2.3' );
32
 
33
  // Providers
34
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );