PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.3.2
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.3.2
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 +3 -55 2.3.82.3.2 View file →
@@ -100,12 +100,8 @@
100 100
101 101 // Get playlist id from the channel
102 102 $playlist_id = $this->get_playlist_id( $params );
103 103
104 - if ( is_object( $playlist_id ) && isset( $playlist_id->error ) ) {
105 - return $playlist_id;
106 - }
107 -
108 104 if ( empty( $playlist_id ) ) {
109 105 return $this->get_error( __( 'No videos found matching your query.', 'automatic-youtube-gallery' ) );
110 106 }
111 107
@@ -122,12 +118,8 @@
122 118 // Get playlist id from the channel
123 119 $params['forUsername'] = $this->parse_youtube_id_from_url( $params['src'], 'username' );
124 120 $playlist_id = $this->get_playlist_id( $params );
125 121
126 - if ( is_object( $playlist_id ) && isset( $playlist_id->error ) ) {
127 - return $playlist_id;
128 - }
129 -
130 122 if ( empty( $playlist_id ) ) {
131 123 return $this->get_error( __( 'No videos found matching your query.', 'automatic-youtube-gallery' ) );
132 124 }
133 125
@@ -156,16 +148,14 @@
156 148 if ( empty( $params['src'] ) ) {
157 149 return $this->get_error( __( 'YouTube Channel ID (or) or a YouTube Video URL from the Channel is required.', 'automatic-youtube-gallery' ) );
158 150 }
159 151
160 - $params['channelId'] = $this->get_channel_id( $params );
152 + $response = new stdClass();
153 + $response->id = $this->get_channel_id( $params );
161 154
162 - if ( empty( $params['channelId'] ) ) {
155 + if ( empty( $response->id ) ) {
163 156 return $this->get_error( __( 'Invalid YouTube Channel ID.', 'automatic-youtube-gallery' ) );
164 157 }
165 -
166 - // Get live video using the channel id
167 - $response = $this->request_api_live_video( $params );
168 158 break;
169 159
170 160 default: // video
171 161 if ( empty( $params['src'] ) ) {
@@ -471,50 +461,8 @@
471 461 $response->videos = $videos;
472 462
473 463 return $response;
474 464 }
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 - }
517 465
518 466 /**
519 467 * Get details of the given video ID.
520 468 *