33import bs4 as bsoup
44import requests
55from collections import defaultdict
6- # from pprint import pprint
76import shutil
87import os
98import concurrent .futures
@@ -50,7 +49,7 @@ def readcomics_download_chapter(url, chapter_num, download_location):
5049 if not os .path .exists (chapter_location ):
5150 os .makedirs (chapter_location )
5251 # Start downloading the urls
53- with concurrent .futures .ThreadPoolExecutor (max_workers = 8 ) as executor :
52+ with concurrent .futures .ThreadPoolExecutor (max_workers = 10 ) as executor :
5453 for image , filename in urls :
5554 executor .submit (download_image , image , filename )
5655 # Convert the folder to a comic book zip filename
@@ -76,17 +75,41 @@ def main():
7675 help = 'Comic urls to download' )
7776 parser .add_argument (
7877 "-l" , "--location" , default = os .getcwd (), help = "set download location" )
78+ parser .add_argument (
79+ "-c" , "--chapters" , default = False ,
80+ help = "Specify chapters to download separated by : (10:20)." )
7981
8082 args = parser .parse_args ()
8183
8284 for url in args .urls :
8385 comic = url .split ('/' )[- 1 ]
8486 print ('Downloading comic: ' + comic )
87+
88+ # Extract chapters
8589 if 'readcomics.tv' in url :
8690 chapters = readcomics_extract_chapters (url )
8791
92+ # Get chapters to download
93+ if args .chapters :
94+ try :
95+ start_stop = args .chapters .split (':' )
96+ if len (start_stop ) == 1 :
97+ keys = [int (start_stop )]
98+ elif len (start_stop ) == 2 :
99+ keys = list (range (
100+ int (start_stop [0 ]), int (start_stop [1 ])+ 1 , 1 ))
101+ else :
102+ raise SyntaxError (
103+ "Chapter inputs should be separated by ':'" )
104+ except TypeError :
105+ raise SyntaxError ("Chapter inputs should be separated by ':'" )
106+ exit ()
107+ else :
108+ keys = chapters .keys
109+
110+ # Download chapters
88111 if 'readcomics.tv' in url :
89- for k in chapters :
112+ for k in keys :
90113 download_location = os .path .join (args .location , comic )
91114 if not os .path .exists (download_location ):
92115 os .makedirs (download_location )
0 commit comments