feat: dida365 record

This commit is contained in:
DIYgod 2020-12-21 21:35:49 +08:00
parent f476900595
commit 326714ec5a
No known key found for this signature in database
GPG Key ID: D159328F47A80DCA
3 changed files with 52 additions and 22 deletions

View File

@ -610,3 +610,8 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
1. 在 4399 首页登录。
2. 打开开发者工具,切换到 Network 面板,刷新
3. 查找`www.4399.com`的访问请求,点击请求,在右侧 Headers 中找到 Cookie.
- 滴答清单
- `DIDA365_USERNAME`: 滴答清单用户名
- `DIDA365_PASSWORD`: 滴答清单密码

View File

@ -4,6 +4,18 @@ pageClass: routes
# 其他
## 4399 论坛
### 4399 论坛
<Route author="DIYgod" example="/forum4399/mtag-83932" path="/forum4399/:mtag" :paramsDesc="['mtag,必选-论坛网址最后的mtag字段']" selfhost="1"/>
::: warning 注意
需要用户 cookie 值,详情见部署页面的配置模块。
:::
</Route>
## acwifi 路由器交流
### 新闻
@ -351,6 +363,18 @@ type 为 all 时category 参数不支持 cost 和 free
<Route author="LogicJake" example="/kpmg/insights" path="/kpmg/insights" />
## 滴答清单
### 习惯打卡
::: warning 注意
需要账号密码,详情见部署文档部分 RSS 模块配置
:::
<Route author="DIYgod" example="/dida365/habit/checkins" path="/dida365/habit/checkins" selfhost="1"/>
## 东莞教研网
### 信息公开
@ -919,13 +943,3 @@ type 为 all 时category 参数不支持 cost 和 free
### はてな匿名ダイアリー - 人気記事アーカイブ
<Route author="masakichi" example="/hatena/anonymous_diary/archive" path="/hatena/anonymous_diary/archive"/>
### 4399 论坛
<Route author="DIYgod" example="/forum4399/mtag-83932" path="/forum4399/:mtag" :paramsDesc="['mtag,必选-论坛网址最后的mtag字段']" selfhost="1"/>
::: warning 注意
需要用户 cookie 值,详情见部署页面的配置模块。
:::
</Route>

View File

@ -27,36 +27,47 @@ if (config.dida365.username && config.dida365.password) {
module.exports = async (ctx) => {
if (loginFlag) {
const habitsListRes = await got.get({
const habitsRes = await got.get({
url: 'https://api.dida365.com/api/v2/habits',
cookieJar,
});
const habitsList = habitsListRes.data;
const habits = habitsRes.data;
const paramsList = [];
habitsList.forEach((item) => {
habits.forEach((item) => {
paramsList.push(['habitIds', item.id]);
});
const searchParams = new URLSearchParams(paramsList);
const checkinsRes = await got.get({
const habitCheckinsRes = await got.get({
url: 'https://api.dida365.com/api/v2/habitCheckins',
cookieJar,
searchParams,
});
const checkins = checkinsRes.data;
const checkins = habitCheckinsRes.data;
const habitRecordsRes = await got.get({
url: 'https://api.dida365.com/api/v2/habitRecords',
cookieJar,
searchParams,
});
const records = habitRecordsRes.data;
let list = [];
for (const habitId in checkins.checkins) {
const info = habitsList.find((item) => item.id === habitId);
const info = habits.find((item) => item.id === habitId);
list = list.concat(
checkins.checkins[habitId]
.sort((a, b) => a.checkinStamp - b.checkinStamp)
.map((checkin, index) => ({
title: `${index + 1}${info.name}打卡`,
pubDate: `${(checkin.checkinStamp + '').slice(0, 4)}-${(checkin.checkinStamp + '').slice(4, 6)}-${(checkin.checkinStamp + '').slice(6, 8)}`,
link: `https://dida365.com/webapp/#q/all/habit/${checkin.habitId}`,
guid: checkin.id,
}))
.map((checkin, index) => {
const record = records.habitRecords[checkin.habitId].find((re) => re.stamp === checkin.checkinStamp);
return {
title: `${index + 1}${info.name}打卡`,
description: record && record.content,
pubDate: `${(checkin.checkinStamp + '').slice(0, 4)}-${(checkin.checkinStamp + '').slice(4, 6)}-${(checkin.checkinStamp + '').slice(6, 8)}`,
link: `https://dida365.com/webapp/#q/all/habit/${checkin.habitId}`,
guid: checkin.id,
};
})
);
}