From b7eb2d238e19b6fd4ce7e811b7eee69fa6a2e84f Mon Sep 17 00:00:00 2001 From: lyz05 <294068487@qq.com> Date: Tue, 8 Nov 2022 17:09:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=99=90=E5=88=B6=E6=97=A7=E5=86=85?= =?UTF-8?q?=E5=AD=98=E9=83=A8=E5=88=86=E7=9A=84=E6=9C=80=E5=A4=A7=E5=86=85?= =?UTF-8?q?=E5=AD=98=E5=A4=A7=E5=B0=8F=E4=B8=BA200M=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- routes/api/iqiyi.js | 3 ++- routes/api/tencentvideo.js | 3 ++- routes/api/youku.js | 3 ++- routes/danmaku.js | 8 +++++--- test/App.test.js | 4 +++- utils/memory.js | 14 ++++++++++++++ 7 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 utils/memory.js diff --git a/package.json b/package.json index 7b5f1b2..d5dc48a 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "0.1.0", "private": true, "scripts": { - "start": "node --max-old-space-size=128 ./bin/www", - "dev": "nodemon --max-old-space-size=128 ./bin/www", + "start": "node --max-old-space-size=200 ./bin/www", + "dev": "nodemon --max-old-space-size=200 ./bin/www", "test": "nyc -a mocha --recursive" }, "dependencies": { diff --git a/routes/api/iqiyi.js b/routes/api/iqiyi.js index c2c0833..0e97f5d 100644 --- a/routes/api/iqiyi.js +++ b/routes/api/iqiyi.js @@ -8,7 +8,8 @@ function Iqiyi() { this.name = '爱奇艺' this.domain = 'iqiyi.com' this.example_urls = [ - 'https://www.iqiyi.com/v_19rr1lm35o.html' + 'https://www.iqiyi.com/v_19rr1lm35o.html', //api lens 11 + 'https://www.iqiyi.com/v_1wozsa91cfs.html' //api lens 9 ]; this.resolve = async (url) => { diff --git a/routes/api/tencentvideo.js b/routes/api/tencentvideo.js index f6bcf59..fa97b9c 100644 --- a/routes/api/tencentvideo.js +++ b/routes/api/tencentvideo.js @@ -9,7 +9,8 @@ function Tencentvideo() { this.domain = 'v.qq.com' this.example_urls = [ 'https://v.qq.com/x/cover/mzc002003pn34qk/u3319i5s3jt.html', - 'https://v.qq.com/x/cover/53q0eh78q97e4d1/x00174aq5no.html'//api lens 50 + 'https://v.qq.com/x/cover/53q0eh78q97e4d1/x00174aq5no.html',//api lens 50 + 'https://v.qq.com/x/cover/mzc00200fph94nw/l00448ijvve.html',//api lens 91 ]; this.resolve = async (url) => { diff --git a/routes/api/youku.js b/routes/api/youku.js index 97e7d78..8fb7237 100644 --- a/routes/api/youku.js +++ b/routes/api/youku.js @@ -9,7 +9,8 @@ function Youku() { this.name = '优酷' this.domain = 'v.youku.com' this.example_urls = [ - 'https://v.youku.com/v_show/id_XNTE5NjUxNjUyOA==.html' + 'https://v.youku.com/v_show/id_XNTE5NjUxNjUyOA==.html', + 'https://v.youku.com/v_show/id_XMTc1OTE4ODI5Ng==.html' ]; this.get_tk_enc = async () => { diff --git a/routes/danmaku.js b/routes/danmaku.js index ab93a41..9569d41 100644 --- a/routes/danmaku.js +++ b/routes/danmaku.js @@ -1,14 +1,15 @@ const express = require('express'); const axios = require('axios'); const router = express.Router(); -const { bilibili, mgtv, tencentvideo, youku, iqiyi } = require('../routes/api/base'); +const { bilibili, mgtv, tencentvideo, youku, iqiyi } = require('./api/base'); const list = [bilibili, mgtv, tencentvideo, youku, iqiyi]; +const memory = require('../utils/memory') function getscheme(req) { return req.headers['x-forwarded-proto'] || req.protocol; } -async function build_response(url, download) { +async function build_response(url) { try { const res = await axios.get(url) } catch (error) { @@ -37,7 +38,8 @@ router.get('/', async function (req, res, next) { } else { url = req.query.url; download = (req.query.download === 'on'); - ret = await build_response(url, download) + ret = await build_response(url) + memory() //显示内存使用量 if (ret.msg !== 'ok') { res.status(403).send(ret.msg) } else if (download) { diff --git a/test/App.test.js b/test/App.test.js index c010d4f..645ad65 100644 --- a/test/App.test.js +++ b/test/App.test.js @@ -4,7 +4,6 @@ let app = require('../app'); const { bilibili, mgtv, tencentvideo, youku, iqiyi } = require('../routes/api/base'); const list = [bilibili, mgtv, tencentvideo, youku, iqiyi]; -let should = chai.should(); chai.use(chaiHttp); describe('App', () => { @@ -77,4 +76,7 @@ describe('App', () => { }); }); }); + describe('airportsub modules',()=>{ + + }); }); \ No newline at end of file diff --git a/utils/memory.js b/utils/memory.js new file mode 100644 index 0000000..90c6479 --- /dev/null +++ b/utils/memory.js @@ -0,0 +1,14 @@ +const {filesize} = require('filesize') + +const print = function () { + const memoryUsage = process.memoryUsage(); + + console.log(JSON.stringify({ + rss: filesize(memoryUsage.rss),//RAM 中保存的进程占用的内存部分,包括代码本身、栈、堆。 + heapTotal: filesize(memoryUsage.heapTotal),//堆中总共申请到的内存量。 + heapUsed: filesize(memoryUsage.heapUsed),//堆中目前用到的内存量,判断内存泄漏我们主要以这个字段为准。 + external: filesize(memoryUsage.external),// V8 引擎内部的 C++ 对象占用的内存。 + })); +} + +module.exports = print \ No newline at end of file