Skip to content

Commit

Permalink
v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PhiFever committed Dec 16, 2024
1 parent 4c042fb commit 4fb390f
Show file tree
Hide file tree
Showing 9 changed files with 214 additions and 307 deletions.
31 changes: 21 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# only on linux
IS_LINUX := $(shell [ -f /etc/os-release ] || [ -f /etc/lsb-release ] && echo 1 || echo 0)

all: check_os
@echo "begin build"

check_os:
ifeq ($(IS_LINUX),0)
$(error "This Makefile is only for Linux")
endif

# Binary names
BINARY_NAME=AfdianToMarkdown

# Build flags
LDFLAGS=-ldflags "-s -w"
# num of parallel builds
PARALLEL_BUILD=6

# Release directories
RELEASE_DIR=./release
BUILD_DIR=./bin
BUILD_DIR=./build

.PHONY: build windows linux macos clean test release

Expand All @@ -15,25 +28,23 @@ build: windows linux macos

# Build and compress for Windows
windows:
mkdir -p $(BUILD_DIR)/windows
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -p 4 -o $(BUILD_DIR)/windows/$(BINARY_NAME).exe main.go
#卡巴斯基会报毒,所以暂时不使用upx压缩
#upx --best --lzma $(BUILD_DIR)/windows/$(BINARY_NAME).exe
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -p $(PARALLEL_BUILD) -o $(BUILD_DIR)/windows/$(BINARY_NAME).exe main.go

# Build and compress for Linux
linux:
mkdir -p $(BUILD_DIR)/linux
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -p 4 -o $(BUILD_DIR)/linux/$(BINARY_NAME) main.go
upx --best --lzma $(BUILD_DIR)/linux/$(BINARY_NAME)
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -p $(PARALLEL_BUILD) -o $(BUILD_DIR)/linux/$(BINARY_NAME) main.go

# Build and compress for macOS
macos:
mkdir -p $(BUILD_DIR)/macos
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -p 4 -o $(BUILD_DIR)/macos/$(BINARY_NAME) main.go
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -p $(PARALLEL_BUILD) -o $(BUILD_DIR)/macos/$(BINARY_NAME) main.go

# Move and rename the compressed executables
release: build
# sudo apt-get install upx
mkdir -p $(RELEASE_DIR)
# Kaspersky antivirus will report virus, so do not use upx compress
# upx --best --lzma $(BUILD_DIR)/windows/$(BINARY_NAME).exe
upx --best --lzma $(BUILD_DIR)/linux/$(BINARY_NAME)
mv $(BUILD_DIR)/windows/$(BINARY_NAME).exe $(RELEASE_DIR)/$(BINARY_NAME)_windows_amd64.exe
mv $(BUILD_DIR)/linux/$(BINARY_NAME) $(RELEASE_DIR)/$(BINARY_NAME)_linux_amd64
mv $(BUILD_DIR)/macos/$(BINARY_NAME) $(RELEASE_DIR)/$(BINARY_NAME)_darwin_amd64
Expand Down
48 changes: 4 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,47 +19,13 @@
**注意主站域名可能需要手动指定(默认为afdian.com)**

### 构建
- 参见`Makefile`

本程序在go1.23.0下构建,如无编译环境,也可到release页面自行下载对应的可执行文件

```
make build
```
- 本程序在go1.23下构建,如无编译环境,也可到release页面自行下载对应的可执行文件

### 帮助
注:--list功能尚未实现

```
$ .\AfdianToMarkdown.exe -h
NAME:
AfdianToMarkdown - 爱发电下载器,支持按作者或按作品集爬取数据
Github Link: https://github.com/PhiFever/AfdianToMarkdown
USAGE:
eg:
AfdianToMarkdown.exe -au Alice motions
eg:
AfdianToMarkdown.exe -au Alice albums
eg:
AfdianToMarkdown.exe -l album_list.txt
eg:
AfdianToMarkdown.exe update
VERSION:
0.3.0
COMMANDS:
motions 下载指定作者的所有动态
albums 下载指定作者的所有作品集
update 更新所有已经下载的作者的动态和作品集
GLOBAL OPTIONS:
--host value 主站域名,默认为afdian.com,被封可自行更改 (default: "afdian.com")
--author value, --au value 待下载的作者id
--list value, -l value 待下载的作品集id列表文件,每行一个id。(不能与参数-au同时使用)
--help, -h show help
--version, -v print the version
```

### 使用
Expand All @@ -73,13 +39,13 @@ GLOBAL OPTIONS:
#### 下载作者的所有动态

```shell
AfdianToMarkdown.exe --host="ifdian.net" -au "作者id" motions
AfdianToMarkdown.exe motions --host="ifdian.net" -au "作者id"
```

#### 下载作者所有的作品集

```shell
AfdianToMarkdown.exe -au "作者id" albums
AfdianToMarkdown.exe albums -au "作者id"
```

#### 更新所有已经下载的作者的动态和作品集
Expand All @@ -89,12 +55,6 @@ AfdianToMarkdown.exe -au "作者id" albums
AfdianToMarkdown.exe --host="ifdian.net" update
```

#### 下载指定文件中按行分隔的作品集(尚未实现)

```shell
AfdianToMarkdown.exe -l "文件路径"
```

### 更新日志
### v0.4.0
增加了对于漫画作品集的支持(暂未发布)
Expand Down
Loading

0 comments on commit 4fb390f

Please sign in to comment.