Comparing version 0.0.5 to 0.0.6
28
index.js
@@ -1,16 +0,16 @@ | ||
const request = require("request"); | ||
const snekfetch = require("snekfetch"); | ||
const moment = require("moment"); | ||
const utils = require("./Utils.js"); | ||
module.exports = class API { | ||
constructor(authkey) { | ||
this.key = authkey; | ||
class YouTubeAPI { | ||
constructor(apiKey) { | ||
this.key = apiKey; | ||
} | ||
async getVideoInfo(videoID, callback) { | ||
request(`https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics,liveStreamingDetails,contentDetails&id=${videoID}&key=${this.key}`, function (err, res, body) { | ||
let json = JSON.parse(body); | ||
async getVideo(id) { | ||
return new Promise(async (res, rej) => { | ||
let apiResponse = await snekfetch.get(`https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics,liveStreamingDetails,contentDetails&id=${id}&key=${this.key}`); | ||
let json = JSON.parse(apiResponse.text); | ||
let data = json.items[0]; | ||
if(!data) throw new TypeError("Invalid video id provided!"); | ||
if(!data) return rej("The provided video id was invalid!"); | ||
let livestream; | ||
@@ -20,6 +20,6 @@ if(data.snippet.liveBroadcastContent === "none") livestream = "No"; | ||
if(data.snippet.liveBroadcastContent === "upcoming") livestream = "Upcoming live stream!"; | ||
let info = { | ||
return res(JSON.stringify({ | ||
videoID: data.id, | ||
url: `https://www.youtube.com/watch?v=${data.id}`, | ||
title: data.snippet.title ? data.snippet.title : "No title found!", | ||
title: data.snippet.title, | ||
channel: { | ||
@@ -48,4 +48,3 @@ id: data.snippet.channelId, | ||
} | ||
} | ||
callback(info); | ||
})); | ||
}); | ||
@@ -98,2 +97,3 @@ } | ||
} | ||
} | ||
} | ||
exports.YT_API = YouTubeAPI; |
{ | ||
"name": "yt-api", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "", | ||
"main": "index.js", | ||
"types": "typings/index.ts", | ||
"scripts": { | ||
@@ -17,5 +18,5 @@ "test": "echo \"Error: no test specified\" && exit 1" | ||
"moment": "^2.20.1", | ||
"request": "^2.83.0", | ||
"snekfetch": "^3.6.4", | ||
"ytdl-core": "^0.18.7" | ||
} | ||
} |
@@ -31,3 +31,3 @@ # Welcome to the yt-api a light weight and easy to use api. | ||
livestream: //Is it a livestream?, | ||
category: //The category its in, | ||
category: //The categoryId that the videos in, | ||
thumbnail: //The videos thumbnail, | ||
@@ -34,0 +34,0 @@ description: //The video's description, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15103
5
151
+ Addedsnekfetch@^3.6.4
+ Addedsnekfetch@3.6.4(transitive)
- Removedrequest@^2.83.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.13.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)