A simple nodejs library for youku authentication and upload.
npm install anytv-node-youku-uploader --save
- Login with Youku OAuth2
- Upload Videos
On your index.js / server.js / app.js, register your database using a key.
import Youku from 'anytv-node-youku-uploader';
const config = {
client_id: 'YOUR CLIENT ID',
client_secret: 'YOUR CLIENT SECRET',
redirect_uri: 'YOUR REDIRECT URI',
slice_size: 4096 //optional
};
//get auth class
const auth = Youku.auth;
//initialize auth
const youku = new auth(config);
//authorize a user
//1. get auth url
const authurl = youku.get_auth_url(state);
//2. redirect user to auth url
//3. get access token, accepts `authorization_code` and `refresh_token` as grant type
youku.get_access_token('GRANT TYPE', 'IDENTIFIER', (err, result) => {
//4. upload!
const metadata = {
title: 'sample123',
description: 'sample description123',
tags: 'sample anytv youku 123',
file_name: 'sample.avi',
filepath: 'FILE PATH'
};
youku.upload(metadata, (err, result) => {
//this is the callback after uploading
}, (progress) => {
//this is optional, do something with the progress/status
});
//optional: get user info
youku.get_user_info((err, result) => {
//do whatever u want with the result
})
});
to follow
Install the tools needed:
npm install babel -g
npm install esdoc -g
npm install mocha -g
npm install --dev
To compile the ES6 source code to ES5:
babel src --watch --out-dir lib
To generate the docs:
npm run docs
npm test
npm run coverage
Then open coverage/lcov-report/index.html.
MIT