'

Optional: Only required if using videos from Tudou.

Directions: Go to open.tudou.com and create an application, then copy and paste your app key below.

', 'fields' => array( 'app_key' => array( 'name' => 'App Key', 'type' => 'text', 'description' => '' ) ) ); public static function register_provider( $providers ) { $providers[self::service_slug] = new self; return $providers; } // Regex strings public $regexes = array( '#//(?:www\.)?tudou\.com/programs/view/html5embed\.action\?type=(?:[0-9]+)(?:&|&\#038;|&)code=([A-Za-z0-9\-_]+)#', // iFrame SRC ); // Thumbnail URL public function get_thumbnail_url( $id ) { // Get our API key $app_key = ( isset( $this->options['app_key'] ) && $this->options['app_key'] != '' ? $this->options['app_key'] : false ); if ( $app_key ) { $request = "http://api.tudou.com/v6/video/info?app_key=$app_key&format=json&itemCodes=$id"; $response = wp_remote_get( $request ); if( is_wp_error( $response ) ) { $result = $this->construct_info_retrieval_error( $request, $response ); } else { $result = json_decode( $response['body'] ); if ( isset( $result->error_info ) ) { $result = new WP_Error( 'tudou_api_error', $result->error_info ); } elseif ( !isset( $result->results[0]->bigPicUrl ) ) { $result = new WP_Error( 'tudou_not_found', sprintf( __( 'Unable to retrieve thumbnail for Tudou video with an ID of %s', 'video-thumbnails' ), $id ) ); } else { $result = $result->results[0]->bigPicUrl; } } } else { $result = new WP_Error( 'tudou_api_key', __( 'You must enter an API key in the provider settings to retrieve thumbnails from Tudou.', 'video-thumbnails' ) ); } return $result; } // Test cases public static function get_test_cases() { return array( array( 'markup' => '', 'expected' => 'http://g3.tdimg.com/83fedbc41cf9055dce9182a0c07da601/w_2.jpg', 'expected_hash' => '3a5e656f8c302ae5b23665f22d296ae1', 'name' => __( 'iFrame Embed', 'video-thumbnails' ) ), ); } } ?>