youtubePlayerModel->newestVids('15'); $return = ''; if (!empty($data)) { foreach ($data as $row) { $videoId = $row['contentDetails']; $videoId = $videoId['videoId']; $title = $this->youtubePlayerModel->getInfos($videoId)['title']; if ($id == $videoId) { $return .= '
  • ' . $title . '
    ' . $title . '
  • '; } else { $return .= '
  • ' . $title . '
    ' . $title . '
  • '; } // if($id == $videoId) { // $return .= '' .$title. ''; // } else { // $return .= '' .$title. ''; // } } } else { $return = null; } return $return; } public function newestVids($vidCount) { $data = $this->db->query('SELECT * FROM social_posts WHERE post_plattform = \'YouTube\' ORDER BY post_date DESC LIMIT ?', [$vidCount])->result_array(); if (!empty($data)) { return $data; } else { return null; } } public function getInfos($id) { $data = json_decode(@file_get_contents('https://www.googleapis.com/youtube/v3/videos?part=snippet%2Cstatistics&hl=de&id=' . $id . '®ionCode=de&key=AIzaSyAZi6W9FODqd-bjlmV0sGJ8vjvSgFNTXVM'), true)['items']; $data = $data[0]; $infos = $data['snippet']; $stats = $data['statistics']; $return = []; $return['title'] = $infos['title']; $description = htmlspecialchars($infos['description']); $descriptionList = explode(' ', $description); $description = ''; foreach ($descriptionList as $item) { if (isset(parse_url($item)['scheme']) && isset(parse_url($item)['host'])) { $description .= '' . $item . ' '; } else { if ($infos['channelTitle'] == 'KingOfDog') { $items1 = ['✔️', '➕', '©']; $items2 = ['

    ✔️', '
    ➕', '
    ©']; $description .= str_replace($items1, $items2, $item) . ' '; } else { $description .= $item . ' '; } } } $return['description'] = $description; $published = strtotime($infos['publishedAt']); $return['published'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$published"), $_SESSION['site_lang']); $return['channelName'] = $infos['channelTitle']; $return['channelUrl'] = 'http://youtube.com/channel/' . $infos['channelId']; $return['views'] = number_format($stats['viewCount'], 0, ',', '.'); $return['likes'] = $stats['likeCount']; $return['dislikes'] = $stats['dislikeCount']; $return['comments'] = number_format($stats['commentCount'], 0, ',', '.'); $rateCount = intval($return['likes']) + intval($return['dislikes']); if (intval($return['likes']) > 0 && intval($return['dislikes']) > 0) { $return['likeWidth'] = intval($return['likes']) / $rateCount * 100; $return['dislikeWidth'] = intval($return['dislikes']) / $rateCount * 100; $return['grayWidth'] = 0; } elseif (intval($return['likes']) == 0 && intval($return['dislikes']) == 0) { $return['likeWidth'] = 0; $return['dislikeWidth'] = 0; $return['grayWidth'] = 100; } elseif (intval($return['likes']) == 0) { $return['likeWidth'] = 0; $return['dislikeWidth'] = 100; $return['grayWidth'] = 0; } else { $return['likeWidth'] = 100; $return['dislikeWidth'] = 0; $return['grayWidth'] = 0; } $return['thumbnails'] = $infos['thumbnails']; return $return; } public function checkVideo($videoID) { $data = json_decode(@file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=" . $videoID . "&key=AIzaSyAZi6W9FODqd-bjlmV0sGJ8vjvSgFNTXVM")); return $data->pageInfo->totalResults !== 0; } }