Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yt-api

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yt-api - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

typings/index.d.ts

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,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc