@@ -153,7 +153,7 @@ def get_chapters(vid_id, limit_rate):
153
153
print_err ("Error: Wrong link. No video found." )
154
154
155
155
title = details ["title" ]
156
- title = re .sub (r"[<>|/\\?* ]" , "_" ,title );
156
+ title = re .sub (r"[^\w\s\d.,\+\$\%\#\@\!\(\)\[\]\-\{\} ]" , "_" ,title );
157
157
os .makedirs (title , 0o755 , exist_ok = True )
158
158
159
159
url = 'https://static.packt-cdn.com/products/{}/toc' .format (vid_id )
@@ -166,18 +166,19 @@ def get_chapters(vid_id, limit_rate):
166
166
all_chapters = details ['chapters' ]
167
167
for x ,i in enumerate (all_chapters ):
168
168
section = i ['title' ]
169
- section = re .sub (r"[<>|/\\?* ]" , "_" , section )
169
+ section = re .sub (r"[^\w\s\d.,\+\$\%\#\@\!\(\)\[\]\-\{\} ]" , "_" , section )
170
170
s_path = "{}{}{:02}-{}" .format (title , os .sep , x + 1 , section )
171
171
os .makedirs (s_path , 0o755 , exist_ok = True )
172
- print (bcolors .OKGREEN + "\n Chapter {}/{}:" .format (x + 1 , len (all_chapters )), section , "\n " + bcolors .ENDC )
172
+ print (bcolors .OKGREEN + "\n Chapter {}/{} ({} videos) :" .format (x + 1 , len (all_chapters ), len ( i [ 'sections' ] )), section , "\n " + bcolors .ENDC )
173
173
for y ,c in enumerate (i ['sections' ]):
174
174
chapter = c ['title' ]
175
- chapter = re .sub (r"[<>|/\\?* ]" , "_" , chapter )
175
+ chapter = re .sub (r"[^\w\s\d.,\+\$\%\#\@\!\(\)\[\]\-\{\} ]" , "_" , chapter )
176
176
c_path = "{}{}{:02}-{}.mp4" .format (s_path , os .sep , y + 1 , chapter )
177
177
video_id = i ['id' ] + '/' + c ['id' ]
178
178
video_url = get_video_url (vid_id , video_id )
179
179
download_url (video_url , c_path , limit_rate )
180
180
181
+
181
182
182
183
def start_download (username , password , vid_id , limit_rate ):
183
184
login (username , password )
0 commit comments