Skip to content

Commit

Permalink
Merge pull request #48 from shaww855/dev
Browse files Browse the repository at this point in the history
v1.5.2
  • Loading branch information
shaww855 committed Jun 28, 2022
2 parents c7a8298 + 44c9598 commit 48bbcfd
Show file tree
Hide file tree
Showing 15 changed files with 798 additions and 912 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/git-actions-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Actions Release"

on:
push:
tags:
- '*'

jobs:
build:
name: Publish binaries
runs-on: windows-latest

steps:
- uses: actions/checkout@v3
- name: 'Get cache'
uses: actions/setup-node@v3
with:
node-version: '14'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Set env
run: npm config set puppeteer_skip_chromium_download=true
- name: Install
run: npm ci
- name: Build
run: npm run build:win
- name: Upload to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: acfunlive.exe
asset_name: acfunlive_win_$tag.exe
tag: ${{ github.ref }}
overwrite: true
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 更新日志
此项目的所有更改都将记录在此文件中。
格式基于[Keep a Changelog](https://keepachangelog.com/en/1.0.0/),并且该项目遵循 [Semantic Versioning](https://semver.org/spec/v2.0.0.html)

## [未发布]

## [1.5.2] - 2022-06-28
### 新增
* Win 平台添加`记住登录状态`引导
为方便将本工具设为开机启动的用户,开启此项会在首次登录成功后会保存 **cookies** 于本地,之后的每次启动不会再询问登录方式,请保证本地运行环境的安全。
* Win 平台添加`直播间数量限制`引导
默认 `0` 为无限,请根据本机运行内存大小酌情设置。
* 使用工作流自动发布
* 添加了更新日志

### 变更
* 说明文档新增配置文件中`cookies``version`的解释
* 读取配置方式优化,在登录成功后配置储存于运行环境,避免频繁 I/O

[未发布]: https://github.com/shaww855/acfun-live/compare/v1.5.2...HEAD
[1.5.2]: https://github.com/shaww855/acfun-live/compare/v1.5.1...v1.5.2
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
## AcFun-Live
[![CodeQL](https://github.com/shilx/acfun-live/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/shilx/acfun-live/actions/workflows/codeql-analysis.yml)
[![release](https://img.shields.io/github/v/release/shilx/acfun-live)](https://github.com/shilx/acfun-live/releases)
[![downloads](https://img.shields.io/github/downloads/shilx/acfun-live/total)](https://github.com/shilx/acfun-live/releases)
[![downloads](https://img.shields.io/github/license/shilx/acfun-live)](https://github.com/shilx/acfun-live/blob/main/LICENSE)
# AcFun-Live
[![Actions Release](https://github.com/shaww855/acfun-live/actions/workflows/git-actions-release.yml/badge.svg)](https://github.com/shaww855/acfun-live/actions/workflows/git-actions-release.yml)
[![CodeQL](https://github.com/shaww855/acfun-live/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/shaww855/acfun-live/actions/workflows/codeql-analysis.yml)
[![version](https://img.shields.io/github/package-json/v/shaww855/acfun-live)](https://github.com/shaww855/acfun-live/tags)
[![downloads](https://img.shields.io/github/downloads/shaww855/acfun-live/total)](https://github.com/shaww855/acfun-live/releases)
[![license](https://img.shields.io/github/license/shaww855/acfun-live)](https://github.com/shaww855/acfun-live/blob/main/LICENSE)
使用 Puppeteer 开启 AcFun 直播监控室,挂牌子,还有开播通知!😏
请认准唯二指定下载仓库 Gitee、Github。
本工具完全免费、开源,有更好的点子欢迎PR。
## 隐私提示
本工具不会向A站以外的任何服务器发送、储存你的任何信息,也不会分享任何信息给任意第三方,所有操作均通过A站Api实现。
本工具不会向A站以外的任何服务器发送或储存你的任何信息,也不会分享任何信息给任意第三方,所有操作均通过A站Api实现。
- Win 用户扫码登录不储存任何信息;账号密码登录则储存于运行环境中,关闭即销毁。
- Linux 用户账号密码明文存储于本地,请自行保证本地环境安全。

Expand All @@ -20,9 +21,9 @@
本工具通过操控 Chromium 实现各种操作,请始终保持你的浏览器为最新版本。
- ## Windows
**可选扫码登录,无需输入账号密码**
支持 Windows10 及以上,请前往 发布页面 下载,解压后直接运行。
[国内下载地址](https://gitee.com/cn_shaw/acfun-live/releases)
[海外下载地址](https://github.com/shilx/acfun-live/releases)
支持 Windows10 及以上,请前往 发布页面 下载
- [国内下载地址](https://gitee.com/cn_shaw/acfun-live/releases)
- [海外下载地址](https://github.com/shaww855/acfun-live/releases)
- ## Linux
- 安装
- NodeJs 和 NPM (尽量保持为最新版)
Expand Down Expand Up @@ -69,6 +70,8 @@ useObsDanmaku | Boolean | 使用官方OBS弹幕工具监控<br>开启此项时
notification | Boolean<br>Array | 借助第三方APP推送开播通知<br>true: 所有粉丝牌主播的通知<br>false: 不推送开播通知<br> [ Number ]: 指定uid开播推送,前提是已关注并有粉丝牌<br>此配置项会受 `checkAllRoom` 影响<br>服务器时间的 0~6 点不推送
iftttKey | String | [IFTTT](https://ifttt.com/) 密钥<br>[配置方法](#IFTTT)
barkKey | String | [Bark](https://github.com/Finb/Bark) 密钥 仅限IOS<br>[配置方法](#BARK)
cookies | String<br>Array | 保存登录状态的字段<br>要么为空字符串,要么为`puppeteer`导出的`cookies`数组
version | String | 当前版本号<br>本工具会将它与Github上的版本号对比并提示是否有更新

## 推送配置
### IFTTT
Expand Down Expand Up @@ -139,4 +142,4 @@ barkKey | String | [Bark](https://github.com/Finb/Bark) 密钥 仅限IOS<br>[

## Stargazers over time

[![Stargazers over time](https://starchart.cc/shilx/acfun-live.svg)](https://starchart.cc/shilx/acfun-live)
[![Stargazers over time](https://starchart.cc/shaww855/acfun-live.svg)](https://starchart.cc/shaww855/acfun-live)
33 changes: 16 additions & 17 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
module.exports = function () {
const schedule = require('node-schedule');
const puppeteer = require('puppeteer');
const schedule = require('node-schedule')
const puppeteer = require('puppeteer')
const { getConfig, setConfig } = require ('./util.js')
// 页面操作
const {
userLogin,
userLoginByCookies,
userLoginByQrcode,
startMonitor,
endMonitor,
requestFliter,
handlePageError
} = require ('./pages.js')

module.exports = function(){
// 配置文件
const { getConfig, setConfig } = require('./util.js')
const config = getConfig()

// 页面操作
const {
userLogin,
userLoginByCookies,
userLoginByQrcode,
startMonitor,
endMonitor,
requestFliter,
handlePageError
} = require('./pages.js')

console.log('调试模式', config.debug);
console.log('每天0~1点自动重启', config.autoRestart);
console.log(`每(分钟)检查直播`, config.checkLiveTimeout);
Expand Down Expand Up @@ -64,7 +63,6 @@ module.exports = function () {
]
}).then(async browser => {
globalBrowser = browser
console.log('puppeteer launched');
const pageList = await browser.pages()
const page = pageList[0]
await requestFliter(page)
Expand Down Expand Up @@ -106,7 +104,8 @@ module.exports = function () {

// 起飞
loginFn(page).then(() => {
console.log('loginFn then');
// 登录成功后,设置配置缓存
global.configCache = true
startMonitor(browser)
})

Expand Down
21 changes: 10 additions & 11 deletions checkUpdate.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const https = require('https');
const { version } = require('./package.json')
const { notify } = require('./notification')
const https = require('https')
const { notify } = require('./notification/index.js')
const { hasNewVersion } = require('./util.js')

const downloadInfo = `
---
唯二指定下载地址:
中国大陆(GFW内) https://gitee.com/cn_shaw/acfun-live/releases
其他地区及海外 https://github.com/shilx/acfun-live/releases
其他地区及海外 https://github.com/shaww855/acfun-live/releases
---
`

module.exports = () => {
module.exports = function(){
return new Promise((resolve, reject) => {
return https.get('https://gitee.com/cn_shaw/acfun-live/raw/main/package.json', { timeout:3000 }, (res) => {
// return https.get('https://raw.githubusercontent.com/shilx/acfun-live/main/package.json', { timeout:3000 }, (res) => {
// return https.get('https://github.91chi.fun/https://raw.githubusercontent.com/shilx/acfun-live/main/package.json', { timeout:3000 }, (res) => {
// return https.get('https://raw.githubusercontent.com/shaww855/acfun-live/main/package.json', { timeout:3000 }, (res) => {
// return https.get('https://github.91chi.fun/https://raw.githubusercontent.com/shaww855/acfun-live/main/package.json', { timeout:3000 }, (res) => {

const { statusCode } = res;
// const contentType = res.headers['content-type'];
Expand Down Expand Up @@ -52,12 +52,11 @@ module.exports = () => {
reject(e.message)
});
}).then(res => {
let msg = `当前版本:${version},`
let msg = `当前版本:${global.version},`
if (res.version) {
const { hasNewVersion } = require('./util.js')
if (hasNewVersion(res.version, version)) {
if (hasNewVersion(res.version, global.version)) {
msg += `GitHub版本 ${res.version},请关注`
notify(msg, 'https://github.com/shilx/acfun-live/releases')
notify(msg, 'https://github.com/shaww855/acfun-live/releases')
msg = `${msg}${downloadInfo}`
} else {
msg += '已是最新'
Expand Down
File renamed without changes.
46 changes: 34 additions & 12 deletions entry.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const { getConfig, setConfig } = require('./util.js')
const inquirer = require('inquirer');
const inquirer = require('inquirer')
// 检查更新
const checkUpdate = require('./checkUpdate')
const checkUpdate = require('./checkUpdate.js')
const { hasNewVersion } = require('./util.js')
const fs = require('node:fs')
const runApp = require('./app.js')
const defaultConfig = {
"account": "",
Expand All @@ -27,6 +29,8 @@ const defaultConfig = {
"cookies": ""
}

global.version = JSON.parse(fs.readFileSync('./package.json', "utf8")).version

global.platformIsWin = process.platform === 'win32'

/**
Expand Down Expand Up @@ -84,6 +88,11 @@ const confirmLoginType = () =>
done(null, true)
}
}
}, {
type: 'confirm',
message: '记住登录状态',
default: false,
name: 'saveCookies'
}, ]).then(answers => {
global.loginInfo = answers

Expand Down Expand Up @@ -111,13 +120,18 @@ const confirmLoginType = () =>
*/
const createConfiguration = () => {
return inquirer.prompt([{
type: 'number',
message: '直播间数量限制(请根据本机运行内存大小酌情设置,0 为无限)',
default: 0,
name: 'serverRoomLimit',
}, {
type: 'confirm',
message: '是否开启调试',
message: '是否开启调试',
default: false,
name: 'debug',
}, {
type: 'list',
message: '是否开启自动重启',
message: '是否开启自动重启',
choices: [{
name: '关闭',
value: false,
Expand All @@ -137,7 +151,7 @@ const createConfiguration = () => {
name: 'executablePath',
}, {
// type: 'confirm',
// message: '使用OBS弹幕工具监控',
// message: '使用OBS弹幕工具监控',
// default: true,
// name: 'useObsDanmaku',
// }, {
Expand All @@ -147,7 +161,7 @@ const createConfiguration = () => {
name: 'checkWearMedal'
}, {
type: 'confirm',
message: '只要有粉丝牌,即使未关注主播也需要监控',
message: '只要有粉丝牌,即使未关注主播也需要监控',
default: false,
name: 'checkAllRoom'
}]).then((answers) => {
Expand All @@ -159,6 +173,8 @@ const createConfiguration = () => {
userConfig.cookies = JSON.parse(answers.cookies)
}

userConfig.serverRoomLimit = [ userConfig.serverRoomLimit ]

delete userConfig.notificationApp
setConfig({
userConfig: {
Expand Down Expand Up @@ -196,15 +212,13 @@ checkUpdate().then(() => {
const config = getConfig()
let 配置文件过期 = false
if (config !== null) {
const { version } = require('./package.json')
const { hasNewVersion } = require('./util.js')
if (config.version === undefined) {
// 没有版本信息
配置文件过期 = true
} else if (config.version === version) {
} else if (config.version === global.version) {
// 当前版本
配置文件过期 = false
} else if (hasNewVersion(config.version, version)) {
} else if (hasNewVersion(config.version, global.version)) {
// 旧版本
配置文件过期 = true
} else {
Expand All @@ -218,16 +232,24 @@ checkUpdate().then(() => {
if (config === null) {
setConfig({ userConfig: defaultConfig })
console.log('Linux请用户按照文档修改配置文件');
console.log('https://github.com/shilx/acfun-live#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E');
console.log('https://github.com/shaww855/acfun-live#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E');
} else if (配置文件过期) {
console.log('版本已更新,请按照文档重新创建配置文件');
console.log('https://github.com/shilx/acfun-live#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E');
console.log('https://github.com/shaww855/acfun-live#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E');
} else {
runApp()
}
return
}
// Win平台
if (config !== null && config.cookies !== '') {
global.loginInfo = {
...config,
loginType: 'cookies'
}
runApp()
return
}
confirmLoginType().then(async () => {
if (config === null) {
// 未配置
Expand Down
1 change: 0 additions & 1 deletion evaluateHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const OpenLivePage = (page, retry = 0) => {
})
}


module.exports = (action, page, data) => {
switch (action) {
case '个人信息':
Expand Down
4 changes: 2 additions & 2 deletions notification/bark.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const https = require('https')
module.exports = (path) => {
const https = require('node:https')
module.exports = function (path) {
return new Promise((resolve, reject) => {
path = encodeURI(path)

Expand Down
6 changes: 3 additions & 3 deletions notification/ifttt.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const https = require('https')
module.exports = (path) => {
const https = require('node:https')
module.exports = function (path) {
return new Promise((resolve, reject) => {
path = encodeURI(path)

const options = {
hostname: 'maker.ifttt.com',
port: 443,
Expand Down
4 changes: 2 additions & 2 deletions notification/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
let data = {}

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

/**
* 发送开播通知
Expand Down
Loading

0 comments on commit 48bbcfd

Please sign in to comment.