Skip to content

Commit

Permalink
✨ feat: 新增 吾爱破解、果壳、快手
Browse files Browse the repository at this point in the history
  • Loading branch information
imsyy committed Dec 5, 2024
1 parent f38d264 commit 161b6b6
Show file tree
Hide file tree
Showing 22 changed files with 288 additions and 1,050 deletions.
5 changes: 1 addition & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,4 @@ REQUEST_TIMEOUT=6000
USE_LOG_FILE=true

# RSS Mode
RSS_MODE=false

# Puppeteer
USE_PUPPETEER=false
RSS_MODE=false
17 changes: 1 addition & 16 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
imsyy/dailyhot-api
ghcr.io/${{ github.repository }}
- name: Build and push regular image (no Puppeteer)
- name: Build and push regular image
uses: docker/build-push-action@v5
with:
context: .
Expand All @@ -54,18 +54,3 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push Puppeteer image (with Puppeteer)
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: |
linux/amd64
linux/arm64
push: true
tags: imsyy/dailyhot-api:web-latest
build-args: |
USE_PUPPETEER=true
labels: ${{ steps.meta.outputs.labels }}

24 changes: 2 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,6 @@ FROM node:20-alpine AS base

ENV NODE_ENV=docker

# 安装 Puppeteer 所需的依赖库
RUN apk add --no-cache \
libc6-compat \
nss \
freetype \
harfbuzz \
ca-certificates

# 判断是否需要安装 Chromium
ARG USE_PUPPETEER=false
RUN if [ "$USE_PUPPETEER" = "true" ]; then \
apk add --no-cache chromium; \
fi

# 配置 Chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

# 清理缓存
RUN rm -rf /var/cache/apk/*

Expand All @@ -33,12 +15,10 @@ COPY package*json tsconfig.json pnpm-lock.yaml .env.example ./
COPY src ./src
COPY public ./public

# add .env.example to .env
# 复制环境变量
RUN [ ! -e ".env" ] && cp .env.example .env || true
RUN if [ "$USE_PUPPETEER" = "true" ]; then \
sed -i 's/^USE_PUPPETEER=false/USE_PUPPETEER=true/' .env; \
fi

# 安装依赖
RUN pnpm install
RUN pnpm build
RUN pnpm prune --production
Expand Down
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<details>
<summary>查看全部接口</summary>

> 实例站点运行于海外服务器,部分国内站点可能存在访问异常,请以实际情况为准
> 示例站点运行于海外服务器,部分国内站点可能存在访问异常,请以实际情况为准
| **站点** | **类别** | **调用名称** | **状态** |
| ---------------- | ------------ | -------------- | --------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -41,13 +41,15 @@
| 知乎日报 | 推荐榜 | zhihu-daily | ![](https://img.shields.io/website.svg?label=zhihu-daily&url=https://api-hot.imsyy.top/zhihu-daily&cacheSeconds=7200) |
| 百度 | 热搜榜 | baidu | ![](https://img.shields.io/website.svg?label=baidu&url=https://api-hot.imsyy.top/baidu&cacheSeconds=7200) |
| 抖音 | 热点榜 | douyin | ![](https://img.shields.io/website.svg?label=douyin&url=https://api-hot.imsyy.top/douyin&cacheSeconds=7200) |
| 快手 | 热点榜 | kuaishou | ![](https://img.shields.io/website.svg?label=kuaishou&url=https://api-hot.imsyy.top/kuaishou&cacheSeconds=7200) |
| 豆瓣电影 | 新片榜 | douban-movie | ![](https://img.shields.io/website.svg?label=douban-movie&url=https://api-hot.imsyy.top/douban-movie&cacheSeconds=7200) |
| 豆瓣讨论小组 | 讨论精选 | douban-group | ![](https://img.shields.io/website.svg?label=douban-group&url=https://api-hot.imsyy.top/douban-group&cacheSeconds=7200) |
| 百度贴吧 | 热议榜 | tieba | ![](https://img.shields.io/website.svg?label=tieba&url=https://api-hot.imsyy.top/tieba&cacheSeconds=7200) |
| 少数派 | 热榜 | sspai | ![](https://img.shields.io/website.svg?label=sspai&url=https://api-hot.imsyy.top/sspai&cacheSeconds=7200) |
| IT之家 | 热榜 | ithome | ![](https://img.shields.io/website.svg?label=ithome&url=https://api-hot.imsyy.top/ithome&cacheSeconds=7200) |
| IT之家「喜加一」 | 最新动态 | ithome-xijiayi | ![](https://img.shields.io/website.svg?label=ithome-xijiayi&url=https://api-hot.imsyy.top/ithome-xijiayi&cacheSeconds=7200) |
| 简书 | 热门推荐 | jianshu | ![](https://img.shields.io/website.svg?label=jianshu&url=https://api-hot.imsyy.top/jianshu&cacheSeconds=7200) |
| 果壳 | 热门文章 | guokr | ![](https://img.shields.io/website.svg?label=guokr&url=https://api-hot.imsyy.top/guokr&cacheSeconds=7200) |
| 澎湃新闻 | 热榜 | thepaper | ![](https://img.shields.io/website.svg?label=thepaper&url=https://api-hot.imsyy.top/thepaper&cacheSeconds=7200) |
| 今日头条 | 热榜 | toutiao | ![](https://img.shields.io/website.svg?label=toutiao&url=https://api-hot.imsyy.top/toutiao&cacheSeconds=7200) |
| 36 氪 | 热榜 | 36kr | ![](https://img.shields.io/website.svg?label=36kr&url=https://api-hot.imsyy.top/36kr&cacheSeconds=7200) |
Expand All @@ -66,7 +68,7 @@
| 虎扑 | 步行街热帖 | hupu | ![](https://img.shields.io/website.svg?label=hupu&url=https://api-hot.imsyy.top/hupu&cacheSeconds=7200) |
| 爱范儿 | 快讯 | ifanr | ![](https://img.shields.io/website.svg?label=ifanr&url=https://api-hot.imsyy.top/ifanr&cacheSeconds=7200) |
| 英雄联盟 | 更新公告 | lol | ![](https://img.shields.io/website.svg?label=lol&url=https://api-hot.imsyy.top/lol&cacheSeconds=7200) |
| 米游社 | 最新消息 | miyoushe | ![](https://img.shields.io/website.svg?label=miyoushe&url=https://api-hot.imsyy.top/miyoushe&cacheSeconds=7200) |
| 米游社 | 最新消息 | miyoushe | ![](https://img.shields.io/website.svg?label=miyoushe&url=https://api-hot.imsyy.top/miyoushe&cacheSeconds=7200) |
| 原神 | 最新消息 | genshin | ![](https://img.shields.io/website.svg?label=genshin&url=https://api-hot.imsyy.top/genshin&cacheSeconds=7200) |
| 崩坏3 | 最新动态 | honkai | ![](https://img.shields.io/website.svg?label=honkai&url=https://api-hot.imsyy.top/honkai&cacheSeconds=7200) |
| 崩坏:星穹铁道 | 最新动态 | starrail | ![](https://img.shields.io/website.svg?label=starrail&url=https://api-hot.imsyy.top/starrail&cacheSeconds=7200) |
Expand Down Expand Up @@ -103,8 +105,6 @@ serveHotApi(3000);

## ⚙️ 部署

由于部分接口无法通过接口调用等方式获取数据,故采用 `Puppeteer` 来实现,但由于使用后会造成 **内存占用过大或镜像过大**,可选择性开启,详情请参考下方说明。

具体使用说明可参考 [我的博客](https://blog.imsyy.top/posts/2024/0408),下方仅讲解基础操作:

### Docker 部署
Expand All @@ -116,8 +116,6 @@ serveHotApi(3000);
```bash
# 构建
docker build -t dailyhot-api .
# 构建 Puppeteer 版
docker build --build-arg USE_PUPPETEER=true -t dailyhot-api .

# 运行
docker run --restart always -p 6688:6688 -d dailyhot-api
Expand All @@ -130,16 +128,14 @@ docker-compose up -d
```bash
# 拉取
docker pull imsyy/dailyhot-api:latest
# 拉取 Puppeteer 版
docker pull imsyy/dailyhot-api:web-latest

# 运行
docker run --restart always -p 6688:6688 -d imsyy/dailyhot-api:latest
```

### 手动部署

最直接的方式,您可以按照以下步骤将 DailyHotApi 部署在您的电脑、服务器或者其他任何地方
最直接的方式,您可以按照以下步骤将 `DailyHotApi` 部署在您的电脑、服务器或者其他任何地方

#### 安装

Expand All @@ -159,10 +155,7 @@ npm install
#### 开发

```bash
# 标准运行
npm run dev
# 采用 Puppeteer 运行
npm run dev:web
```

成功启动后程序会在控制台输出可访问的地址
Expand All @@ -171,11 +164,7 @@ npm run dev:web

```bash
npm run build

# 标准运行
npm run start
# 采用 Puppeteer 运行
npm run start:web
```

成功启动后程序会在控制台输出可访问的地址
Expand Down
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@
"format": "prettier --write .",
"lint": "eslint .",
"dev": "cross-env NODE_ENV=development tsx watch --no-cache src/index.ts",
"dev:web": "cross-env NODE_ENV=development USE_PUPPETEER=true tsx watch --no-cache src/index.ts",
"dev:cache": "cross-env NODE_ENV=development tsx watch src/index.ts",
"build": "tsc --project tsconfig.json",
"start": "cross-env NODE_ENV=development tsx dist/index.js",
"start:web": "cross-env NODE_ENV=development USE_PUPPETEER=true tsx dist/index.js"
"start": "cross-env NODE_ENV=development tsx dist/index.js"
},
"type": "module",
"dependencies": {
Expand All @@ -46,18 +44,18 @@
"dotenv": "^16.4.6",
"feed": "^4.2.2",
"hono": "^4.6.12",
"iconv-lite": "^0.6.3",
"md5": "^2.3.0",
"node-cache": "^5.1.2",
"puppeteer": "^23.10.0",
"puppeteer-cluster": "^0.24.0",
"rss-parser": "^3.13.0",
"winston": "^3.17.0",
"xml2js": "^0.6.2"
"user-agents": "^1.1.379",
"winston": "^3.17.0"
},
"devDependencies": {
"@eslint/js": "^9.16.0",
"@types/md5": "^2.3.5",
"@types/node": "^22.10.1",
"@types/user-agents": "^1.0.4",
"@types/xml2js": "^0.4.14",
"@typescript-eslint/eslint-plugin": "^8.17.0",
"@typescript-eslint/parser": "^8.17.0",
Expand Down
Loading

0 comments on commit 161b6b6

Please sign in to comment.