Skip to content
Extraits de code Groupes Projets
Valider 45d858b4 rédigé par ZeyuC's avatar ZeyuC
Parcourir les fichiers

Merge branch 'feature-youtubeApi' into develop

parents 65b40cfc 2d57b9e9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -5,13 +5,12 @@
* Date: 2018/11/18
* Time: 16:16
*/
require '../vendor/autoload.php';
include '../vendor/autoload.php';
$setting = array(
'key' => 'AIzaSyAg1Jz2Zxlna4sLJTE8BNpQlN2vSETqcHA'
);
function searchByKey($keyword){
global $setting;
$youtube = new Madcoda\Youtube\Youtube($setting);
......@@ -62,3 +61,133 @@ function getChannelViewCount($id) {
return intval($res->statistics->viewCount);
}
function getVideoInfoById($id){
global $setting;
$youtube = new Madcoda\Youtube\Youtube($setting);
$res = $youtube->getVideoInfo($id);
return $res;
}
/**
* Search Get the name of the a video by ID
* @param Id
* @return the Name of a video
*/
function getVideoNameById($id){
global $setting;
$youtube = new Madcoda\Youtube\Youtube($setting);
$res = $youtube->getVideoInfo($id)->snippet->title;
return $res;
}
/**
* Search Get the Icon of the a video by ID
* @param Id
* @return the Icon of a video
*/
function getVideoIconById($id){
global $setting;
$youtube = new Madcoda\Youtube\Youtube($setting);
$res = $youtube->getVideoInfo($id)->snippet->thumbnails->default->url;
return $res;
}
/**
* Search Get the ViewCount of the a video by ID
* @param Id
* @return the viewCount of a video
*/
function getVideoViewCountById($id){
global $setting;
$youtube = new Madcoda\Youtube\Youtube($setting);
$res = $youtube->getVideoInfo($id)->statistics->viewCount;
return $res;
}
/**
* Search Get the most populare count videos's id in a channel by channelID
* @param $channelId
* @param $count
* @return an array including the id of the most populare count videos
*/
function getCountTopVideos($channelId,$count)
{
global $setting;
$youtube = new Madcoda\Youtube\Youtube($setting);
$vid = $youtube->searchChannelVideos('',$channelId,$count, "viewCount");
$CountList = array();
for($i=0;$i<$count ; $i++)
{
$CountList[$i] = getVideoInfoById($vid[$i]->id->videoId)->id;
}
return $CountList;
}
/**
* Get the viewcount of the recent count videos by channelID
* @param $channelId
* @param $count
*/
function getviewCountOfRecentVideo($channelId,$count)
{
global $setting;
$youtube = new Madcoda\Youtube\Youtube($setting);
$vid = $youtube->searchChannelVideos('',$channelId,$count,"date");
$ViewCountList = array();
for($i=0; $i<$count ; $i++)
{
$id = $vid[$i]->id->videoId;
$ViewCountList[$i] = getVideoInfoById($id)->statistics->viewCount;
}
return $ViewCountList;
}
/**
* Get the Likecount of the recent count videos by channelID
* @param $channelId
* @param $count
*/
function getDislikeCountOfRecentVideo($channelId,$count)
{
global $setting;
$youtube = new Madcoda\Youtube\Youtube($setting);
$vid = $youtube->searchChannelVideos('',$channelId,$count);
$CountList = array();
for($i=0;$i<$count ; $i++)
{
$CountList[$i] = (getVideoInfoById($vid[$i]->id->videoId))->statistics->dislikeCount;
}
return $CountList;
}
/**
* Search Get the DisLikecount of the recent count videos by channelID
* @param $channelId
* @param $count
*/
function getLikeCountOfRecentVideo($channelId,$count)
{
global $setting;
$youtube = new Madcoda\Youtube\Youtube($setting);
$vid = $youtube->searchChannelVideos('',$channelId,$count);
$CountList = array();
for($i=0;$i<$count ; $i++)
{
$CountList[$i] = (getVideoInfoById($vid[$i]->id->videoId))->statistics->likeCount;
}
return $CountList;
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter