private function beeteam368_youtube_get_upload_videos($playlist_upload, $pageToken, $prev_page_videos, $task_api_id = 0){ if(is_array($playlist_upload) && count($playlist_upload)==3){ $request_url = $this->search_url_date($playlist_upload[0], $playlist_upload[1], $playlist_upload[2], $pageToken, $task_api_id); }else{ $request_url = $this->playlist_url($playlist_upload, $pageToken, $task_api_id); } $response = wp_remote_get($request_url, array('timeout'=>368)); if(is_wp_error($response)){ return array(); }else { $result = json_decode($response['body']); if((isset($result->{'error'}) && $result->{'error'}!='') || (isset($result->{'pageInfo'}) && isset($result->{'pageInfo'}->{'totalResults'}) && $result->{'pageInfo'}->{'totalResults'}==0)){ return array(); } } $videos = array(); if(isset($result->{'items'}) && count($result->{'items'})>0){ foreach ($result->{'items'} as $value) { if(count($videos) >= 20) break; // Limit to 20 videos if(isset($value->{'contentDetails'}) && isset($value->{'contentDetails'}->{'videoId'}) && isset($value->{'contentDetails'}->{'videoPublishedAt'})){ $videoID = $value->{'contentDetails'}->{'videoId'}; $videoPublishedAt = $value->{'contentDetails'}->{'videoPublishedAt'}; array_push( $videos, array('videoID' => $videoID, $videoID => $videoPublishedAt) ); }elseif(isset($value->{'id'}) && isset($value->{'id'}->{'videoId'}) && isset($value->{'snippet'}) && isset($value->{'snippet'}->{'publishedAt'})){ $videoID = $value->{'id'}->{'videoId'}; $videoPublishedAt = $value->{'snippet'}->{'publishedAt'}; array_push( $videos, array('videoID' => $videoID, $videoID => $videoPublishedAt) ); } } } return $videos; } private function beeteam368_youtube_automatic_import($auto_id){ if(!isset($auto_id) || !is_numeric($auto_id)){ return; } $processing = get_post_meta($auto_id, $this->prefix.'processing', true); if($processing == 'yes'){ return; } $this->update_processing($auto_id, 'yes'); $playlist_upload = $this->auto_detech_playlist_id($this->auto_detech($youtube_source), '', '', $auto_id); if($playlist_upload!=''){ $fetch_videos = $this->beeteam368_youtube_get_upload_videos($playlist_upload, '', array(), $auto_id); if(!is_array($fetch_videos) || count($fetch_videos) == 0){ $this->update_processing($auto_id, 'no'); return; } $videos = array_slice(wp_list_pluck( $fetch_videos, 'videoID' ), 0, 20); // Limit to 20 foreach($videos as $video){ $newPostID = wp_insert_post([ 'post_title' => '[ID: '.$video.'] Youtube Automatic', 'post_status' => 'private' ]); if(!is_wp_error($newPostID)){ update_post_meta($newPostID, 'beeteam368_youtube_automactic_id', $video); } } } $this->update_processing($auto_id, 'no'); } {"id":1738,"count":1,"description":"","link":"https:\/\/punchdrunkgamer.com\/tag\/ufc-brazil\/","name":"UFC Brazil","slug":"ufc-brazil","taxonomy":"post_tag","meta":[],"yoast_head":"\nUFC Brazil Archives - PunchDrunkGamer<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/punchdrunkgamer.com\/tag\/ufc-brazil\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"UFC Brazil Archives - PunchDrunkGamer\" \/>\n<meta property=\"og:url\" content=\"https:\/\/punchdrunkgamer.com\/tag\/ufc-brazil\/\" \/>\n<meta property=\"og:site_name\" content=\"PunchDrunkGamer\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"CollectionPage\",\"@id\":\"https:\/\/punchdrunkgamer.com\/tag\/ufc-brazil\/\",\"url\":\"https:\/\/punchdrunkgamer.com\/tag\/ufc-brazil\/\",\"name\":\"UFC Brazil Archives - PunchDrunkGamer\",\"isPartOf\":{\"@id\":\"https:\/\/punchdrunkgamer.com\/#website\"},\"breadcrumb\":{\"@id\":\"https:\/\/punchdrunkgamer.com\/tag\/ufc-brazil\/#breadcrumb\"},\"inLanguage\":\"en-US\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/punchdrunkgamer.com\/tag\/ufc-brazil\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/punchdrunkgamer.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"UFC Brazil\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/punchdrunkgamer.com\/#website\",\"url\":\"https:\/\/punchdrunkgamer.com\/\",\"name\":\"PunchDrunkGamer\",\"description\":\"PunchDrunkGamer delivers the action-packed coverage you crave.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/punchdrunkgamer.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},false]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"UFC Brazil Archives - PunchDrunkGamer","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/punchdrunkgamer.com\/tag\/ufc-brazil\/","og_locale":"en_US","og_type":"article","og_title":"UFC Brazil Archives - PunchDrunkGamer","og_url":"https:\/\/punchdrunkgamer.com\/tag\/ufc-brazil\/","og_site_name":"PunchDrunkGamer","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"CollectionPage","@id":"https:\/\/punchdrunkgamer.com\/tag\/ufc-brazil\/","url":"https:\/\/punchdrunkgamer.com\/tag\/ufc-brazil\/","name":"UFC Brazil Archives - PunchDrunkGamer","isPartOf":{"@id":"https:\/\/punchdrunkgamer.com\/#website"},"breadcrumb":{"@id":"https:\/\/punchdrunkgamer.com\/tag\/ufc-brazil\/#breadcrumb"},"inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https:\/\/punchdrunkgamer.com\/tag\/ufc-brazil\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/punchdrunkgamer.com\/"},{"@type":"ListItem","position":2,"name":"UFC Brazil"}]},{"@type":"WebSite","@id":"https:\/\/punchdrunkgamer.com\/#website","url":"https:\/\/punchdrunkgamer.com\/","name":"PunchDrunkGamer","description":"PunchDrunkGamer delivers the action-packed coverage you crave.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/punchdrunkgamer.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},false]}},"_links":{"self":[{"href":"https:\/\/punchdrunkgamer.com\/wp-json\/wp\/v2\/tags\/1738","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/punchdrunkgamer.com\/wp-json\/wp\/v2\/tags"}],"about":[{"href":"https:\/\/punchdrunkgamer.com\/wp-json\/wp\/v2\/taxonomies\/post_tag"}],"wp:post_type":[{"href":"https:\/\/punchdrunkgamer.com\/wp-json\/wp\/v2\/posts?tags=1738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}