Skip to content

Commit

Permalink
better console progress bar, updated readme, fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ZayrexDev committed Nov 17, 2022
1 parent 5b456ff commit b07294a
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 147 deletions.
79 changes: 39 additions & 40 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This project is still **Not stable**, so it may not work well for now...

### Subcommand fetch

Download picture from specfic source.
Download picture from specific source.

- Usage

Expand All @@ -33,58 +33,57 @@ Download picture from specfic source.

- Arguments

| Argument | Description |
|:---------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| --list-sources | List all the sources |
| -s, --source source_name | Set the source to use. If it's not set, then the program will use the first source in the config. |
| -o, --output output_dictionary | Set the output dictionary. If it's not set, the program will use the dictionary of the program. |
| --arg key1=value1,key2=value2,... | custom the argument in the url. Please see[url](#url) |
| --multi-thread | **Experimental**. Enable multi thread download. <font color=grey>(May improve download speed?)</font> |
| Argument | Description |
| :-------------------------------: | :-----------------------------------------------------------------------------------------------: |
| --list-sources | List all the sources |
| -s, --source source_name | Set the source to use. If it's not set, then the program will use the first source in the config. |
| -o, --output output_dictionary | Set the output dictionary. If it's not set, the program will use the dictionary of the program. |
| --arg key1=value1,key2=value2,... | custom the argument in the url. Please see[url](#url) |
| --multi-thread | **Experimental**. Enable multi thread download. (May improve download speed?) |

### Subcommand schedule

Schedule commands.

- Usage

- Enter `schedule` mode with initial command
- Enter `schedule` mode with initial command

```shell
>java -jar ACGPicDownload.jar schedule [arguments] [fetch command to run]
Schedule>
```
```shell
>java -jar ACGPicDownload.jar schedule [arguments] [fetch command to run]
Schedule>
```

- Only enter `schedule` mode
- Only enter `schedule` mode

```shell
>java -jar ACGPicDownload.jar schedule
Schedule>
```
```shell
>java -jar ACGPicDownload.jar schedule
Schedule>
```

In `schedule` mode, you can use the commands below:

|Command|Description|
|:-------:|:------:|
|add \<argument\> \<command\>|Add fetch event|
|del \<Event id\>|Delete a event|
|list|List all events|
|start|Exit `schedule` mode and start running|
| Command | Description |
| -------------------------- | :------------------------------------: | |
| add \<argument> \<command> | Add fetch event |
| del \<EventID> | Delete a event |
| list | List all events |
| start | Exit `schedule` mode and start running |

- Arguments in `schedule` mode

|Argument|Description|
|:----:|:----:|
| --interval,-i \<interval\> | Set the interval between running, for example `10s` and `2m` |
| --max-times, -m \<max times to run\>|Set the max time to run|

| Argument | Description |
| :----------------------------------: | :----------------------------------------------------------: |
| --interval,-i \<interval\> | Set the interval between running, for example `10s` and `2m` |
| --max-times, -m \<max times to run\> | Set the max time to run |

## <span id="simple-tutorial">...to be more specific?</span>

### Run directly

You can run ACGPicDownload.jar directly, in this case, program will use default `Lolicon` source...

```
```shell
>java -jar ACGPicDownload.jar
[Fetch] Fetching pictures from https://api.lolicon.app/setu/v2?r18=0&num=1 ...
Expand All @@ -100,7 +99,7 @@ If you want to add some customize argument, then you can follow these steps...
1. First, use `--list-sources` to see all the sources...
```
```shell
>java -jar ACGPicDownload.jar --list-sources
[Fetch] Name | Description | URL
Expand Down Expand Up @@ -130,7 +129,7 @@ If you want to add some customize argument, then you can follow these steps...
like:`-s lolicon`,`-o pic`,`--arg num=5`
So, we need to run like this:
```
```shell
>java -jar ACGPicDownload.jar -s lolicon -o pic --arg num=5
[Fetch] Fetching pictures from https://api.lolicon.app/setu/v2?r18=0&num=5 ...
Expand All @@ -150,13 +149,13 @@ If you want to add some customize argument, then you can follow these steps...

2. Next, enter `schedule` mode

```shell
>java -jar ACGPicDownload.jar schedule
Schedule>
```
```shell
>java -jar ACGPicDownload.jar schedule
Schedule>
```

3. If we want to run our command every 10m, run 20 times in total, then we should add `-i 10m` and `-m 20` . So, our event should be like `-i 10m -m 20 -s lolicon -o pic --arg num=5`
3. If we want to run our command every 10m, run 20 times in total, then we should add `-i 10m` and `-m 20` . So, our
event should be like `-i 10m -m 20 -s lolicon -o pic --arg num=5`

4. Last add `add` in front of the event to add a event, then use `start` to run.

Expand All @@ -182,12 +181,12 @@ There are already some sources in the default `sources.json`. You can see them t
An available source should contain the following values in `sources.json`:

| Key | Type | Description | Detail |
|:---------------------------:|:------:|:----------------------------------------------:|:----------------------------------------------------------------------------------:|
| :-------------------------: | :----: | :--------------------------------------------: | :--------------------------------------------------------------------------------: |
| name | String | Name of the source | **Required**. Please make sure that each source has different names. |
| description | String | Description of the source | Optional |
| [returnType](#returnType) | String | The return type of the url | `json` or `redirect`, if it's empty, then the program will choose it automatically |
| [url](#url) | String | The url used to fetch | **Required** |
| [defaultArgs](#defaultArgs) | JSON | The default values of the variables in the url | Optional |
| [defaultArgs](#defaultArgs) | JSON | The default values of the variables in the url | Optional |
| [sourceKey](#sourceKey) | String | The path to image data(s) in the JSON | Optional, if it's empty, the program will try to parse the json directly. |
| [picUrl](#picUrl) | String | The path to image url in each image data | **Required** |
| [nameRule](#nameRule) | String | The naming rules | It tells the program how to name the downloaded images |
Expand Down
73 changes: 37 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@
```shell
java -jar ACGPicDownload.jar fetch [参数]
```

- 参数列表:

| 参数名 | 描述 |
|:---------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------:|
| --list-sources | 列出所有已配置的下载源 |
| -s, --source source_name | 设置需要使用的源,若为空,使用配置下的第一个下载源 |
| -o, --output output_dictionary | 设置下载目录,若为空,则默认为当前目录 |
| --arg key1=value1,key2=value2,... | 自定义URL里的某些参数。 详细请参见[url](#url) |
| --multi-thread | **实验性功能** 启用多线程下载 可能会提升下载速度? |
| 参数名 | 描述 |
| :-------------------------------: | :------------------------------------------------: |
| --list-sources | 列出所有已配置的下载源 |
| -s, --source source_name | 设置需要使用的源,若为空,使用配置下的第一个下载源 |
| -o, --output output_dictionary | 设置下载目录,若为空,则默认为当前目录 |
| --arg key1=value1,key2=value2,... | 自定义URL里的某些参数。 详细请参见[url](#url) |
| --multi-thread | **实验性功能** 启用多线程下载 可能会提升下载速度? |

### <span id="schedule">子指令 schedule</span>

Expand All @@ -63,27 +64,27 @@

`schedule`模式模式下,你可以使用以下指令:

|指令|描述|
|:-------:|:------:|
|add \<参数\> \<指令\>|添加fetch事件|
|del \<指令id\>|删除某一条事件|
|list|列出目前所有添加的事件|
|start|退出`schedule`模式并开始执行事件|
| 指令 | 描述 |
| :-------------------: | :------------------------------: |
| add \<参数\> \<指令\> | 添加fetch事件 |
| del \<指令id\> | 删除某一条事件 |
| list | 列出目前所有添加的事件 |
| start | 退出`schedule`模式并开始执行事件 |

- 参数列表
- 参数列表

|参数名|描述|
|:----:|:----:|
| --interval,-i \<时间间隔\> | 指定每次执行的间隔,例如`10s`,`2m` |
| --max-times, -m \<最大次数\>|指定执行的最大次数|
| 参数名 | 描述 |
| :--------------------------: | :--------------------------------: |
| --interval,-i \<时间间隔\> | 指定每次执行的间隔,例如`10s`,`2m` |
| --max-times, -m \<最大次数\> | 指定执行的最大次数 |

## <span id="tutorial">...说得再具体些?
## <span id="tutorial">...说得再具体些?</span>

### 直接运行

你可以直接使用命令行运行 ACGPicDownload.jar ,这会使用默认的 `lolicon` 源...

```
```shell
>java -jar ACGPicDownload.jar
[Fetch] Fetching pictures from https://api.lolicon.app/setu/v2?r18=0&num=1 ...
Expand Down Expand Up @@ -147,13 +148,13 @@

2. 接下来,先进入 `schedule` 子指令

```shell
>java -jar ACGPicDownload.jar schedule
Schedule>
```
```shell
>java -jar ACGPicDownload.jar schedule
Schedule>
```

3. 假设我们要将上面的指令每10分钟运行一次,总共运行20次,那么我们应该加上 `-i 10m``-m 20` 的参数。那么我们的事件指令应为 `-i 10m -m 20 -s lolicon -o pic --arg num=5`
3. 假设我们要将上面的指令每10分钟运行一次,总共运行20次,那么我们应该加上 `-i 10m``-m 20`
的参数。那么我们的事件指令应为 `-i 10m -m 20 -s lolicon -o pic --arg num=5`

4. 最后,在前面添加 `add` 以添加事件,并用 `start` 开始运行。

Expand All @@ -178,16 +179,16 @@

一个正常的 `sources.json` 应当包含以下的参数:

| 参数名 | 参数类型 | 描述 | 补充说明 |
|:---------------------------:|:-------:|:---------------------------------:|:------------------------------------------------:|
| name | 字符串 | 下载源的名称 | **需要**. 请确保不同的下载源具有不同的名字 |
| description | 字符串 | 下载源的描述 | 可选 |
| [returnType](#returnType) | 字符串 | 下载源的返回类型 | `json`或`redirect`,当为空时,将会尝试自动判断 |
| [url](#url) | 字符串 | 下载URL | **需要** |
| [defaultArgs](#defaultArgs) | JSON | URL中参数的默认值 | 可选 |
| [sourceKey](#sourceKey) | 字符串 | 返回值中指向每张图片数据的路径 | 可选,当为空时,将会直接尝试解析返回值 |
| [picUrl](#picUrl) | 字符串 | 每张图片数据中指向每下载链接的路径 | **需要** |
| [nameRule](#nameRule) | 字符串 | 下载的命名规则 | 可选 |
| 参数名 | 参数类型 | 描述 | 补充说明 |
| :-------------------------: | :------: | :--------------------------------: | :-------------------------------------------: |
| name | 字符串 | 下载源的名称 | **需要**. 请确保不同的下载源具有不同的名字 |
| description | 字符串 | 下载源的描述 | 可选 |
| [returnType](#returnType) | 字符串 | 下载源的返回类型 | `json`或`redirect`,当为空时,将会尝试自动判断 |
| [url](#url) | 字符串 | 下载URL | **需要** |
| [defaultArgs](#defaultArgs) | JSON | URL中参数的默认值 | 可选 |
| [sourceKey](#sourceKey) | 字符串 | 返回值中指向每张图片数据的路径 | 可选,当为空时,将会直接尝试解析返回值 |
| [picUrl](#picUrl) | 字符串 | 每张图片数据中指向每下载链接的路径 | **需要** |
| [nameRule](#nameRule) | 字符串 | 下载的命名规则 | 可选 |

### url

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.18</version>
<version>2.0.19</version>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit b07294a

Please sign in to comment.