@@ -30,6 +30,7 @@ def __init__(self, parent=None):
30
30
31
31
comicNameLabel = QLabel ("漫画名: " )
32
32
self .comicNameLabel = QLabel ("暂无" )
33
+ self .one_folder_checkbox = QCheckBox ("单目录" )
33
34
34
35
comicIntroLabel = QLabel ("简介: " )
35
36
self .comicIntro = QLabel ("暂无" )
@@ -60,13 +61,13 @@ def __init__(self, parent=None):
60
61
mainLayout .addWidget (self .browseButton , 1 , 2 )
61
62
mainLayout .addWidget (comicNameLabel , 2 , 0 )
62
63
mainLayout .addWidget (self .comicNameLabel , 2 , 1 , 1 , 2 )
64
+ mainLayout .addWidget (self .one_folder_checkbox , 2 , 2 )
63
65
mainLayout .addWidget (comicIntroLabel , 3 , 0 )
64
66
mainLayout .addWidget (self .comicIntro , 3 , 1 , 1 , 2 )
65
67
mainLayout .addWidget (chapterGroupBox , 4 , 0 , 1 , 3 )
66
68
mainLayout .addWidget (self .downloadButton , 5 , 2 )
67
69
mainLayout .addWidget (self .statusLabel , 5 , 0 , 1 , 2 )
68
70
69
-
70
71
self .setLayout (mainLayout )
71
72
self .setWindowTitle ("腾讯漫画下载" )
72
73
self .setGeometry (400 , 300 , 800 , 500 )
@@ -135,6 +136,7 @@ def anaysisURL(self):
135
136
136
137
def download (self ):
137
138
self .downloadButton .setText ("下载中..." )
139
+ one_folder = self .one_folder_checkbox .isChecked ()
138
140
139
141
self .enableWidget (False )
140
142
@@ -149,7 +151,7 @@ def download(self):
149
151
if not os .path .isdir (comicPath ):
150
152
os .makedirs (comicPath )
151
153
152
- self .downloadThread = Downloader (selectedChapterList , comicPath , self .contentList , self .contentNameList , self .id )
154
+ self .downloadThread = Downloader (selectedChapterList , comicPath , self .contentList , self .contentNameList , self .id , one_folder )
153
155
self .downloadThread .output .connect (self .setStatus )
154
156
self .downloadThread .finished .connect (lambda : self .enableWidget (True ))
155
157
self .downloadThread .start ()
@@ -158,14 +160,15 @@ class Downloader(QThread):
158
160
output = pyqtSignal (['QString' ])
159
161
finished = pyqtSignal ()
160
162
161
- def __init__ (self , selectedChapterList , comicPath , contentList , contentNameList , id , parent = None ):
163
+ def __init__ (self , selectedChapterList , comicPath , contentList , contentNameList , id , one_folder = False , parent = None ):
162
164
super (Downloader , self ).__init__ (parent )
163
165
164
166
self .selectedChapterList = selectedChapterList
165
167
self .comicPath = comicPath
166
168
self .contentList = contentList
167
169
self .contentNameList = contentNameList
168
170
self .id = id
171
+ self .one_folder = one_folder
169
172
170
173
def run (self ):
171
174
try :
@@ -176,10 +179,11 @@ def run(self):
176
179
forbiddenRE = re .compile (r'[\\/":*?<>|]' ) #windows下文件名非法字符\ / : * ? " < > |
177
180
self .contentNameList [i ] = re .sub (forbiddenRE , '_' , self .contentNameList [i ])
178
181
contentPath = os .path .join (self .comicPath , '第{0:0>4}话-{1}' .format (i + 1 , self .contentNameList [i ]))
179
- if not os .path .isdir (contentPath ):
180
- os .mkdir (contentPath )
182
+ if not self .one_folder :
183
+ if not os .path .isdir (contentPath ):
184
+ os .mkdir (contentPath )
181
185
imgList = getComic .getImgList (self .contentList [i ], self .id )
182
- getComic .downloadImg (imgList , contentPath )
186
+ getComic .downloadImg (imgList , contentPath , self . one_folder )
183
187
184
188
self .output .emit ('完毕!' )
185
189
0 commit comments