0 ) { return $actual_start_timestamp; } return self::get_scheduled_start_timestamp( $post, $misc_data ); } public static function get_scheduled_start_timestamp( $post, $misc_data = array() ) { if ( ! empty( $post['liveStreamingDetails']['scheduledStartTime'] ) ) { $remove_extra = str_replace( array( 'T', '+00:00', '.000Z', '+' ), ' ', $post['liveStreamingDetails']['scheduledStartTime'] ); $timestamp = strtotime( $remove_extra ); return $timestamp; } elseif ( isset( $misc_data['live_streaming_details'][ SBY_Parse::get_video_id( $post ) ]['sby_scheduled_start_time'] ) ) { return strtotime( $misc_data['live_streaming_details'][ SBY_Parse::get_video_id( $post ) ]['sby_scheduled_start_time'] ); } elseif ( isset( $misc_data['sby_scheduled_start_time'][0] ) ) { return strtotime( $misc_data['sby_scheduled_start_time'][0] ); } elseif ( isset( $post['sby_scheduled_start_time'] ) ) { return strtotime( $post['sby_scheduled_start_time'] ); } return 0; } public static function get_actual_start_timestamp( $post, $misc_data = array() ) { if ( ! empty( $post['liveStreamingDetails']['actualStartTime'] ) ) { $remove_extra = str_replace( array( 'T', '+00:00', '.000Z', '+' ), ' ', $post['liveStreamingDetails']['actualStartTime'] ); $timestamp = strtotime( $remove_extra ); return $timestamp; } elseif ( isset( $misc_data['live_streaming_details'][ SBY_Parse::get_video_id( $post ) ]['sby_actual_start_time'] ) ) { return strtotime( $misc_data['live_streaming_details'][ SBY_Parse::get_video_id( $post ) ]['sby_actual_start_time'] ); } elseif ( isset( $misc_data['sby_actual_start_time'][0] ) ) { return strtotime( $misc_data['sby_actual_start_time'][0] ); } elseif ( isset( $post['sby_actual_start_time'] ) ) { return strtotime( $post['sby_actual_start_time'] ); } return 0; } public static function get_video_title( $channel_or_playlist_item_data ) { if ( isset( $channel_or_playlist_item_data['items'][0]['snippet']['title'] ) ) { return $channel_or_playlist_item_data['items'][0]['snippet']['title']; } else if ( isset( $channel_or_playlist_item_data['snippet']['title'] ) ) { return $channel_or_playlist_item_data['snippet']['title']; } return ''; } public static function get_channel_id( $channel_or_playlist_item_data ) { if ( isset( $channel_or_playlist_item_data['items'][0]['id'] ) ) { return $channel_or_playlist_item_data['items'][0]['id']; } elseif ( isset( $channel_or_playlist_item_data['snippet']['channelId'] ) ) { return $channel_or_playlist_item_data['snippet']['channelId']; } elseif ( isset( $channel_or_playlist_item_data['id'] ) ) { return $channel_or_playlist_item_data['id']; } return ''; } public static function get_channel_title( $channel_or_playlist_item_data ) { if ( isset( $channel_or_playlist_item_data['items'][0]['snippet']['title'] ) ) { return $channel_or_playlist_item_data['items'][0]['snippet']['title']; } elseif ( isset( $channel_or_playlist_item_data['snippet']['channelTitle'] ) ) { return $channel_or_playlist_item_data['snippet']['channelTitle']; } return ''; } public static function get_channel_permalink( $channel_data ) { return 'https://www.youtube.com/channel/' . SBY_Parse::get_channel_id( $channel_data ) . '/'; } /** * @param array $header_data * @param array $settings * * @return string * * @since 1.0 */ public static function get_avatar( $header_data, $settings = array( 'favor_local' => false ) ) { if ( !empty($settings['favor_local'] ) && ! empty( $header_data['local_avatar'] ) ) { return $header_data['local_avatar']; } else { if ( isset( $header_data['items'][0]['snippet']['thumbnails'] ) ) { $header_size = isset( $settings['headersize'] ) ? $settings['headersize'] : ''; if ( $header_size === 'large' ) { return $header_data['items'][0]['snippet']['thumbnails']['high']['url']; } elseif ( $header_size === 'medium' ) { return $header_data['items'][0]['snippet']['thumbnails']['medium']['url']; } else { return $header_data['items'][0]['snippet']['thumbnails']['default']['url']; } } } return ''; } public static function get_item_avatar( $post, $avatars ) { if ( empty ( $avatars ) ) { return ''; } else { $username = SBY_Parse::get_channel_id( $post ); if ( isset( $avatars[ $username ] ) ) { return $avatars[ $username ]; } } return ''; } /** * Account bio/description used in header * * @param $header_data * * @return string * * @since 1.0 */ public static function get_channel_description( $header_data ) { if ( isset( $header_data['items'][0]['snippet']['description'] ) ) { return $header_data['items'][0]['snippet']['description']; } return ''; } /** * Parse quoted strings as boolean such as 'true' and 'false' * * @since 2.0 */ public static function parse_quoted_string_as_boolean( $settings ) { foreach($settings as $key => $value) { if ( $value == 'true' ) { $settings[$key] = true; } if ( $value == 'false' ) { $settings[$key] = false; } } return $settings; } }