Skip to content

Commit

Permalink
Merge pull request #43 from shilx/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
shaww855 committed May 1, 2022
2 parents a05ddf2 + d5a002b commit 1b366bb
Show file tree
Hide file tree
Showing 7 changed files with 875 additions and 681 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ barkKey | String | [Bark](https://github.com/Finb/Bark) 密钥 IOS用户专享<
## 安装时可能出现的问题
* ERROR: Failed to set up Chromium r782078! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
一般是网络慢导致下载浏览器失败,解决方法有二
- 设置淘宝预源后再次尝试安装
- 设置淘宝源后再次尝试安装
`npm config set puppeteer_download_host=https://npm.taobao.org/mirrors`
- 如果你本机已经安装 Chromium,可以设置跳过下载后,再次尝试安装
`npm config set puppeteer_skip_chromium_download=true`
Expand All @@ -146,4 +146,10 @@ barkKey | String | [Bark](https://github.com/Finb/Bark) 密钥 IOS用户专享<
path/node_modules/puppeteer/.local-chromium/linux-782078/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
- 查找缺少的依赖并安装
https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
* 打包懒人包时进度慢
可能是需要下载node包缓慢导致的
1.https://github.com/vercel/pkg-fetch/releases 下载提示中的node包
2. 放到 `C:\Users\{用户名}\.pkg-cache\{当前pkg版本号}` 目录下
3. 改名为 `fetched-{node版本号}-win-x64`
4. 再次运行打包命令即可
---
18 changes: 11 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = function () {
]
}).then(async browser => {
globalBrowser = browser
console.log('puppeteer launched,Cookie状态:', config.cookies !== '');
console.log('puppeteer launched');
const pageList = await browser.pages()
const page = pageList[0]
await requestFliter(page)
Expand All @@ -74,23 +74,27 @@ module.exports = function () {
handlePageError(page, '主页', error)
})

let loginFn = userLoginByCookies

// 开始登录
if (config.cookies !== '') {
console.log('登录方式 Cookie');
await userLoginByCookies(page)
} else if (config.account !== '' && config.password !== '') {
console.log('登录方式 账号密码');
await userLogin(page)
loginFn = userLogin
} else {
console.error('请填写 Cookie 或者 账号密码 以便登录')
}

// 起飞
startMonitor(browser)
loginFn(page).then(() => {
console.log('loginFn then');
startMonitor(browser)
})

}).catch(err => {
console.error(err)
console.log('🐛puppeteer启动失败,5秒后自动关闭🐛');
console.log('puppeteer启动失败,5秒后自动关闭');
setTimeout(() => {
process.exit(1)
}, 5000)
Expand All @@ -104,9 +108,9 @@ module.exports = function () {
}

const rule = config.autoRestart === true ? '01 00 * * *' : config.autoRestart
console.log(`🤖 定时重启工具运行中,规则:${rule}`);
console.log(`定时重启工具运行中,规则:${rule}`);
schedule.scheduleJob({ rule }, function () {
console.log(`🤖 定时重启已触发,规则:${rule}`);
console.log(`定时重启已触发,规则:${rule}`);
endMonitor(globalBrowser)
Start()
})
Expand Down
10 changes: 5 additions & 5 deletions entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,18 @@ async function configQuestion () {

const handleError = err => {
if (err.result === -401) {
console.error('🐛 登录过期,尝试使用账号密码重新登录');
console.error('登录过期,尝试使用账号密码重新登录');
setConfig({ prop: 'cookies' })
Start()
return
}
console.log(err)
console.log('🐛 出现错误,10秒后自动关闭...');
console.log('🐛 如频繁报错,请删除config.json文件后,重新开打工具');
console.log('🐛 或截图反馈给开发者');
console.log('出现错误,10秒后自动关闭...');
console.log('如频繁报错,请删除config.json文件后,重新开打工具');
console.log('或截图反馈给开发者');

setTimeout(() => {
console.log('🐛 祝您身体健康,再见');
console.log('祝您身体健康,再见');
}, 7000)
setTimeout(() => {
process.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion notification/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
let data = {}

const { getConfig, formartDate } = require('../util.js')
const { checkLiveTimeout, notification, iftttKey, barkKey } = getConfig()
const IFTTT = require('./ifttt')
const BARK = require('./bark')

Expand All @@ -11,6 +10,7 @@ const BARK = require('./bark')
* @returns
*/
function liveStart (liveUperInfo) {
const { checkLiveTimeout, notification, iftttKey, barkKey } = getConfig()
if (notification === false || notification.length === 0) return
if (iftttKey + barkKey === '') {
console.log('开播通知 发送失败,未配置相关key。');
Expand Down
Loading

0 comments on commit 1b366bb

Please sign in to comment.