Coder Social home page Coder Social logo

node-tv-source's Introduction

使用nodejs搭建服务器,获取企鹅直播斗鱼TV直播源并网页在线播放

github

在线demo

由来

作为一个前端,不用用nodejs真的是浪费啊

需求来源为平时看直播斗鱼什么的网页太卡,还偷偷挖矿

所有萌生了自己搞的想法(能看就行)

思路

其实这玩意很简单,大致就分两块

  • 直播源
  • 播放

直播源直接去它们网站找即可,然后就是播放,很多播放器都支持的

如果是网页的话可以用大神的flv.js

至于上面提到的nodejs服务端接口,是因为获取直播源的接口会有跨域等等限制,浏览器端无法完成,所以需要使用nodejs搭建服务端完成

使用步骤

npm i express request
node server.js

打开网页localhost:2901 即可体验

nodejs服务端搭建

使用express便捷搭建,代码也很简洁

var express = require('c');
var request = require('request');
var app = express();
app.get('/getUrl', function (req, res, next) {
  res.header('Access-Control-Allow-Origin', '*'); // 跨域
  if (req.method == 'OPTIONS') {
    res.send(200);
  }
  request({}, function (error, response, body) {
    res.json({})
  });
});

//定义端口
var server = app.listen(2901, function () {
  console.log('启动成功!端口号:' + 2901);
})

node-tv-source's People

Contributors

chu295 avatar

Watchers

 avatar

Forkers

sun520999

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.