1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- var http = require('http');
- var request = require('request');
- var fs = require('fs');
- var url = require('url');
- var ljConst = require("./const/LjConst.js");
- var CourseDown = require("./CourseDown");
- var async = require("async");
- var express = require('express');
- var app = express();
- //引入工具类
- var logHelper = require("./helper/LjLogHelper.js");
- var httpHelper = require("./helper/LjHttpHelper");
- var fileHelper = require("./helper/LjFileHelper");
- var apiHelper = require("./helper/LjApiHelper");
- var ljStringHelper = require("./helper/LjStringHelper");
- var videoUrl1 = 'https://efunvideo.ai160.com/vs2m/001/00101002/00101002002/00101002002.m3u8';
- var videoUrl2 = 'https://efunvideo.ai160.com/vs2m/801/C-01-01-0004/J-03-02-000365/J-03-02-000365.m3u8';
- var imgUrl = 'https://efunimgs.ai160.com/resources/J/02/01/500001.jpg';
- //downloadFile(videoUrl1);
- //downloadFile(videoUrl2);
- //fileHelper.downloadFile(imgUrl);
- var result = JSON.parse(fs.readFileSync("./lessonInfo.json"));
- CourseDown.downCourse(result,function()
- {
- console.info("周现广");
- });
- /**
- * 下载
- */
- app.get('/down.do', function (req, res)
- {
- var arg = url.parse(req.url, true).query;
- var courseId = arg.courseId;
- var eid = arg.eid;
- var uid = arg.uid;
- var token = arg.token;
- var lessonId = arg.lessonId;
- //获取参数
- logHelper.info(arg);
- //校验参数
- if (ljStringHelper.isNull(courseId))
- {
- logHelper.info("null object of courseId");
- return "null object of courseId";
- }
- if (ljStringHelper.isNull(lessonId))
- {
- logHelper.info("null object of lessonId");
- return "null object of courseId";
- }
- if (ljStringHelper.isNull(eid))
- {
- logHelper.info("null object of eid");
- return "null object of eid";
- }
- if (ljStringHelper.isNull(uid))
- {
- logHelper.info("null object of uid");
- return "null object of uid";
- }
- if (ljStringHelper.isNull(token))
- {
- logHelper.info("null object of token");
- return "null object of token";
- }
- var opt = {};
- opt.eid = "100166681101003";
- opt.uid = "100166681101001";
- opt.token = token;
- opt.lessonId = "02279ace371a11e8af2000163e08bde8";
- courseId = "02549160371e11e88c3600163e08bde8";
- opt.url = apiHelper.getApiForCourse(lessonId, courseId, eid);
- httpHelper.request(opt, function (error, res, body)
- {
- logHelper.info(body);
- let obj = JSON.parse(body);
- logHelper.info(obj.code);
- var result = JSON.parse(body);
- CourseDown.downCourse(result);
- });
- });
- //启动监听
- app.listen(9095, function ()
- {
- logHelper.info("winBoxNode starting success");
- });
|