Skip to content

Commit

Permalink
fix: using addLocalFolder instead of addLocalFolderPromise
Browse files Browse the repository at this point in the history
`addLocalFolderPromise` error with unicode characters.
  • Loading branch information
justorez committed Jan 31, 2024
1 parent c17bf97 commit 1dae01a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 21 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,28 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repo
uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- uses: actions/setup-node@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
cache: 'pnpm'

- run: |
- name: Install deps and build
run: |
pnpm install
pnpm build
- run: npm publish
- name: Publish to npmjs.com
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,24 @@ env:
PICA_DL_SEARCH_KEYWORDS: ${{ inputs.PICA_DL_SEARCH_KEYWORDS }}

jobs:
download_and_compress:
download:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repo
uses: actions/checkout@v4

- name: install pnpm
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: install node
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: install and build
- name: Install deps and build
run: |
pnpm install
pnpm run build
Expand All @@ -65,15 +66,15 @@ jobs:
run: pnpm start

- if: inputs.OUTPUT_ZIP
name: compress
name: Compress
run: pnpm start:zip

- name: upload to github
- name: Upload to github
uses: actions/upload-artifact@v4
with:
name: pica-comics
path: ${{ inputs.OUTPUT_ZIP && 'comics-zip/' || 'comics/' }}
retention-days: 7

- name: upload to file.io
- name: Upload to file.io
run: node scripts/upload.js
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["github.vscode-github-actions"]
}
13 changes: 8 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
- 关键词搜索:支持多选
- 自动过滤已下载的章节和图片,不会重复下载
- 如果没有相关环境变量,则启动交互命令界面;若有则直接执行
- 通过 `pica-zip` 命令分章节批量压缩,配合支持 zip 包的漫画阅读软件使用,比如 [Perfect Viewer](https://play.google.com/store/apps/details?id=com.rookiestudio.perfectviewer)
- 通过 `pica-zip` 命令分章节批量压缩,配合支持 zip 包的漫画阅读软件使用,比如 [Perfect Viewer](https://play.google.com/store/apps/details?id=com.rookiestudio.perfectviewer)<br>
不限于 `pica-cli` 下载的漫画使用,只要符合 [cmoics/漫画标题/漫画章节/漫画图片](#) 的目录结构即可。
- 借助 github action 实现飞速下载,同时将下好的漫画包上传到 github artifact 和 file.io(无需注册和科学上网)
- 借助 github action 实现飞速下载,支持从 github artifact 和 file.io(无需注册和科学上网)两种方式下载完整漫画包。<br>
file.io 文件保存两周,单文件最大 2GB,注意链接只能下载**一次**,下载后文件会自动删除

如果用的开心,求个 star 支持一下,比心 ~ ❤️

Expand Down Expand Up @@ -42,11 +43,13 @@ fork 一份本仓库,将上面三个环境变量,设置为仓库密钥:

![action run](https://s2.loli.net/2024/01/30/PmfublZKLFQrth9.png)

等执行完之后,进入执行详情,点击 Summary,在最下方有漫画的完整压缩包,下载即可。
等执行完之后,进入详情,在最下方有漫画的完整压缩包,下载即可。

![action summary](https://s2.loli.net/2024/01/30/eiRu2B9hovJxOzQ.png)
![artifact](https://s2.loli.net/2024/01/31/rIlTGfy8O5HiFcV.png)

![artifact](https://s2.loli.net/2024/01/30/MJBxVe9UtszNmiv.png)
点击 job 详情查看日志,可以看到 file.io 的下载地址:

![file.io](https://s2.loli.net/2024/01/31/UT4i6zpGjYvDxL3.png)

如果你想自定义过程,请自行修改 [.github/workflows/task.yaml](.github/workflows/task.yaml)

Expand Down
Binary file modified resource/2-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resource/2-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions scripts/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ async function main() {
const task = comics.map(async (comic) => {
try {
const zip = new AdmZip()
await zip.addLocalFolderPromise(path.join(root, comic))
// don't use addLocalFolderPromise, it has bug
zip.addLocalFolder(path.join(root, comic))
const zipBuffer = await zip.toBufferPromise()
const filename = `${comic}.zip`

if (zipBuffer.byteLength < MAX_SIZE) {
const filename = `${comic}.zip`
const file = new File([zipBuffer], filename, {
type: mime.getType('zip')
})
Expand All @@ -41,8 +42,10 @@ async function main() {
form
)
console.log(
`${pico.cyan(comic)} 已上传到 file.io. 下载地址:${pico.green(data.link)}`
`${pico.cyan(filename)} 已上传到 file.io. 下载地址:${pico.green(data.link)}`
)
} else {
console.log(pico.yellow(`${filename} 大小超过了 2GB`))
}
} catch (error) {
console.error(error)
Expand Down

0 comments on commit 1dae01a

Please sign in to comment.