1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const NET: &str = "nhentai.net";
const XXX: &str = "nhentai.xxx";
fn get_type(file_type: &str) -> &str {
if file_type == "j" {
"jpg"
} else if file_type == "p" {
"png"
} else {
"gif"
}
}
#[derive(Debug)]
#[allow(clippy::upper_case_acronyms)]
pub enum Website {
NET,
XXX,
}
pub struct Make {
pub mode: Website,
}
impl Make {
pub fn new(mode: Website) -> Make {
Make { mode }
}
pub fn doujin_url(&self, id: &String) -> String {
match self.mode {
Website::NET => format!("https://{}/g/{}", NET, id),
Website::XXX => format!("https://{}/g/{}", XXX, id),
}
}
pub fn cover(&self, media_id: &str, file_type: &str) -> String {
match self.mode {
Website::NET => format!(
"https://t.{}/galleries/{}/cover.{}",
NET,
media_id,
get_type(file_type)
),
Website::XXX => format!(
"https://cdn.{}/g/{}/cover.{}",
XXX,
media_id,
get_type(file_type)
),
}
}
pub fn cover_thumbnail(&self, media_id: &str, file_type: &str) -> String {
match self.mode {
Website::NET => format!(
"https://t.{}/galleries/{}/thumb.{}",
NET,
media_id,
get_type(file_type)
),
Website::XXX => format!(
"https://cdn.{}/g/{}/thumb.{}",
XXX,
media_id,
get_type(file_type)
),
}
}
pub fn page(&self, media_id: &str, number: u32, file_type: &str) -> String {
match self.mode {
Website::NET => format!(
"https://i.{}/galleries/{}/{}.{}",
NET,
media_id,
number.to_string(),
get_type(file_type)
),
Website::XXX => format!(
"https://cdn.{}/g/{}/{}.{}",
XXX,
media_id,
number.to_string(),
get_type(file_type)
),
}
}
#[allow(dead_code)]
pub fn page_thumbnail(&self, media_id: &str, number: u32, file_type: &str) -> String {
match self.mode {
Website::NET => format!(
"https://t.{}/galleries/{}/{}t.{}",
NET,
media_id,
number.to_string(),
get_type(file_type)
),
Website::XXX => format!(
"https://cdn.{}/g/{}/{}t.{}",
XXX,
media_id,
number.to_string(),
get_type(file_type)
),
}
}
}
pub fn doujin(id: u32) -> String {
format!("https://nhentai.net/api/gallery/{}", id.to_string())
}