-
Notifications
You must be signed in to change notification settings - Fork 0
/
HentaiSaver_1.4.2_aria2_beta.py
245 lines (220 loc) · 8.53 KB
/
HentaiSaver_1.4.2_aria2_beta.py
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
import os
import re
import time
import requests
#初始化变量
localna = os.getcwd()
global hostnull
if os.path.exists(localna+'\\site.ini'):
with open(localna+'\\site.ini','r',encoding='GBK') as f:
hostnull = f.read()
elif not os.path.exists(localna+'\\site.ini'):
hostnull = 'https://zhb.nyabus.com/'
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3861.400 QQBrowser/10.7.4313.400'}
ar = localna+'\\aria2-1.35.0-win-64bit-build1\\aria2c.exe -i '
def hentaisaver(id,a=localna,host1=hostnull,dir=os.pardir):
global local
local = a
titledate = id
print(titledate+'正在解析')
htmlba = requests.get(host1+'g/'+titledate+'/list2/',headers=headers).content.decode()
titlehtml = requests.get(host1+'g/'+titledate,headers=headers).content.decode()
print(titledate+'解析完成')
#获取基本数据
global title
titleset = ">(.*?) »"
title = re.findall(titleset,titlehtml)
title = str(title[0])
titlehtml = 0
#提取标题
os.makedirs(title,exist_ok=True)
print(title+'正在下载中——')
images = re.findall('data-src=\"(.*?)\"' ,htmlba)
if not os.path.exists(localna+'\\'+id+'.aria'):
with open(localna+'\\'+id+'.aria','w',encoding='GBK') as f:
for a in images:
f.write(a+'\n')
save(localna+'\\'+id+'.aria',localna+'\\'+title)
os.rename(localna+'\\'+id+'.aria',localna+'\\'+id+'.log')
return ('\n'+title+'下载已完成,按任意键开始新任务')
def save(url,url_dir):
os.chdir(url_dir)
os.system(ar+url)
os.chdir(localna)
#
#
#ID提取
def hentai_ar_all(id,type,language='ch',host1=hostnull):
global a_list
print(id+'作品提取中。。。')
if language == 'ch':
a_date = requests.get(host1+type+'/'+id+'/chinese',headers=headers).content.decode()
elif language == 'ja':
a_date = requests.get(host1+type+'/'+id,headers=headers).content.decode()
a_list = re.findall('<a href="/g/(.*?)/" c',a_date)
#提取页数
a_num = re.findall('</span> <span class="count">(.*?)</span>',a_date)
num = 0
a_page = 1
a_num = a_num[0][1:-1]
print('作品ID提取完毕,共有'+str(a_num)+'本')
while 1==1:
num = 25+num
a_page = 1+a_page
if num >= int(a_num):
break
print('作品共有'+str(a_page)+'页')
for a in range(2,a_page):
a_shenxia = a_page-a
print('第'+str(a)+'页提取中,还有'+str(a_shenxia)+'页')
if language == 'ch':
a_date = requests.get(host1+type+'/'+id+'/chinese'+'/page/'+str(a),headers=headers).content.decode()
elif language == 'ja':
a_date = requests.get(host1+type+'/'+id+'/page/'+str(a),headers=headers).content.decode()
a_list_nu = re.findall('<a href="/g/(.*?)/" c',a_date)
print('第'+str(a)+'页提取完毕,还有'+str(a_shenxia)+'页')
#追加列表
a_list = a_list+a_list_nu
print("提取完毕,共有"+str(len(a_list))+'页')
time.sleep(1)
return a_list
def id_get(a):
if a[0:2] == 'ar':
if a[2:4] == 'ja':
list = hentai_ar_all(a[4:],'artist','ja',hostnull)
return list
a = a[2:]
list = hentai_ar_all(a,'artist','ch',hostnull)
return list
elif a[0:2] == 'gr':
if a[2:4] == 'ja':
list = hentai_ar_all(a[4:],'group','ja',hostnull)
return list
a = a[2:]
list = hentai_ar_all(a,'group','ch',hostnull)
return list
elif a[0:2] == 'ch':
if a[2:4] == 'ja':
list = hentai_ar_all(a[4:],'character','ja',hostnull)
return list
a = a[2:]
list = hentai_ar_all(a,'character','ch',hostnull)
return list
elif a[0:2] == 'ta':
if a[2:4] == 'ja':
list = hentai_ar_all(a[4:],'tag','ja',hostnull)
return list
a = a[2:]
list = hentai_ar_all(a,'tag','ch',hostnull)
return list
elif a[0:2] == 'pa':
if a[2:4] == 'ja':
list = hentai_ar_all(a[4:],'parody','ja',hostnull)
return list
a = a[2:]
list = hentai_ar_all(a,'parody','ch',hostnull)
return list
return 0
def clean(a):
if "http" in a:
if "/g/" in a:
a = re.findall('/g/(.*?)/',a)
a = a[0]
elif "/group/" in a:
a = re.findall('/group/(.*?)/',a)
a = "grja"+a[0]
elif "/group/" in a and "/chinese" in a :
a = re.findall('/group/(.*?)/chinese',a)
a = "gr"+a[0]
elif "/artist/" in a:
a = re.findall('/artist/(.*?)/',a)
a = "arja"+a[0]
elif "/artist/" in a and "/chinese" in a :
a = re.findall('/artist/(.*?)/chinese',a)
a = "ar"+a[0]
elif "/character/" in a:
a = re.findall('/character/(.*?)/',a)
a = "chja"+a[0]
elif "/character/" in a and "/chinese" in a :
a = re.findall('/character/(.*?)/chinese',a)
a = "ch"+a[0]
elif "/tag/" in a:
a = re.findall('/tag/(.*?)/',a)
a = "taja"+a[0]
elif "/tag/" in a and "/chinese" in a :
a = re.findall('/tag/(.*?)/chinese',a)
a = "ta"+a[0]
elif "/parody/" in a:
a = re.findall('/parody/(.*?)/',a)
a = "paja"+a[0]
elif "/parody/" in a and "/chinese" in a :
a = re.findall('/parody/(.*?)/chinese',a)
a = "pa"+a[0]
return a
os.system('title HentaiSaver 1.4.2 BETA')
os.system('color 02')
work_list = []
while 1==1:
try:
os.system('cls')
os.system('color 02')
print('MADE IN xuexia\nmaker 千反田爱瑠\n用于在线本子网站本子下载\n支持nhentai,nyahentai等使用相同模板的网站\n下载使用aria2c实现多并发下载\n可读取文本文件中的ID实现批量下载\npower by python\n1.4.2修复版\n最新版本请至xuexia15.org获取\n')
print("目前列表中有"+str(len(work_list))+"个任务\n")
a = input('请输入所需要解析的文件、画师、团体、tag、本子ID[输入y开始下载列表任务]:')
#文本读取
if os.path.isfile(a):
with open(a,'r',encoding='GBK') as f:
read_list = f.readlines()
for a in read_list:
a = str(a)
a = clean(a)
#批量提取
list = id_get(a)
if not list == 0:
print("已添加"+str(len(list))+"个任务")
work_list = work_list + list
continue
#id
if not os.path.isfile(a) and int(a) > 0 and int(a) < 999999:
work_list.append(a)
print("目前列表中有"+str(len(work_list))+"个任务")
continue
a = clean(a)
if a == "y" and len(work_list) > 0:
os.system("cls")
print("列表任务开始解析。。。")
for work in work_list:
os.system("cls")
time.sleep(1)
hentaisaver(work)
work_list.remove(work)
print("目前列表中有"+str(len(work_list))+"个任务")
os.system("cls")
input("所有任务下载完成,按任意键继续")
continue
#批量提取
list = id_get(a)
if not list == 0:
print("已添加"+str(len(list))+"个任务")
work_list = work_list + list
continue
try:
if not os.path.isfile(a) and int(a) < 0 and int(a) > 999999:
os.system('color 04')
input('输入不正确,请重试')
os.system('cls')
continue
except TypeError as e:
os.system('color 04')
input('输入不正确,请重试')
os.system('cls')
continue
#id
if not os.path.isfile(a) and int(a) > 0 and int(a) < 999999:
work_list.append(a)
print("任务加入成功")
time.sleep(1)
continue
os.system('cls')
except:
continue