Code Monkey home page Code Monkey logo

axeengine's Introduction

#AxeEngine

NPM IMAGE

a javascript library for resolving the real URL of online videos which works in both Node.js and browser.

中文说明和如何取得视频ID的相关问题见wiki

Get it

> npm install axeengine

Build

> git clone https://github.com/SEIAROTg/AxeEngine.git
> cd AxeEngine
> npm install
> grunt

Output files will be in <git dir>/dest/.

Test

To run test, simply run <git dir>/dest/test.js with Node.js. Make sure test.js is in the same directory as AxeEngine.js.

Load

AxeEngine works in both Node.js and browser. But actually, there can be various of environments, such as Node.js application, web page, and browser extension. Different environment may have different HTTP interface. Therefore, you need to pass HTTP handler to AxeEngine when loading.

After loading, AxeEngine will be in the global namespace (global in Node.js, window in browser).

In Node.js

var loadAxeEngine = require('axeengine');
loadAxeEngine({
    httpGet: < your HTTP handler >
});

Your HTTP handler should be a function that accepts two arguments URL and encoding and returns a Promise object which return HTTP Response Body when resolved.

In Browser

// loadAxeEngine will be automatically add into window object when including AxeEngine.js
// Suppose you have no permission to make cross-domain request
var jsonp = < your jsonp handler >;
loadAxeEngine({
    jsonp: < your jsonp handler >,
});

Your jsonp handler should accept the same arguments as HTTP handler and return a Promise object which return parsed JSON Object when resolved.

If you have permission to make cross-domain request, or do not need cross-domain, you can also pass httpGet as in Node.js.

API

Create resolver

var resolver = AxeEngine.resolverManager.create(<resolver name>, <video id>);
  • <resolver name> is the registration name of resolver. See the list at bottom.
  • <video id> is the id of the video in its site. It may be in different format in different sites and resolvers.

Get video title

resolver.getTitle().then(function(title){
    // ...
});

resolver.getTitle takes no arguments and return a Promise which returns the title in string when resolved.

Get versions

A video may have different versions in some sites.

List versions

resolver.listVersion().then(function(list){
    // ...
});

resolver.listVersion takes no arguments and return a Promise which returns a array of versions.

Get current version

resolver.listVersion().then(function(list){
    index = resolver.getCurrentVersion();
    version = list[index];
});

resolver.getCurrentVersion returns current version index in version list.

Switch version

resolver.switchVersion(< index >).then(function(){
    // ...
});
  • <index> is the index of the new version in the version list

Get qualities

A video usually have multiple qualities.

List qualities

resolver.listQuality().then(function(list){
    // ...
});

resolver.listQuality takes no arguments and return a Promise which returns a array of qualities.

Get current version

resolver.listVersion().then(function(list){
    index = resolver.getCurrentVersion();
    version = list[index];
});

resolver.getCurrentVersion returns current version index in version list.

Switch version

resolver.switchVersion(< index >).then(function(){
    // ...
});
  • <index> is the index of the new version in the version list

LICENSE

GNU Affero General Public License 3.0

Supported Site List

Site Resolver name M3U multi-version multi-quality
v.youku.com youku Y Y Y
tv.sohu.com sohu N - Y
my.tv.sohu.com sohu N - Y
www.letv.com letv Y - Y
www.iqiyi.com iqiyi N - Y

axeengine's People

Contributors

seiarotg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

axeengine's Issues

发布至npm

能否将这个库发布到npm上 用的时候需要自己clone再compile略不方便

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.