PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.3.8
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.3.8
2.9.1 2.9.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 2.0.0 2.1.0 2.2.0 2.3.2 2.3.3 2.3.5 2.3.6 2.3.8 2.3.9 2.4.3 All 37 releases
← All changes | includes/youtube-api.php +47 -3 2.3.62.3.8 View file →
@@ -156,14 +156,16 @@
156 156 if ( empty( $params['src'] ) ) {
157 157 return $this->get_error( __( 'YouTube Channel ID (or) or a YouTube Video URL from the Channel is required.', 'automatic-youtube-gallery' ) );
158 158 }
159 159
160 - $response = new stdClass();
161 - $response->id = $this->get_channel_id( $params );
160 + $params['channelId'] = $this->get_channel_id( $params );
162 161
163 - if ( empty( $response->id ) ) {
162 + if ( empty( $params['channelId'] ) ) {
164 163 return $this->get_error( __( 'Invalid YouTube Channel ID.', 'automatic-youtube-gallery' ) );
165 164 }
165 +
166 + // Get live video using the channel id
167 + $response = $this->request_api_live_video( $params );
166 168 break;
167 169
168 170 default: // video
169 171 if ( empty( $params['src'] ) ) {
@@ -469,8 +471,50 @@
469 471 $response->videos = $videos;
470 472
471 473 return $response;
472 474 }
475 +
476 + /**
477 + * Get live video using search API.
478 + *
479 + * @since 2.3.7
480 + * @access private
481 + * @param array $params Array of query params.
482 + * @return mixed
483 + */
484 + private function request_api_live_video( $params = array() ) {
485 + $api_url = $this->get_api_url( 'search.list' );
486 +
487 + $params['type'] = 'video'; // Overrides user defined type value 'livestream'
488 +
489 + $api_params = $this->safe_merge_params(
490 + array(
491 + 'type' => 'video',
492 + 'eventType' => 'live',
493 + 'part' => 'snippet',
494 + 'channelId' => '',
495 + 'cache' => 0
496 + ),
497 + $params
498 + );
499 +
500 + $api_response = $this->request_api( $api_url, $api_params );
501 + if ( isset( $api_response->error ) ) {
502 + return $api_response;
503 + }
504 +
505 + $videos = $this->parse_videos( $api_response );
506 + if ( isset( $videos->error ) ) {
507 + $livestream_settings = get_option( 'ayg_livestream_settings' );
508 + return $this->get_error( '<div class="ayg-livestream-fallback-message">' . $livestream_settings['fallback_message'] . '</div>' );
509 + }
510 +
511 + // Process output
512 + $response = new stdClass();
513 + $response->videos = $videos;
514 +
515 + return $response;
516 + }
473 517
474 518 /**
475 519 * Get details of the given video ID.
476 520 *