|
@@ -74,7 +74,7 @@
|
|
|
</vxe-column>
|
|
|
<vxe-column field="vcodec" title="视频编码" width="120"></vxe-column>
|
|
|
<vxe-column field="acodec" title="音频编码" width="120"></vxe-column>
|
|
|
- <vxe-column field="status" title="下载状态" width="140">
|
|
|
+ <vxe-column field="status" title="状态" width="140">
|
|
|
<template #default="{ row }">
|
|
|
<template v-if="row.status == '1'">
|
|
|
<i class="el-icon-info" style="font-size: 16px; color: #999;"></i>
|
|
@@ -94,9 +94,9 @@
|
|
|
</template>
|
|
|
</template>
|
|
|
</vxe-column>
|
|
|
- <vxe-column title="操作" width="150">
|
|
|
+ <vxe-column title="操作" width="100">
|
|
|
<template #default="{ row, rowIndex }">
|
|
|
- <el-button v-if="row.urlList && row.urlList.length > 0" type="danger" size="mini" plain @click="copy(rowIndex)">复制</el-button>
|
|
|
+ <!-- <el-button v-if="row.urlList && row.urlList.length > 0" type="danger" size="mini" plain @click="copy(rowIndex)">复制</el-button> -->
|
|
|
<el-button :loading="row.loading" type="danger" size="mini" plain @click="downloadVideo(rowIndex)">下载</el-button>
|
|
|
</template>
|
|
|
</vxe-column>
|
|
@@ -161,15 +161,15 @@
|
|
|
</el-dialog>
|
|
|
|
|
|
<!-- 抖音下载 -->
|
|
|
- <el-dialog title="抖音视频下载" :visible.sync="dyModal" width="300px" :close-on-click-modal="false" :close-on-press-escape="false">
|
|
|
- <el-divider content-position="left">
|
|
|
- 普通下载
|
|
|
+ <el-dialog title="视频下载" :visible.sync="dyModal" width="300px" :close-on-click-modal="false" :close-on-press-escape="false">
|
|
|
+ <el-divider content-position="left" v-if="commonUrl">
|
|
|
+ 浏览器下载
|
|
|
<el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="点击复制地址到浏览器中打开">
|
|
|
<i class="el-icon-info" slot="reference" style="margin-left: 10px; color: #F56C6C;"></i>
|
|
|
</el-popover>
|
|
|
</el-divider>
|
|
|
<div style="text-align: center;">
|
|
|
- <el-button v-if="commonUrl" size="small" round type="primary" @click="copyText(commonUrl)">下载地址</el-button>
|
|
|
+ <el-button v-if="commonUrl" size="small" round type="primary" @click="copyText(commonUrl)">复制下载地址</el-button>
|
|
|
</div>
|
|
|
|
|
|
<el-divider content-position="left">
|
|
@@ -180,10 +180,20 @@
|
|
|
</el-divider>
|
|
|
<div style="text-align: center;">
|
|
|
<div v-for="(item, index) in thunderUrl" :key="index">
|
|
|
- <el-button size="small" round type="primary" @click="copyText(item)" style="margin-bottom: 15px;">下载地址{{index+1}}</el-button>
|
|
|
+ <el-button size="small" round type="primary" @click="copyText(item)" style="margin-bottom: 15px;">复制下载地址{{index+1}}</el-button>
|
|
|
</br>
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <el-divider content-position="left">
|
|
|
+ 普通下载
|
|
|
+ <el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="使用软件下载可能会失败,建议使用浏览器/迅雷下载">
|
|
|
+ <i class="el-icon-info" slot="reference" style="margin-left: 10px; color: #F56C6C;"></i>
|
|
|
+ </el-popover>
|
|
|
+ </el-divider>
|
|
|
+ <div style="text-align: center;">
|
|
|
+ <el-button v-if="selectIndex > -1" :loading="videoList[selectIndex].loading" size="small" round type="primary" @click="downloadVideo(selectIndex, true)" style="margin-bottom: 15px;">点击下载</el-button>
|
|
|
+ </div>
|
|
|
</el-dialog>
|
|
|
|
|
|
</el-main>
|
|
@@ -211,6 +221,7 @@
|
|
|
const axios = require('axios');
|
|
|
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
|
|
|
const listNameArr = ['douyin','kuaishou','weibo','','','','','', '' ,'common'];
|
|
|
+ import { VxeTooltip } from 'vxe-table';
|
|
|
|
|
|
let separator = '';
|
|
|
if (os.platform == 'linux') {
|
|
@@ -226,7 +237,7 @@
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- selectIndex: 0,
|
|
|
+ selectIndex: -1,
|
|
|
usageTimes: 3,
|
|
|
tipsModal: false,
|
|
|
tipsDesc: "暂无下载权限,请开通VIP会员使用",
|
|
@@ -297,9 +308,33 @@
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ // 初始化开发者设置
|
|
|
+ this.$utils.setStorage('headless', 1);
|
|
|
+ this.$utils.setStorage('waitUntil', 'networkidle2');
|
|
|
+
|
|
|
},
|
|
|
methods: {
|
|
|
-
|
|
|
+ // 实时获取开发者设置
|
|
|
+ initDevelop(){
|
|
|
+ let develop = {
|
|
|
+ headless: true,
|
|
|
+ waitUntil: 'networkidle2'
|
|
|
+ };
|
|
|
+ let n1 = this.$utils.getStorage('headless');
|
|
|
+ let n2 = this.$utils.getStorage('waitUntil');
|
|
|
+ if(n1){
|
|
|
+ if(n1 == 1){
|
|
|
+ develop.headless = true;
|
|
|
+ }else if(n1 == 2){
|
|
|
+ develop.headless = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(n2){
|
|
|
+ develop.waitUntil = n2;
|
|
|
+ }
|
|
|
+
|
|
|
+ return develop;
|
|
|
+ },
|
|
|
// 实时获取浏览器路径
|
|
|
initPath(){
|
|
|
let chromePath = puppeteer.executablePath().replace('win32-1', 'win64-1');
|
|
@@ -480,6 +515,7 @@
|
|
|
this.parseLoading = true;
|
|
|
this.tabLoading = true;
|
|
|
this.videoList = [];
|
|
|
+ this.selectIndex = -1;
|
|
|
let params = [
|
|
|
'--dump-json',
|
|
|
formatUrl
|
|
@@ -530,12 +566,12 @@
|
|
|
},
|
|
|
// 点击复制
|
|
|
copy(index){
|
|
|
- let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
- if (!authority) {
|
|
|
- this.tipsModal = true;
|
|
|
- this.tipsDesc = '暂无下载权限,请开通VIP会员使用';
|
|
|
- return false;
|
|
|
- }
|
|
|
+ // let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
+ // if (!authority) {
|
|
|
+ // this.tipsModal = true;
|
|
|
+ // this.tipsDesc = '暂无下载权限,请开通VIP会员使用';
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
|
|
|
this.commonUrl = '';
|
|
|
this.thunderUrl = [];
|
|
@@ -555,6 +591,10 @@
|
|
|
if(uitem.startsWith('https://www.douyin.com/')){
|
|
|
this.commonUrl = uitem;
|
|
|
}
|
|
|
+ if(!title){
|
|
|
+ title = '抖音视频';
|
|
|
+ }
|
|
|
+ // console.log(`AA`+uitem +`&filename=`+title+`.mp4ZZ`);
|
|
|
let urlBuffer = Buffer.from(`AA`+uitem +`&filename=`+title+`.mp4ZZ`).toString('base64');
|
|
|
this.thunderUrl.push('thunder://'+urlBuffer);
|
|
|
})
|
|
@@ -564,7 +604,7 @@
|
|
|
},
|
|
|
|
|
|
// 点击下载视频
|
|
|
- async downloadVideo(index){
|
|
|
+ async downloadVideo(index, flag){
|
|
|
this.selectIndex = index;
|
|
|
let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
if (!authority) {
|
|
@@ -574,75 +614,82 @@
|
|
|
}
|
|
|
this.tipsModal = false;
|
|
|
|
|
|
- let item = this.videoList[index];
|
|
|
- if (!fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName)) {
|
|
|
- fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName);
|
|
|
- }
|
|
|
- let newPath = this.downloadDir + separator + pjson.softInfo.softName;
|
|
|
-
|
|
|
- if(item.tag){ //抖音下载
|
|
|
- if(item.title){
|
|
|
- item.title = item.title.substring(0, 50);
|
|
|
- if(this.containsAnyChar(item.title)){ //判断是否含有特殊字符
|
|
|
- item.title = item.title.replace(/[\\|/|:|*|?|"|<|>||#|%|&|\s]/g, "");
|
|
|
- }
|
|
|
+ if(this.videoList[index].urlList && this.videoList[index].urlList.length > 0 && !flag && this.videoList[index].tag == 'douyin'){ // 浏览器解析出来的下载地址
|
|
|
+ this.copy(index);
|
|
|
+ }else{
|
|
|
+ let item = this.videoList[index];
|
|
|
+ if (!fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName)) {
|
|
|
+ fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName);
|
|
|
}
|
|
|
- let outputPath = newPath + separator + item.title + '[' + item.format_id + ']' + '.mp4';
|
|
|
- let url = item.urlList.length > 0 ? item.urlList[0] : '';
|
|
|
+ let newPath = this.downloadDir + separator + pjson.softInfo.softName;
|
|
|
|
|
|
- if(item.tag == 'douyin'){
|
|
|
- item.urlList.map(uitem => {
|
|
|
- if(uitem.startsWith('https://www.douyin.com/')){
|
|
|
- url = uitem;
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- item.status = '2';
|
|
|
- item.loading = true;
|
|
|
- await this.downloadImage(url, outputPath, item);
|
|
|
- item.loading = false;
|
|
|
- this.$forceUpdate();
|
|
|
- this.$message({message: '恭喜你,下载已完成!', type: 'success'});
|
|
|
- electronApi.call('showItemInfolder',[this.downloadDir + separator + pjson.softInfo.softName +'\\tty.tty']);
|
|
|
- return false;
|
|
|
- }else{
|
|
|
- // console.log(this.downloadUrl);
|
|
|
- let params = [
|
|
|
- '-f',
|
|
|
- item.format_id,
|
|
|
- '--force-overwrites',
|
|
|
- '-o',
|
|
|
- newPath + separator + '%(title).50s['+item.format_id+'].%(ext)s',
|
|
|
- this.downloadUrl
|
|
|
- ];
|
|
|
- item.status = '2';
|
|
|
- item.loading = true;
|
|
|
- this.$forceUpdate();
|
|
|
- electronApi.spawnExec(['dlp.exe', ...params],{
|
|
|
- stdout:(data) =>{
|
|
|
- let str = data.toString();
|
|
|
- const regexDuration = /[download].*? (.*?)%/;
|
|
|
- const res = regexDuration.exec(str);
|
|
|
- if(res && res[1]){
|
|
|
- item.percent = res[1];
|
|
|
- this.$forceUpdate();
|
|
|
+ if(item.tag){ //抖音下载
|
|
|
+ if(item.title){
|
|
|
+ item.title = item.title.substring(0, 50);
|
|
|
+ if(this.containsAnyChar(item.title)){ //判断是否含有特殊字符
|
|
|
+ item.title = item.title.replace(/[\\/:*?"<>|#%&\s]/g, "");
|
|
|
}
|
|
|
}
|
|
|
- }).then(res => {
|
|
|
- let outData = res.stdout ? res.stdout.toString() : '{}';
|
|
|
- item.status = '3';
|
|
|
+ let outputPath = newPath + separator + item.title + '[' + item.format_id + ']' + '.mp4';
|
|
|
+ let url = item.urlList.length > 0 ? item.urlList[0] : '';
|
|
|
+
|
|
|
+ if(item.tag == 'douyin'){
|
|
|
+ item.urlList.map(uitem => {
|
|
|
+ if(uitem.startsWith('https://www.douyin.com/')){
|
|
|
+ url = uitem;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ item.status = '2';
|
|
|
+ item.loading = true;
|
|
|
+ await this.downloadImage(url, outputPath, item);
|
|
|
item.loading = false;
|
|
|
this.$forceUpdate();
|
|
|
this.$message({message: '恭喜你,下载已完成!', type: 'success'});
|
|
|
electronApi.call('showItemInfolder',[this.downloadDir + separator + pjson.softInfo.softName +'\\tty.tty']);
|
|
|
- }).catch(err =>{
|
|
|
- item.status = '4';
|
|
|
- item.loading = false;
|
|
|
+ return false;
|
|
|
+ }else{
|
|
|
+ // console.log(this.downloadUrl);
|
|
|
+ let params = [
|
|
|
+ '-f',
|
|
|
+ item.format_id,
|
|
|
+ '--force-overwrites',
|
|
|
+ '-o',
|
|
|
+ newPath + separator + '%(title).50s['+item.format_id+'].%(ext)s',
|
|
|
+ this.downloadUrl
|
|
|
+ ];
|
|
|
+ item.status = '2';
|
|
|
+ item.loading = true;
|
|
|
this.$forceUpdate();
|
|
|
- // console.log(err);
|
|
|
- })
|
|
|
+ electronApi.spawnExec(['dlp.exe', ...params],{
|
|
|
+ stdout:(data) =>{
|
|
|
+ let str = data.toString();
|
|
|
+ const regexDuration = /[download].*? (.*?)%/;
|
|
|
+ const res = regexDuration.exec(str);
|
|
|
+ if(res && res[1]){
|
|
|
+ item.percent = res[1];
|
|
|
+ this.$forceUpdate();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ let outData = res.stdout ? res.stdout.toString() : '{}';
|
|
|
+ item.status = '3';
|
|
|
+ item.loading = false;
|
|
|
+ this.$forceUpdate();
|
|
|
+ this.$message({message: '恭喜你,下载已完成!', type: 'success'});
|
|
|
+ electronApi.call('showItemInfolder',[this.downloadDir + separator + pjson.softInfo.softName +'\\tty.tty']);
|
|
|
+ }).catch(err =>{
|
|
|
+ item.status = '4';
|
|
|
+ item.loading = false;
|
|
|
+ this.$forceUpdate();
|
|
|
+ // console.log(err);
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
|
|
|
// 解析抖音视频
|
|
@@ -670,8 +717,10 @@
|
|
|
let userDataDir = os.tmpdir() + separator + 'chrome-data-capture-video';
|
|
|
// 运行不同平台的浏览器
|
|
|
puppeteer.use(StealthPlugin());
|
|
|
+ let headless = true;
|
|
|
+ headless = this.initDevelop().headless;
|
|
|
this.videoBrowser = await puppeteer.launch({
|
|
|
- headless: true,
|
|
|
+ headless: headless,
|
|
|
executablePath: this.initPath(),
|
|
|
userDataDir: userDataDir,
|
|
|
args: [
|
|
@@ -691,11 +740,19 @@
|
|
|
let responseVideo = [];
|
|
|
let responseUrl = [];
|
|
|
let responseObj = {};
|
|
|
+ let vtitle = '视频';
|
|
|
page.on('response', async(response) => {
|
|
|
// 检查响应的 MIME 类型是否以 'video/' 开头
|
|
|
if (response.headers()['content-type'] && response.headers()['content-type'].startsWith('video/')) {
|
|
|
if(responseVideo.indexOf(response.url()) < 0 && !response.url().startsWith('blob:https://')){
|
|
|
responseVideo.push(response.url());
|
|
|
+ vtitle = await page.title();
|
|
|
+ if(vtitle){
|
|
|
+ vtitle = vtitle.substring(0, 50);
|
|
|
+ if(this.containsAnyChar(vtitle)){ //判断是否含有特殊字符
|
|
|
+ vtitle = vtitle.replace(/[\\/:*?"<>|#%&\s]/g, "");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (response.headers()['content-type'] && response.headers()['content-type'].startsWith('application/json')) {
|
|
@@ -714,73 +771,95 @@
|
|
|
}
|
|
|
|
|
|
});
|
|
|
- await page.goto(url, {waitUntil : 'networkidle2'});
|
|
|
+ let waitUntil = 'networkidle2';
|
|
|
+ waitUntil = this.initDevelop().waitUntil;
|
|
|
+ await page.goto(url, {waitUntil : waitUntil});
|
|
|
await page.waitForTimeout(1000);
|
|
|
- await page.close();
|
|
|
-
|
|
|
- let arr = ['aweme_detail']; //'video' ,'play_addr', 'url_list', '2'];
|
|
|
- for(let i = 0; i < arr.length; i++){
|
|
|
- responseObj = responseObj[arr[i]];
|
|
|
- }
|
|
|
+ await this.videoBrowser.close();
|
|
|
|
|
|
- if(responseObj.preview_title){
|
|
|
- responseObj.preview_title = responseObj.preview_title.substring(0, 50);
|
|
|
- if(this.containsAnyChar(responseObj.preview_title)){ //判断是否含有特殊字符
|
|
|
- responseObj.preview_title = responseObj.preview_title.replace(/[\\|/|:|*|?|"|<|>||#|%|&|\s]/g, "");
|
|
|
+ if(responseObj['aweme_detail']){ // 返回的接口数据中有aweme_detail参数 才会解析接口数据
|
|
|
+ let arr = ['aweme_detail']; //'video' ,'play_addr', 'url_list', '2'];
|
|
|
+ for(let i = 0; i < arr.length; i++){
|
|
|
+ responseObj = responseObj[arr[i]];
|
|
|
}
|
|
|
- }
|
|
|
- if(responseObj && responseObj.video && responseObj.video.play_addr){
|
|
|
- let vinfo = {
|
|
|
- title: responseObj.preview_title,
|
|
|
- tag: 'douyin',
|
|
|
- format_id: 'default',
|
|
|
- ext: 'mp4',
|
|
|
- resolution: responseObj.video.play_addr.width + 'x' + responseObj.video.play_addr.height,
|
|
|
- fps: '-',
|
|
|
- filesize: responseObj.video.play_addr.data_size,
|
|
|
- vcodec: '-',
|
|
|
- acodec: '-',
|
|
|
- urlList: responseObj.video.play_addr.url_list,
|
|
|
- status: '1',
|
|
|
- loading: false
|
|
|
+
|
|
|
+ if(responseObj && responseObj.preview_title){
|
|
|
+ responseObj.preview_title = responseObj.preview_title.substring(0, 50);
|
|
|
+ if(this.containsAnyChar(responseObj.preview_title)){ //判断是否含有特殊字符
|
|
|
+ responseObj.preview_title = responseObj.preview_title.replace(/[\\/:*?"<>|#%&\s]/g, "");
|
|
|
+ }
|
|
|
}
|
|
|
- this.videoList.push(vinfo);
|
|
|
- }
|
|
|
- if(responseObj && responseObj.video && responseObj.video.play_addr_265){
|
|
|
- let vinfo = {
|
|
|
- title: responseObj.preview_title,
|
|
|
- tag: 'douyin',
|
|
|
- format_id: 'play_addr_265',
|
|
|
- ext: 'mp4',
|
|
|
- resolution: responseObj.video.play_addr_265.width + 'x' + responseObj.video.play_addr_265.height,
|
|
|
- fps: '-',
|
|
|
- filesize: responseObj.video.play_addr_265.data_size,
|
|
|
- vcodec: '-',
|
|
|
- acodec: '-',
|
|
|
- urlList: responseObj.video.play_addr_265.url_list,
|
|
|
- status: '1',
|
|
|
- loading: false
|
|
|
+ if(responseObj && responseObj.video && responseObj.video.play_addr){
|
|
|
+ let vinfo = {
|
|
|
+ title: responseObj.preview_title,
|
|
|
+ tag: 'douyin',
|
|
|
+ format_id: 'default',
|
|
|
+ ext: 'mp4',
|
|
|
+ resolution: responseObj.video.play_addr.width + 'x' + responseObj.video.play_addr.height,
|
|
|
+ fps: '-',
|
|
|
+ filesize: responseObj.video.play_addr.data_size,
|
|
|
+ vcodec: '-',
|
|
|
+ acodec: '-',
|
|
|
+ urlList: responseObj.video.play_addr.url_list,
|
|
|
+ status: '1',
|
|
|
+ loading: false
|
|
|
+ }
|
|
|
+ this.videoList.push(vinfo);
|
|
|
}
|
|
|
- this.videoList.push(vinfo);
|
|
|
- }
|
|
|
- if(responseObj && responseObj.video && responseObj.video.play_addr_h264){
|
|
|
+ if(responseObj && responseObj.video && responseObj.video.play_addr_265){
|
|
|
+ let vinfo = {
|
|
|
+ title: responseObj.preview_title,
|
|
|
+ tag: 'douyin',
|
|
|
+ format_id: 'play_addr_265',
|
|
|
+ ext: 'mp4',
|
|
|
+ resolution: responseObj.video.play_addr_265.width + 'x' + responseObj.video.play_addr_265.height,
|
|
|
+ fps: '-',
|
|
|
+ filesize: responseObj.video.play_addr_265.data_size,
|
|
|
+ vcodec: '-',
|
|
|
+ acodec: '-',
|
|
|
+ urlList: responseObj.video.play_addr_265.url_list,
|
|
|
+ status: '1',
|
|
|
+ loading: false
|
|
|
+ }
|
|
|
+ this.videoList.push(vinfo);
|
|
|
+ }
|
|
|
+ if(responseObj && responseObj.video && responseObj.video.play_addr_h264){
|
|
|
+ let vinfo = {
|
|
|
+ title: responseObj.preview_title,
|
|
|
+ tag: 'douyin',
|
|
|
+ format_id: 'play_addr_h264',
|
|
|
+ ext: 'mp4',
|
|
|
+ resolution: responseObj.video.play_addr_h264.width + 'x' + responseObj.video.play_addr_h264.height,
|
|
|
+ fps: '-',
|
|
|
+ filesize: responseObj.video.play_addr_h264.data_size,
|
|
|
+ vcodec: '-',
|
|
|
+ acodec: '-',
|
|
|
+ urlList: responseObj.video.play_addr_h264.url_list,
|
|
|
+ status: '1',
|
|
|
+ loading: false
|
|
|
+ }
|
|
|
+ this.videoList.push(vinfo);
|
|
|
+ }
|
|
|
+ }else if(responseVideo.length > 0){ //网页解析到视频地址
|
|
|
let vinfo = {
|
|
|
- title: responseObj.preview_title,
|
|
|
+ title: vtitle,
|
|
|
tag: 'douyin',
|
|
|
- format_id: 'play_addr_h264',
|
|
|
+ format_id: 'video',
|
|
|
ext: 'mp4',
|
|
|
- resolution: responseObj.video.play_addr_h264.width + 'x' + responseObj.video.play_addr_h264.height,
|
|
|
+ resolution: '-',
|
|
|
fps: '-',
|
|
|
- filesize: responseObj.video.play_addr_h264.data_size,
|
|
|
+ filesize: '',
|
|
|
vcodec: '-',
|
|
|
acodec: '-',
|
|
|
- urlList: responseObj.video.play_addr_h264.url_list,
|
|
|
+ urlList: responseVideo,
|
|
|
status: '1',
|
|
|
loading: false
|
|
|
}
|
|
|
this.videoList.push(vinfo);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
this.parseLoading = false;
|
|
|
this.tabLoading = false;
|
|
|
}catch(e){
|
|
@@ -820,8 +899,10 @@
|
|
|
let userDataDir = os.tmpdir() + separator + 'chrome-data-capture-video';
|
|
|
// 运行不同平台的浏览器
|
|
|
puppeteer.use(StealthPlugin());
|
|
|
+ let headless = true;
|
|
|
+ headless = this.initDevelop().headless;
|
|
|
this.videoBrowser = await puppeteer.launch({
|
|
|
- headless: true,
|
|
|
+ headless: headless,
|
|
|
executablePath: this.initPath(),
|
|
|
userDataDir: userDataDir,
|
|
|
args: [
|
|
@@ -848,7 +929,7 @@
|
|
|
if(title){
|
|
|
title = title.substring(0, 50);
|
|
|
if(this.containsAnyChar(title)){ //判断是否含有特殊字符
|
|
|
- title = title.replace(/[\\|/|:|*|?|"|<|>||#|%|&|\s]/g, "");
|
|
|
+ title = title.replace(/[\\/:*?"<>|#%&\s]/g, "");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -872,7 +953,9 @@
|
|
|
}
|
|
|
|
|
|
});
|
|
|
- await page.goto(url, {waitUntil : 'networkidle2'});
|
|
|
+ let waitUntil = 'networkidle2';
|
|
|
+ waitUntil = this.initDevelop().waitUntil;
|
|
|
+ await page.goto(url, {waitUntil : waitUntil});
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
|
let pageInfo = await page.evaluate(() => {
|
|
@@ -913,7 +996,7 @@
|
|
|
if(title){
|
|
|
title = title.substring(0, 50);
|
|
|
if(this.containsAnyChar(title)){ //判断是否含有特殊字符
|
|
|
- title = title.replace(/[\\|/|:|*|?|"|<|>||#|%|&|\s]/g, "");
|
|
|
+ title = title.replace(/[\\/:*?"<>|#%&\s]/g, "");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -944,7 +1027,7 @@
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- await page.close();
|
|
|
+ await this.videoBrowser.close();
|
|
|
this.parseLoading = false;
|
|
|
this.tabLoading = false;
|
|
|
}
|
|
@@ -1035,7 +1118,7 @@
|
|
|
if(title){
|
|
|
title = title.substring(0, 50);
|
|
|
if(this.containsAnyChar(title)){ //判断是否含有特殊字符
|
|
|
- title = title.replace(/[\\|/|:|*|?|"|<|>||#|%|&|\s]/g, "");
|
|
|
+ title = title.replace(/[\\/:*?"<>|#%&\s]/g, "");
|
|
|
}
|
|
|
if (fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName + separator + title)) {
|
|
|
urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + title;
|
|
@@ -1091,7 +1174,7 @@
|
|
|
|
|
|
// 是否包含特殊字符
|
|
|
containsAnyChar(str) {
|
|
|
- let charsArray = ['\\', '/', ':', '*', '?', '"', '<', '>', '|', '#', '%' ,'&'];
|
|
|
+ let charsArray = ['\\', '/', ':', '*', '?', '"', '<', '>', '|', '#', '%' ,'&', ' ', '\t', '\n'];
|
|
|
for (let i = 0; i < charsArray.length; i++) {
|
|
|
if (str.includes(charsArray[i])) {
|
|
|
return true;
|