Skip to content

Commit ff60c54

Browse files
authored
Merge pull request #77 from HanaDigital/master
v3.0.7
2 parents e124ecb + 98f2bf3 commit ff60c54

32 files changed

+854
-169
lines changed

.github/workflows/publish.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ jobs:
6262
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6363
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
6464
with:
65-
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
66-
releaseName: "App v__VERSION__"
65+
tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
66+
releaseName: "NovelScraper v__VERSION__"
6767
releaseBody: |
6868
### Platform Files
69+
Your computer may block you from installing the app. Read more [here](https://github.com/HanaDigital/NovelScraper/wiki/How-to-Install).
70+
6971
**Windows:** `NovelScraper_X.X.X_x64_en-US.msi`
7072
**MacOS:** `NovelScraper_X.X.X_x64.dmg`
7173
**Linux:** You can figure it out :D

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ Download and update translated web/light novels from a list of sites.
3434
List of supported sites:
3535
- [NovelFull](https://novelfull.com/)
3636
- [NovelBin](https://novelbin.com/)
37+
- [Novgo](https://novgo.co)
3738

38-
Author: [@dr-nyt](https://github.com/dr-nyt)
39+
Author: [@dr-nyt](https://github.com/dr-nyt)
3940
Contributors: [@webdagger](https://github.com/webdagger), [@jiskim](https://github.com/jiskim)
40-
Version: 3.0.6
41+
Version: 3.0.7
4142

4243
## FEATURES
4344

@@ -46,14 +47,6 @@ Version: 3.0.6
4647
<img src="https://user-images.githubusercontent.com/41040912/95752022-76181800-0cb0-11eb-9e9c-2627334b0779.png">
4748
</p>
4849

49-
## CONTRIBUTE
50-
51-
Contributing to this project is very straight forward. There is a step-by-step guide on how to add a source to the app.
52-
53-
You can find the contribution guide [here](https://github.com/HanaDigital/NovelScraper/wiki/Contribution-Guide).
54-
55-
## ATTRIBUTION
56-
5750
## LICENSE
5851

5952
```

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "novelscraper",
33
"private": true,
4-
"version": "3.0.6",
4+
"version": "3.0.7",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
@@ -21,6 +21,7 @@
2121
"@tauri-apps/plugin-dialog": "~2",
2222
"@tauri-apps/plugin-fs": "~2",
2323
"@tauri-apps/plugin-opener": "^2.2.6",
24+
"@tauri-apps/plugin-os": "~2",
2425
"@tauri-apps/plugin-shell": "^2.0.1",
2526
"@tauri-apps/plugin-store": "~2",
2627
"@tauri-apps/plugin-updater": "~2",

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.lock

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ futures = "0.3.31"
3232
regex = "1.11.1"
3333
reqwest = "0.12.12"
3434
tauri-plugin-opener = "2.2.6"
35+
tauri-plugin-os = "2"
3536

3637
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
3738
tauri-plugin-updater = "2"

src-tauri/capabilities/default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
],
88
"permissions": [
99
"core:default",
10+
"core:window:allow-destroy",
1011
"shell:allow-open",
1112
"store:default",
1213
"fs:default",
@@ -33,7 +34,6 @@
3334
},
3435
"dialog:default",
3536
"shell:default",
36-
"opener:default",
3737
"opener:default"
3838
]
3939
}

src-tauri/src/docker.rs

Lines changed: 81 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1+
use std::{thread::sleep, time::Duration};
2+
13
use tauri::AppHandle;
4+
use tauri_plugin_os::arch;
25
use tauri_plugin_shell::ShellExt;
36

47
pub fn check_docker_status(app: &AppHandle) -> bool {
58
let shell = app.shell();
6-
let output = tauri::async_runtime::block_on(async move {
7-
shell.command("docker").args(["ps"]).output().await.unwrap()
8-
});
9-
if output.status.success() {
10-
println!("Result: {:?}", String::from_utf8(output.stdout));
11-
return true;
12-
} else {
13-
println!("Exit with code: {}", output.status.code().unwrap());
14-
return false;
9+
match tauri::async_runtime::block_on(async move {
10+
shell.command("docker").args(["ps"]).output().await
11+
}) {
12+
Ok(output) => {
13+
if output.status.success() {
14+
println!("Result: {:?}", String::from_utf8(output.stdout));
15+
return true;
16+
} else {
17+
println!("Exit with code: {}", output.status.code().unwrap());
18+
return false;
19+
}
20+
}
21+
Err(e) => {
22+
println!("Error: {}", e);
23+
return false;
24+
}
1525
}
1626
}
1727

@@ -23,6 +33,30 @@ pub fn start_cloudflare_resolver(app: &AppHandle, port: usize) -> bool {
2333
let shell = app.shell();
2434
let start_cmd = ["start", "novelscraper-cloudflare-resolver"];
2535

36+
match tauri::async_runtime::block_on(async move {
37+
shell.command("docker").args(start_cmd).output().await
38+
}) {
39+
Ok(start_output) => {
40+
if start_output.status.success() {
41+
println!("Result: {:?}", String::from_utf8(start_output.stdout));
42+
return true;
43+
} else {
44+
println!("Exit with code: {}", start_output.status.code().unwrap());
45+
println!("Error: {:?}", String::from_utf8(start_output.stderr));
46+
}
47+
}
48+
Err(e) => {
49+
println!("Error: {}", e);
50+
return false;
51+
}
52+
}
53+
54+
let image = if arch() == "aarch64" {
55+
sleep(Duration::from_secs(1));
56+
"drnyt/cf-clearance-scraper-arm64:latest"
57+
} else {
58+
"zfcsoftware/cf-clearance-scraper:latest"
59+
};
2660
let port_link = format!("{port}:3000");
2761
let run_cmd = [
2862
"run",
@@ -35,39 +69,50 @@ pub fn start_cloudflare_resolver(app: &AppHandle, port: usize) -> bool {
3569
"browserLimit=20",
3670
"-e",
3771
"timeOut=60000",
38-
"zfcsoftware/cf-clearance-scraper:latest",
72+
image,
3973
];
40-
let start_output = tauri::async_runtime::block_on(async move {
41-
shell
42-
.command("docker")
43-
.args(start_cmd)
44-
.output()
45-
.await
46-
.unwrap()
47-
});
48-
if start_output.status.success() {
49-
println!("Result: {:?}", String::from_utf8(start_output.stdout));
50-
return true;
51-
} else {
52-
println!("Exit with code: {}", start_output.status.code().unwrap());
53-
println!("Error: {:?}", String::from_utf8(start_output.stderr));
74+
75+
match tauri::async_runtime::block_on(async move {
76+
shell.command("docker").args(run_cmd).output().await
77+
}) {
78+
Ok(run_output) => {
79+
if run_output.status.success() {
80+
println!("Result: {:?}", String::from_utf8(run_output.stdout));
81+
return true;
82+
} else {
83+
println!("Exit with code: {}", run_output.status.code().unwrap());
84+
println!("Error: {:?}", String::from_utf8(run_output.stderr));
85+
return false;
86+
}
87+
}
88+
Err(e) => {
89+
println!("Error: {}", e);
90+
return false;
91+
}
5492
}
93+
}
5594

56-
let run_output = tauri::async_runtime::block_on(async move {
95+
pub fn stop_cloudflare_resolver(app: &AppHandle) -> bool {
96+
let shell = app.shell();
97+
match tauri::async_runtime::block_on(async move {
5798
shell
5899
.command("docker")
59-
.args(run_cmd)
100+
.args(["stop", "novelscraper-cloudflare-resolver"])
60101
.output()
61102
.await
62-
.unwrap()
63-
});
64-
if run_output.status.success() {
65-
println!("Result: {:?}", String::from_utf8(run_output.stdout));
66-
return true;
67-
} else {
68-
println!("Exit with code: {}", run_output.status.code().unwrap());
69-
println!("Error: {:?}", String::from_utf8(run_output.stderr));
70-
71-
return false;
103+
}) {
104+
Ok(output) => {
105+
if output.status.success() {
106+
println!("Result: {:?}", String::from_utf8(output.stdout));
107+
return true;
108+
} else {
109+
println!("Exit with code: {}", output.status.code().unwrap());
110+
return false;
111+
}
112+
}
113+
Err(e) => {
114+
println!("Error: {}", e);
115+
return false;
116+
}
72117
}
73118
}

src-tauri/src/lib.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ async fn download_novel_chapters(
6868
}
6969
}
7070

71-
#[tauri::command]
72-
async fn fetch_html(url: &str, headers: Option<HashMap<String, String>>) -> Result<String, String> {
73-
source::fetch_html(url, &headers).await
71+
#[tauri::command(rename_all = "snake_case")]
72+
async fn fetch_html(
73+
url: &str,
74+
headers: Option<HashMap<String, String>>,
75+
fetch_type: source::types::FetchType,
76+
) -> Result<String, String> {
77+
source::fetch_html(url, &headers, fetch_type).await
7478
}
7579

7680
#[tauri::command]
@@ -83,12 +87,19 @@ async fn fetch_image(
8387

8488
#[tauri::command]
8589
fn check_docker_status(app: AppHandle) -> bool {
86-
return docker::check_docker_status(&app);
90+
let is_started = docker::check_docker_status(&app);
91+
return is_started;
8792
}
8893

8994
#[tauri::command]
9095
fn start_cloudflare_resolver(app: AppHandle, port: usize) -> bool {
91-
return docker::start_cloudflare_resolver(&app, port);
96+
let is_started = docker::start_cloudflare_resolver(&app, port);
97+
return is_started;
98+
}
99+
100+
#[tauri::command]
101+
fn stop_cloudflare_resolver(app: AppHandle) -> bool {
102+
return docker::stop_cloudflare_resolver(&app);
92103
}
93104

94105
#[derive(Default)]
@@ -159,6 +170,7 @@ pub fn run() {
159170
update_novel_download_status,
160171
check_docker_status,
161172
start_cloudflare_resolver,
173+
stop_cloudflare_resolver,
162174
check_for_update,
163175
install_update
164176
])

0 commit comments

Comments
 (0)