youtube-api
Advanced tools
Comparing version 1.4.1 to 2.0.0
{ | ||
"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 @@ }); |
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
14725
190
5
+ Addedcall-bind@1.0.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgoogleapis@5.2.1(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedqs@6.1.26.13.0(transitive)
+ Addedrequest@2.72.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstring-template@1.0.0(transitive)
+ Addedurl@0.11.4(transitive)
- Removedajv@6.12.6(transitive)
- Removedasn1@0.1.11(transitive)
- Removedassert-plus@0.1.5(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedbl@1.0.3(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedctype@0.5.3(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgoogleapis@2.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@0.11.01.2.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.10.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@5.2.16.5.3(transitive)
- Removedrequest@2.65.02.88.2(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
Updatedgoogleapis@^5.2.1