Skip to content

Commit

Permalink
Merge pull request #174 from YaoZeyuan/yaozeyuan/dev/etf-save-world-v2
Browse files Browse the repository at this point in the history
发布3.5.0版
  • Loading branch information
YaoZeyuan authored Oct 26, 2024
2 parents 6ebc971 + 881e2f7 commit 3b0dbce
Show file tree
Hide file tree
Showing 18 changed files with 1,075 additions and 360 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# 软件下载

最新版本: 3.3.0
最新版本: 3.5.0

[点击进入下载页](https://www.yaozeyuan.online/stablog/)

Expand Down
17 changes: 17 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# 3.5.0

> 感谢博主 [@二级市场捡辣鸡冠军](https://weibo.com/u/7519797263) 的无私分享. 作者受博主感召, 爬起来更新了这版代码
1. 建立失败重抓机制, 并通过数据库记录失败任务, 支持针对失败页面进行重抓
2. 解决pdf模糊问题.
1. 之前按照屏幕宽750px进行截图, 但实际上现代显示器物理像素一般是逻辑像素x2甚至x4水平, 导致750px图片被放大两倍后, 显得模糊
2. 解决方案是在渲染截图时, 按750 x 放大比率进行截图, 目前比率为2倍, 也就是截取2倍图, 实测可以满足分辨率需要
3. 阅读体验问题
1. 显式增加推荐阅读器提示
4. 开发调试优化
1. 增加配置项, 允许关闭自动生成配置能力
2. 增加配置项, 支持只重抓错误记录
3. 所有请求一律自动重试5次
4. 运行完毕后默认进行重试
5. 显式提示抓取错误解决方案: 重新登录或者等待6小时后重试

# 3.4.0

1. 修复无法访问微博接口的bug, 恢复软件功能
Expand Down
2 changes: 1 addition & 1 deletion client/.umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
// 使用hash模式, 解决基于文件进行浏览时的白屏问题
history: { type: 'hash' },
base: "/",
publicPath: './',
publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
hash: true,
chainWebpack(memo, { env, webpack }) {
// 设置 alias
Expand Down
112 changes: 89 additions & 23 deletions client/src/pages/customer_task/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ type TypeDatabase = {
total_page_count: number
followers_count: number
}
fetchErrorDistribution: {
weibo_page: number
long_text_weibo: number
article: number
}
}

const Order: {
Expand All @@ -76,13 +81,6 @@ const ImageQuilty = {
无图: 'none',
默认: 'default',
}
const PdfQuilty: { [key: string]: 50 | 60 | 70 | 90 | 100 } = {
'50': 50,
'60': 60,
'70': 70,
'90': 90,
'100': 100,
}

const Translate_Image_Quilty = {
[TaskConfigType.CONST_Image_Quilty_默认]: '默认',
Expand All @@ -104,7 +102,6 @@ const Const_Volume_Split_By: { [key: string]: string } = {
let taskConfig: TypeTaskConfig.Customer = {
configList: [_.clone(defaultConfigItem)],
imageQuilty: TaskConfigType.CONST_Image_Quilty_默认,
pdfQuilty: PdfQuilty['60'],
maxBlogInBook: 100000,
postAtOrderBy: TaskConfigType.CONST_Order_Asc,
bookTitle: '',
Expand All @@ -115,6 +112,8 @@ let taskConfig: TypeTaskConfig.Customer = {
fetchEndAtPageNo: 100000,
outputStartAtMs: dayjs('2010-01-01 00:00:00').unix() * 1000,
outputEndAtMs: dayjs().add(1, 'year').unix() * 1000,
enableAutoConfig: true,
onlyRetry: false,
isSkipFetch: false,
isSkipGeneratePdf: false,
isRegenerateHtml2PdfImage: false,
Expand All @@ -131,8 +130,12 @@ let jsonContent = util.getFileContent(pathConfig.customerTaskConfigUri)
try {
taskConfig = JSON.parse(jsonContent)
} catch (e) {}
// 输出时间始终重置为次日
taskConfig.outputEndAtMs = dayjs().add(1, 'day').unix() * 1000
if (taskConfig.enableAutoConfig) {
// 仅在启用自动生成配置时, 才自动重置输出时间

// 输出时间始终重置为次日
taskConfig.outputEndAtMs = dayjs().add(1, 'day').unix() * 1000
}
if (taskConfig.configList.length === 0) {
taskConfig.configList.push(_.clone(defaultConfigItem))
}
Expand Down Expand Up @@ -165,6 +168,11 @@ export default function IndexPage(props: { changeTabKey: Function }) {
total_page_count: 0,
followers_count: 0,
},
fetchErrorDistribution: {
article: 0,
long_text_weibo: 0,
weibo_page: 0,
},
},
(e) => e,
),
Expand Down Expand Up @@ -224,14 +232,37 @@ export default function IndexPage(props: { changeTabKey: Function }) {
return
}

// 获取数据库中的抓取错误记录
const errorDistributionList = await ipcRenderer.sendSync('MFetchErrorRecord_asyncGetErrorDistributionCount', {
author_uid: uid,
})
set$$Database(
produce($$database, (raw) => {
// 更新错误数据分布
for (let record of errorDistributionList) {
switch (record.resource_type) {
case 'weibo_page':
raw.fetchErrorDistribution.weibo_page = record.count
break
case 'long_text_weibo':
raw.fetchErrorDistribution.long_text_weibo = record.count
break
case 'article':
raw.fetchErrorDistribution.article = record.count
break
default:
}
}

raw.taskConfig.configList[0].uid = uid
raw.currentUserInfo = userInfo
if (updatePageRange) {
// 当启动任务时, 不需要更新页面列表
raw.taskConfig.fetchStartAtPageNo = 0
raw.taskConfig.fetchEndAtPageNo = userInfo?.total_page_count || 1000
if (raw.taskConfig.enableAutoConfig) {
// 仅在启用自动生成配置时, 才更新配置内容
raw.taskConfig.fetchStartAtPageNo = 0
raw.taskConfig.fetchEndAtPageNo = userInfo?.total_page_count || 1000
}
}
form.setFieldsValue({
fetchEndAtPageNo: raw.taskConfig.fetchEndAtPageNo,
Expand Down Expand Up @@ -421,6 +452,22 @@ export default function IndexPage(props: { changeTabKey: Function }) {
</Descriptions>
)}
</Form.Item>
<Form.Item label="待重试记录数">
<div className="flex-container">
<Descriptions bordered column={1}>
<Descriptions.Item label="微博页面">{$$database.fetchErrorDistribution.weibo_page}</Descriptions.Item>
<Descriptions.Item label="长微博">
{$$database.fetchErrorDistribution.long_text_weibo}
</Descriptions.Item>
<Descriptions.Item label="微博文章">{$$database.fetchErrorDistribution.article}</Descriptions.Item>
</Descriptions>
</div>
</Form.Item>
<Form.Item label="ℹ️Tip">
<div className="flex-container">
若频繁提示抓取失败, 请重新点击下方`退出当前账号`按钮后重登, 或者6小时后再来即可
</div>
</Form.Item>
<Divider>备份配置</Divider>

<Form.Item
Expand All @@ -445,6 +492,21 @@ export default function IndexPage(props: { changeTabKey: Function }) {
<span>&nbsp;页&nbsp;</span>
</div>
</Form.Item>
<Form.Item
label={
<span>
仅重试失败记录&nbsp;
<Tooltip title="跳过全量抓取, 只对之前抓取失败的页面记录进行重试. 重试成功后自动删除对应记录(正常抓取完成后, 默认重试失败页面, 不需要专门勾选. 如果本身没有失败记录, 相当于跳过抓取流程)">
<QuestionCircleOutlined />
</Tooltip>
</span>
}
name="onlyRetry"
valuePropName="checked"
>
<Switch></Switch>
</Form.Item>

<Collapse>
<Collapse.Panel header="[高级选项]输出规则" key="output-config">
<Form.Item
Expand Down Expand Up @@ -487,17 +549,6 @@ export default function IndexPage(props: { changeTabKey: Function }) {
<Radio.Button value={ImageQuilty.默认}>有图</Radio.Button>
</Radio.Group>
</Form.Item>
{/* <Form.Item label="pdf图片清晰度" name="pdfQuilty">
<Radio.Group buttonStyle="solid">
<Radio.Button value={PdfQuilty[50]}>50</Radio.Button>
<Radio.Button value={PdfQuilty[60]}>60-推荐值</Radio.Button>
<Radio.Button value={PdfQuilty[70]}>70</Radio.Button>
<Radio.Button value={PdfQuilty[80]}>80</Radio.Button>
<Radio.Button value={PdfQuilty[90]}>90</Radio.Button>
<Radio.Button value={PdfQuilty[100]}>100</Radio.Button>
</Radio.Group>
</Form.Item> */}

<Form.Item label="时间范围">
<div className="flex-container">
<span>只输出从</span>
Expand Down Expand Up @@ -545,6 +596,21 @@ export default function IndexPage(props: { changeTabKey: Function }) {

<Collapse>
<Collapse.Panel header="[高级选项]开发调试" key="develop-config">
<Form.Item
label={
<span>
自动更新抓取/导出范围&nbsp;
<Tooltip title="自动更新抓取范围和导出范围,默认启用,仅在调试时推荐关闭">
<QuestionCircleOutlined />
</Tooltip>
</span>
}
name="enableAutoConfig"
valuePropName="checked"
>
<Switch></Switch>
</Form.Item>

<Form.Item
label={
<span>
Expand Down
17 changes: 12 additions & 5 deletions client/src/pages/customer_task/task_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ export namespace TypeTaskConfig {
export type Customer = {
configList: Array<Record>
imageQuilty: imageQuilty // 图片质量
pdfQuilty: 50 | 60 | 70 | 90 | 100 // pdf输出质量(默认60, 质量体积平衡点)
bookTitle: string // 书名
comment: string // 备注
maxBlogInBook: maxBlogInBook // 自动分卷: 单本电子书中最大微博数
/**
* 是否启用自动配置(自动配置会将用户配置的起止时间等参数还原, 默认启用)
*/
enableAutoConfig: boolean
/**
* 微博排序方式: 按发布事件升序排列, 按发布时间降序排列
*/
Expand All @@ -28,13 +31,17 @@ export namespace TypeTaskConfig {
*/
fetchEndAtPageNo: number
/**
* 输出微博时间上限(毫秒值)
* 输出微博时间段-开始时间(毫秒)
*/
outputStartAtMs: number
/**
* 输出微博时间下限(毫秒值)
* 输出微博时间段-结束时间(毫秒)
*/
outputEndAtMs: number
/**
* 是否只进行重抓
*/
onlyRetry: boolean
/**
* 是否跳过备份阶段
*/
Expand All @@ -48,8 +55,8 @@ export namespace TypeTaskConfig {
*/
isRegenerateHtml2PdfImage: boolean
/**
* 是否只看微博文章(微博文章一定是原创, 转发微博不算原创)
*/
* 是否只看微博文章(微博文章一定是原创, 转发微博不算原创)
*/
isOnlyArticle: boolean
/**
* 是否只看原创
Expand Down
5 changes: 3 additions & 2 deletions demo.customer_task_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@
"comment": "孤鸿泽"
}
],
"enableAutoConfig": true,
"maxBlogInBook": 1000,
"imageQuilty": "default",
"bookTitle": "测试电子书",
"comment": "测试",
"mergeBy": "month",
"mergeCount": 100,
"pdfQuilty": 60,
"postAtOrderBy": "asc",
"fetchStartAtPageNo": 0,
"fetchEndAtPageNo": 100,
"outputStartAtMs": 1420041600000,
"outputEndAtMs": 1571339017000,
"isOnlyArticle": false,
"isOnlyOriginal": false
"isOnlyOriginal": false,
"onlyRetry": false
}
Loading

0 comments on commit 3b0dbce

Please sign in to comment.