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

youtube-api

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

youtube-api - npm Package Compare versions

Comparing version 1.4.1 to 2.0.0

12

package.json
{
"name": "youtube-api",
"version": "1.4.1",
"version": "2.0.0",
"description": "A Node.JS module, which provides an object oriented wrapper for the Youtube v3 API.",

@@ -30,3 +30,3 @@ "main": "lib/index.js",

"dependencies": {
"googleapis": "^2.1.3"
"googleapis": "^5.2.1"
},

@@ -37,3 +37,9 @@ "homepage": "https://github.com/IonicaBizau/youtube-api",

},
"devDependencies": {},
"devDependencies": {
"bug-killer": "^4.2.2",
"lien": "^1.0.1",
"opn": "^4.0.1",
"pretty-bytes": "^3.0.1",
"r-json": "^1.2.2"
},
"scripts": {

@@ -40,0 +46,0 @@ "test": "echo \"Error: no test specified\" && exit 1"

# youtube-api [![PayPal](https://img.shields.io/badge/%24-paypal-f39c12.svg)][paypal-donations] [![Version](https://img.shields.io/npm/v/youtube-api.svg)](https://www.npmjs.com/package/youtube-api) [![Downloads](https://img.shields.io/npm/dt/youtube-api.svg)](https://www.npmjs.com/package/youtube-api) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)
# youtube-api
[![PayPal](https://img.shields.io/badge/%24-paypal-f39c12.svg)][paypal-donations] [![AMA](https://img.shields.io/badge/ask%20me-anything-1abc9c.svg)](https://github.com/IonicaBizau/ama) [![Version](https://img.shields.io/npm/v/youtube-api.svg)](https://www.npmjs.com/package/youtube-api) [![Downloads](https://img.shields.io/npm/dt/youtube-api.svg)](https://www.npmjs.com/package/youtube-api) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)
> A Node.JS module, which provides an object oriented wrapper for the Youtube v3 API.

@@ -31,17 +33,16 @@

// Dependencies
var Youtube = require("youtube-api")
, Fs = require("fs")
, ReadJson = require("r-json")
, Lien = require("lien")
, Logger = require("bug-killer")
, Opn = require("opn")
;
const Youtube = require("youtube-api")
, fs = require("fs")
, readJson = require("r-json")
, Lien = require("lien")
, Logger = require("bug-killer")
, opn = require("opn")
, prettyBytes = require("pretty-bytes")
;
// Constants
// I downloaded the file from OAuth2 -> Download JSON
const CREDENTIALS = ReadJson("./credentials.json");
const CREDENTIALS = readJson(`${__dirname}/credentials.json`);
// Init lien server
var server = new Lien({
let server = new Lien({
host: "localhost"

@@ -54,3 +55,3 @@ , port: 5000

// https://developers.google.com/youtube/v3/guides/moving_to_oauth#service_accounts
var oauth = Youtube.authenticate({
let oauth = Youtube.authenticate({
type: "oauth"

@@ -62,3 +63,3 @@ , client_id: CREDENTIALS.web.client_id

Opn(oauth.generateAuthUrl({
opn(oauth.generateAuthUrl({
access_type: "offline"

@@ -69,8 +70,18 @@ , scope: ["https://www.googleapis.com/auth/youtube.upload"]

// Handle oauth2 callback
server.page.add("/oauth2callback", function (lien) {
Logger.log("Trying to get the token using the following code: " + lien.search.code);
oauth.getToken(lien.search.code, function(err, tokens) {
if (err) { lien(err, 400); return Logger.log(err); }
server.addPage("/oauth2callback", lien => {
Logger.log("Trying to get the token using the following code: " + lien.query.code);
oauth.getToken(lien.query.code, (err, tokens) => {
if (err) {
lien.lien(err, 400);
return Logger.log(err);
}
Logger.log("Got the tokens.");
oauth.setCredentials(tokens);
Youtube.videos.insert({
lien.end("The video is being uploaded. Check out the logs in the terminal.");
var req = Youtube.videos.insert({
resource: {

@@ -92,8 +103,12 @@ // Video title and description

, media: {
body: Fs.createReadStream("video.mp4")
body: fs.createReadStream("index.mpeg")
}
}, function (err, data) {
if (err) { return lien.end(err, 400); }
lien.end(data);
}, (err, data) => {
console.log("Done.");
process.exit();
});
setInterval(function () {
Logger.log(`${prettyBytes(req.req.connection._bytesDispatched)} bytes uploaded.`);
}, 250);
});

@@ -100,0 +115,0 @@ });

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