Skip to content
This repository was archived by the owner on Oct 27, 2021. It is now read-only.

Commit 7dc63ba

Browse files
Add files via upload
1 parent 95b136d commit 7dc63ba

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

docready.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$(document).ready(function(){
2+
var keyword = '[ HOW TO ] HACK ANDROID APPS USING MODDED PLAYSTORE ';
3+
searchVideosCode(keyword);
4+
videosCountCode(videoId[0]);
5+
displayVideosCount();
6+
});

index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<html>
2+
<head>
3+
<title>YouTube Count Views,Likes,Dislikes,Comments,Favorites of a Video</title>
4+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
5+
<script src="https://rawgit.com/DevelopersWork/CodingWithAPIs/SimpleYTVSE-VideoEmbed/script.js"></script>
6+
<script src="auth.js"></script>
7+
<script src="script.js"></script>
8+
<script async src="docready.js"></script>
9+
</head>
10+
<body>
11+
<section id="display">
12+
13+
</section>
14+
</body>
15+
</html>

script.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
var videoViewCount = [],videoCommentCount = [],
2+
videoLikeCount = [],videoDislikeCount = [],videoFavoriteCount = [];
3+
4+
function getNewVideo(){
5+
document.getElementById('display').innerHTML = '';
6+
this.keyword = prompt('Enter Video Id/Title/keyword','Developers@Work');
7+
searchVideosCode(this.keyword);
8+
videosCountCode(videoId[0]);
9+
displayVideosCount();
10+
}
11+
12+
function videosCountCode(YouTubeVideoId , i=0){
13+
var API_KEY = API();
14+
$.ajax({
15+
url:'https://www.googleapis.com/youtube/v3/videos',
16+
data:{
17+
key:API_KEY,
18+
part:'statistics',
19+
id:YouTubeVideoId
20+
},
21+
async:false,
22+
success:function(data){
23+
var temp = data.items[0];
24+
videoViewCount[i] = temp.statistics.viewCount;
25+
videoCommentCount[i] = temp.statistics.commentCount;
26+
videoLikeCount[i] = temp.statistics.likeCount;
27+
videoDislikeCount[i] = temp.statistics.dislikeCount;
28+
videoFavoriteCount[i] = temp.statistics.favoriteCount;
29+
}
30+
});
31+
}
32+
33+
function displayVideosCount(i=0){
34+
$('#display').append('\
35+
<div id="video'+videoId[i]+'">\
36+
<img src="'+videoThumbnail[i]+'">\
37+
<h1 id="'+videoTitle[i]+'" onClick="getNewVideo()">'+videoTitle[i]+'</h1>\
38+
<h2 id="'+videoId[i]+'views">Video Views : '+videoViewCount[i]+'</h2>\
39+
<h2 id="'+videoId[i]+'likes">Likes: '+videoLikeCount[i]+'</h2>\
40+
<h2 id="'+videoId[i]+'comments">Comments : '+videoCommentCount[i]+'</h2>\
41+
<h2 id="'+videoId[i]+'dislikes">Dislikes : '+videoDislikeCount[i]+'</h2>\
42+
</div>\
43+
');
44+
}

0 commit comments

Comments
 (0)