aboutsummaryrefslogtreecommitdiffstats
path: root/tools/processor.php
diff options
context:
space:
mode:
Diffstat (limited to 'tools/processor.php')
-rw-r--r--tools/processor.php27
1 files changed, 22 insertions, 5 deletions
diff --git a/tools/processor.php b/tools/processor.php
index 80461ba..f4e6d2b 100644
--- a/tools/processor.php
+++ b/tools/processor.php
@@ -16,9 +16,9 @@ if (strpos($baselink,$yturl) !== false){
}
parse_str($link, $urlData);
-$my_id = array_values($urlData)[0];
+$video_id = array_values($urlData)[0];
-$videoFetchURL = file_get_contents('https://www.youtube.com/get_video_info?html5=1&video_id='.$my_id);
+$videoFetchURL = file_get_contents("https://www.youtube.com/get_video_info?html5=1&video_id={$video_id}");
parse_str($videoFetchURL, $video_info);
$video_info = json_decode(json_encode($video_info));
@@ -29,12 +29,29 @@ $videoTitle = $video_info->title;
$videoAuthor = $video_info->author;
$videoDurationSecs = $video_info->length_seconds;
$videoDuration = secToDuration($videoDurationSecs);
-//$videoViews = $video_info->view_count;
$videoChannel = $video_info->ucid;
+// Begin_ViewCount
+$api_key = 'AIzaSyB9TLn5HvT614SjzBv8ZOj3wL2tc7PM3M4'; // API KEY only view_count
+$data_all = json_decode(file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id={$video_id}&key={$api_key}"));
+$video_view = $data_all->items[0]->statistics->viewCount;
+
+function bytes($a) {
+ $unim = array("","K","M","G","T","P");
+ $c = 0;
+ while ($a>=1000) {
+ $c++;
+ $a = $a/1000;
+ }
+ return number_format($a,($c ? 2 : 0),",",".")." ".$unim[$c];
+}
+
+$videoViews = bytes($video_view);
+// End_ViewCount
+
//change hqdefault.jpg to default.jpg for downgrading the thumbnail quality
-$videoThumbURL = "https://i1.ytimg.com/vi/{$my_id}/hqdefault.jpg";
-$librethumb = "https://i1.ytimg.com/vi/{$my_id}/maxresdefault.jpg";
+$videoThumbURL = "https://i1.ytimg.com/vi/{$video_id}/hqdefault.jpg";
+$librethumb = "https://i1.ytimg.com/vi/{$video_id}/maxresdefault.jpg";
if (!isset($video_info->url_encoded_fmt_stream_map)) {
die('No data found');