def single_chapter(self, comic_url, comic_name, download_directory, conversion, keep_files): chapter_number = str(comic_url).split("/")[-1].strip() source, cookies = globalFunctions.GlobalFunctions().page_downloader(manga_url=comic_url) last_chapter = int(re.findall(r'<option value="(.*?)">(.*?)</option>', str(source))[-1][-1].strip()) # Image URL Structure --> http://www.readcomics.website/uploads/manga/trinity-2016/chapters/2/01.jpg name_of_manga = str(comic_url).split("/")[4] img_list = [] for image_number in range(1, last_chapter + 1): img_list.append("http://www.readcomics.website/uploads/manga/{0}/chapters/{1}/{2}.jpg".format(name_of_manga, chapter_number, str(image_number).zfill(2))) file_directory = globalFunctions.GlobalFunctions().create_file_directory(chapter_number, comic_name) directory_path = os.path.realpath(str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) links = [] file_names = [] for current_chapter, image_link in enumerate(img_list): current_chapter += 1 file_name = str(globalFunctions.GlobalFunctions().prepend_zeroes(current_chapter, len(img_list))) + ".jpg" file_names.append(file_name) links.append(image_link) globalFunctions.GlobalFunctions().multithread_download(chapter_number, comic_name, comic_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number) return 0
def single_chapter(self, comic_url, comic_name, download_directory, conversion, keep_files): chapter_number = re.search(r"cid/(\d+)", str(comic_url)).group(1) source, cookies_main = globalFunctions.GlobalFunctions( ).page_downloader(manga_url=comic_url) base64data = re.findall(r"DATA\s*=\s*'(.+?)'", str(source))[0][1:] data = re.findall(r"data:\s*'(.+?)',", str(source)) nonce = re.findall(r'data-mpmvr="(.+?)"', str(source))[0] logging.debug("base64data : %s" % base64data) # print(base64data) # import sys # sys.exit() img_detail_json = json.loads(self.__decode_base64_data(base64data)) logging.debug("img_detail_json : %s" % img_detail_json) img_list = [] for img_url in img_detail_json.get('picture'): img_list.append(img_url['url']) logging.debug("img_list : %s" % img_list) file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(chapter_number, comic_name) # directory_path = os.path.realpath(file_directory) directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) # for num, image_link in enumerate(img_list): # print(num) links = [] file_names = [] for current_chapter, image_link in enumerate(img_list): # file_name = "0" + str(img_list.index(image_link)) + "." + str(image_link).split(".")[-1] # file_name = str(current_chapter) + '.' + str(image_link).split(".")[-1] current_chapter += 1 file_name = str(globalFunctions.GlobalFunctions().prepend_zeroes( current_chapter, len(img_list))) + ".jpg" logging.debug("image_link : %s" % image_link) file_names.append(file_name) links.append(image_link) globalFunctions.GlobalFunctions().multithread_download( chapter_number, comic_name, comic_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number) return 0
def single_chapter(self, comic_url, comic_name, download_directory, conversion, keep_files): chapter_number = int( str(comic_url).replace("/", "").split("_")[-1].strip()) source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url) try: first_image_link = "http://readcomicbooksonline.net/reader/mangas" \ + str(re.search(r'src="mangas(.*?)\"', str(source)).group(1)).replace(" ", "%20") except: print("Seems like this page doesn't Exist.") print("Or, there's some issue. Open a new 'ISSUE' on Github.") return 1 last_page_number = int( str(re.search(r'</select> of (.*?) <a', str(source)).group(1)).strip()) img_list = [] img_list.append(first_image_link) for page_number in range(1, last_page_number): image_number = first_image_link[-7:].replace(".jpg", "").replace( ".png", "").strip() image_number_string = str(int(image_number) + 1).zfill(3) + ".jpg" image_download_link = first_image_link.replace( image_number + ".jpg", image_number_string) first_image_link = image_download_link img_list.append(image_download_link) file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(chapter_number, comic_name) directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) links = [] file_names = [] for current_chapter, image_link in enumerate(img_list): current_chapter += 1 file_name = str(globalFunctions.GlobalFunctions().prepend_zeroes( current_chapter, len(img_list))) + ".jpg" file_names.append(file_name) links.append(image_link) globalFunctions.GlobalFunctions().multithread_download( chapter_number, comic_name, comic_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number) return 0
def __init__(self, page_id, download_directory, **kwargs): self.page_id = str(page_id).strip() self.manga_name = str(kwargs.get("manga_name")) self.chapter_number = str(kwargs.get("chapter_number")) self.logging = kwargs.get("log_flag") self.conversion = kwargs.get("conversion") self.keep_files = kwargs.get("keep_files") self.json_content = self.json_download(page_id=self.page_id) self.image_links = self.link_lookup(json_source=self.json_content) if self.manga_name == "" or self.chapter_number == "": try: # Python 2 and 3 inputs() form user. On exception, we take it as Python 3 self.manga_name = raw_input("Please Enter Manga Name : ") self.chapter_number = raw_input( "Please Enter Chapter Number : ") except Exception as WrongInputType: # If python3, then raw_input() won't work. self.manga_name = input("Please Enter Manga Name : ") self.chapter_number = input("Please Enter Chapter Number : ") else: pass file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(self.chapter_number, self.manga_name) directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) links = [] file_names = [] for image in self.image_links: link = self.image_links[image] file_name = str(globalFunctions.GlobalFunctions().prepend_zeroes( str(image), len(self.image_links))) + str(link[-4:]) file_names.append(file_name) links.append(link) globalFunctions.GlobalFunctions().multithread_download( self.chapter_number, self.manga_name, None, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, self.conversion, self.keep_files, self.manga_name, self.chapter_number)
def single_chapter(self, manga_url, download_directory, conversion, keep_files): url_splitter = str(manga_url).split('?')[-1].split('&') chapter_number = 0 comic_name = globalFunctions.easySlug( str(manga_url).split('/')[5].replace('-', ' ').title()) for param in url_splitter: if "episode_no" in param.lower().strip(): chapter_number = param.split("=")[-1] break source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=manga_url) file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(chapter_number, comic_name) directory_path = os.path.realpath( str(download_directory) + os.sep + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) images = source.findAll('img') links = [] file_names = [] i = 0 chapter_list = source.find('div', {'id': '_imageList'}) all_links = chapter_list.findAll('img') for link in all_links: file_name = str(globalFunctions.GlobalFunctions().prepend_zeroes( i, len(images))) + ".jpg" file_names.append(file_name) links.append( str(link['data-url']).replace('type=q90', '') if self.quality. lower().strip() == "best" else link['data-url']) i += 1 globalFunctions.GlobalFunctions().multithread_download( chapter_number, comic_name, manga_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number) return 0
def single_chapter(self, chapter_path, comic_id, download_directory): scraper = self.scraper chapter_url = JAPSCAN_URL + chapter_path chapter_name = chapter_path.split('/')[-2] pages = BeautifulSoup(scraper.get(chapter_url).content, features='lxml').find('select', {'id': 'pages'}) page_options = pages.findAll('option', value=True) file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(chapter_name, comic_id) directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) links = [] file_names = [] pbar = tqdm(page_options, leave=True, unit='image(s)', position=0) pbar.set_description('[Comic-dl] Downloading : %s [%s] ' % (comic_id, chapter_name)) for page_tag in page_options: page_url = JAPSCAN_URL + page_tag['value'] page = BeautifulSoup(scraper.get(page_url).content, features='lxml') image_url = page.find('div', {'id': 'image'})['data-src'] links.append(image_url) file_name = image_url.split("/")[-1] file_names.append(file_name) # pbar = tqdm([image_url], leave=True, unit='image(s)', position=0) self.download_image(referer=image_url, directory_path=directory_path, pbar=pbar, image_url=image_url, file_name=file_name)
def full_series(self, comic_id, sorting, download_directory, chapter_range, conversion, keep_files): scraper = self.scraper content = scraper.get(self.manga_url).content chapter_divs = BeautifulSoup(content, features='lxml').findAll( 'div', {'class': 'chapters_list'}) starting, ending = self.compute_start_end(chapter_divs, chapter_range) if self.print_index: idx = 0 for chap_link in chapter_divs[::-1]: idx = idx + 1 print( str(idx) + ": " + re.sub('[\t\r\n]', '', chap_link.find('a').getText())) return 0 for chapter_div in chapter_divs[::-1][starting - 1:ending]: chapter_path = chapter_div.find(href=True)['href'] try: self.single_chapter(chapter_path, comic_id, download_directory) except Exception as ex: break # break to continue processing other mangas # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and ( chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(self.manga_url) return 0
def single_chapter(self, comic_url, comic_name, download_directory, conversion, keep_files): chapter_number = str(comic_url).split("/")[4].strip() source, cookies_main = globalFunctions.GlobalFunctions().page_downloader(manga_url=comic_url) image_url = "http://raw.senmanga.com/viewer/" + str(comic_name).replace(" ", "-") + "/" + str( chapter_number) + "/" page_referer = "http://raw.senmanga.com/" + str(comic_name).replace(" ", "-") + "/" + str(chapter_number) + "/" last_page_number = int(str(re.search(r"</select> of (\d+) <a", str(source)).group(1)).strip()) file_directory = globalFunctions.GlobalFunctions().create_file_directory(chapter_number, comic_name) # directory_path = os.path.realpath(file_directory) directory_path = os.path.realpath(str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) links = [] file_names = [] for x in range(0, last_page_number + 1): if x == 0: pass else: # file_name = "0" + str(x) + ".jpg" # print("File Name : %s" % file_name) ddl_image = str(image_url) + str(x) referer = str(page_referer) + str(x - 1) logging.debug("Image Link : %s" % ddl_image) file_name = str( globalFunctions.GlobalFunctions().prepend_zeroes(x, last_page_number + 1)) + ".jpg" links.append(ddl_image) file_names.append(file_name) globalFunctions.GlobalFunctions().multithread_download(chapter_number, comic_name, comic_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number) return 0
def single_chapter(self, chapter_url, comic_name, download_directory, conversion, keep_files): chapter_number = str(chapter_url).split("/")[8].strip() source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=chapter_url) img_links = self.image_links(source) logging.debug("Img Links : %s" % img_links) file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(chapter_number, comic_name) # directory_path = os.path.realpath(file_directory) directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) print("Img Links : {0}".format(img_links)) print("LEN Img Links : {0}".format(str(len(img_links)))) links = [] file_names = [] for current_chapter, image_link in enumerate(img_links): new_link = image_link.replace("\\", "") # file_name = str(img_links.index(link)) + ".jpg" current_chapter += 1 file_name = str(globalFunctions.GlobalFunctions().prepend_zeroes( current_chapter, len(img_links))) + ".jpg" file_names.append(file_name) links.append(new_link) globalFunctions.GlobalFunctions().multithread_download( chapter_number, comic_name, comic_name, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number) return 0
def single_chapter(self, comic_url, comic_name, download_directory, conversion, keep_files): # http: // comic.naver.com / webtoon / detail.nhn?titleId = 654817 & no = 100 & weekday = tue chapter_number = re.search(r"no=(\d+)", str(comic_url)).group(1) source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url) # https://image-comic.pstatic.net/webtoon/183559/399/20180810173548_ffbf217190f59dc04bd6fc538e11d64b_IMAG01_1.jpg img_regex = r'https?://(?:imgcomic\.naver\.net|image-comic\.pstatic\.net)/webtoon/\d+/\d+/.+?\.(?:jpg|png|gif|bmp|JPG|PNG|GIF|BMP)' image_list = list(re.findall(img_regex, str(source))) logging.debug("Image List : %s" % image_list) file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(chapter_number, comic_name) # directory_path = os.path.realpath(file_directory) directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) print("Directory Path : %s" % str(directory_path)) if not os.path.exists(directory_path): os.makedirs(directory_path) links = [] file_names = [] for current_chapter, image_link in enumerate(image_list): current_chapter += 1 # Fix for #18 file_name = str(globalFunctions.GlobalFunctions().prepend_zeroes( current_chapter, len(image_list))) + ".jpg" file_names.append(file_name) links.append(image_link) globalFunctions.GlobalFunctions().multithread_download( chapter_number, comic_name, comic_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number) return 0
def user_login(self, username, password, **kwargs): session_cookie = "" headers = kwargs.get("headers") if not headers: headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', 'Accept-Encoding': 'gzip, deflate', 'referer': 'https://bato.to/' } print("Getting Auth Token...") page_source, update_cookie = globalFunctions.GlobalFunctions( ).page_downloader( manga_url= "https://bato.to/forums/index.php?app=core&module=global§ion=login" ) soup_parse = page_source.find_all('input', {'type': 'hidden'}) auth_token = str([x['value'] for x in soup_parse][0]).strip() payload = { 'auth_key': auth_token, 'ips_username': username, 'ips_password': password, 'rememberMe': '1' } sess = requests.session() sess = cloudscraper.create_scraper(sess) print('Trying To Log In...') connection = sess.post( "https://bato.to/forums/index.php?app=core&module=global§ion=login&do=process", headers=headers, data=payload, cookies=kwargs.get("cookies")) if connection.status_code != 200: print("Whoops! Seems like I can't connect to website.") print("It's showing : %s" % connection) print( "Run this script with the --verbose argument and report the issue along with log file on Github." ) sys.exit(1) else: page_source = BeautifulSoup(connection.text.encode("utf-8"), "html.parser") if "logout" in str(page_source): print("Successfully Logged In!") else: print( "Couldn't Log You In. Please Check Your Credentials Again!" ) session_cookie = sess.cookies return session_cookie
def single_chapter(self, comic_url, download_directory, conversion, keep_files): comic_name = re.sub(r"[0-9][a-z][A-Z]\ ", "", str(comic_url).split("/")[3].replace("%20", " ").replace("-", " ").title()) source, cookies = globalFunctions.GlobalFunctions().page_downloader(manga_url=comic_url) img_list = [] first_image_link_bs = source.find_all('div', {'class': 'chapter-main'}) # print(first_image_link_bs) for single_node in first_image_link_bs: x = single_node.findAll('img') for a in x: img_list.append(str(a['src']).strip()) # http://www.comicextra.com/steven-universe-ongoing/chapter-13 chapter_number = str(comic_url.split("-")[-1]).replace("/full", "") # print(chapter_number) # total_pages = re.search(r'>of (.*?)</div>', str(source)).group(1) total_pages = len(img_list) # print(total_pages) file_directory = globalFunctions.GlobalFunctions().create_file_directory(chapter_number, comic_name) directory_path = os.path.realpath(str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) links = [] file_names = [] for current_chapter, chapter_link in enumerate(img_list): current_chapter += 1 file_name = str(globalFunctions.GlobalFunctions().prepend_zeroes(current_chapter, len(img_list))) + ".jpg" file_names.append(file_name) links.append(chapter_link) globalFunctions.GlobalFunctions().multithread_download(chapter_number, comic_name, comic_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number) return 0
def single_chapter(self, comic_url, comic_name, download_directory, conversion, keep_files): chapter_number = str( str(comic_url).split("/")[4].strip().replace("_", " ").replace( "-", " ").title()) source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url) img_list = [] temp_list = source.find_all("div", {"class": "chapter-container"}) for elements in temp_list: x = elements.findAll('img') for a in x: img_list.append(str(a['src']).strip()) file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(chapter_number, comic_name) directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) links = [] file_names = [] for current_chapter, image_link in enumerate(img_list): current_chapter += 1 file_name = str(globalFunctions.GlobalFunctions().prepend_zeroes( current_chapter, len(img_list))) + ".jpg" file_names.append(file_name) links.append(image_link) globalFunctions.GlobalFunctions().multithread_download( chapter_number, comic_name, comic_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number) return 0
def single_chapter(self, comic_url, comic_name, download_directory): chapter_number = re.search("(\d+)", str(comic_url)).group(1) # print(chapter_number) source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url) # print(source) image_list = re.findall(r"lstImages\.push\(wrapKA\(\"(.*?)\"\)\);", str(source)) # file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(chapter_number, comic_name) directory_path = os.path.realpath(file_directory) if not os.path.exists(file_directory): os.makedirs(file_directory) print(image_list) links = [] file_names = [] for link in image_list: link_edited = "http://2.bp.blogspot.com/" + link.replace( "\\", "") + ".png" print(link_edited) # file_name = str(link).split("/")[-1].strip() file_name = str(image_list.index(link)) + ".jpg" print(file_name) file_names.append(file_name) links.append(link_edited) globalFunctions.GlobalFunctions().multithread_download( chapter_number, comic_name, comic_url, directory_path, file_names, links) # globalFunctions.GlobalFunctions().multithread_download(chapter_number, comic_name, comic_url, directory_path, # file_names, links, self.logging) return 0
def single_chapter(self, source, comic_url, comic_name, download_directory, conversion, keep_files): short_content = source.findAll('div', {'itemprop': 'description articleBody'}) img_list = re.findall(r'href="(.*?)"', str(short_content)) chapter_number = str(str(comic_url).split("/")[-1]).replace( ".html", "") file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(chapter_number, comic_name) directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) links = [] file_names = [] for current_chapter, image_link in enumerate(img_list): # file_name = str(img_list.index(image_link)) logging.debug("image_link : %s" % image_link) current_chapter += 1 file_name = str(globalFunctions.GlobalFunctions().prepend_zeroes( current_chapter, len(img_list))) + ".jpg" file_names.append(file_name) links.append(image_link) globalFunctions.GlobalFunctions().multithread_download( chapter_number, comic_name, comic_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number) return 0
def single_chapter(self, comic_url, comic_name, download_directory, conversion, keep_files): chapter_number = int(str(comic_url).split("/")[6].strip()) # print(chapter_number) source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url) links_string = re.search(r'pages = \[(.*?)\]', str(source)).group(1) img_list = re.findall(r'\"(.*?)\"', str(links_string)) file_directory = str(comic_name) + '/' + str(chapter_number) + "/" file_directory = file_directory.replace(":", "-") directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) links = [] file_names = [] for page_count, image_link in enumerate(img_list): page_count += 1 file_name = str(globalFunctions.GlobalFunctions().prepend_zeroes( page_count, len(img_list))) + ".jpg" file_names.append(file_name) links.append("https://hqbr.com.br" + str(image_link)) globalFunctions.GlobalFunctions().multithread_download( chapter_number, comic_name, comic_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number) return 0
def single_chapter(self, comic_url, comic_name, download_directory, conversion, keep_files): chapter_number = str(comic_url).split("/")[5].strip() source, cookies_main = globalFunctions.GlobalFunctions( ).page_downloader(manga_url=comic_url) last_page_number = int( re.search(r"</select> of (\d+) <a", str(source)).group(1)) file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(chapter_number, comic_name) # directory_path = os.path.realpath(file_directory) directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) if self.print_index: for x in xrange(1, last_page_number + 1): print(str(x) + ": " + str(comic_url) + "/" + str(x)) return if not os.path.exists(directory_path): os.makedirs(directory_path) links = [] file_names = [] for x in range(1, last_page_number + 1): chapter_url = str(comic_url) + "/" + str(x) image_prefix = "http://www.omgbeaupeep.com/comics/mangas/" if "otakusmash" in comic_url: image_prefix = "https://www.otakusmash.com/read-comics/mangas/" source_new, cookies_new = globalFunctions.GlobalFunctions( ).page_downloader(manga_url=chapter_url) image_link = image_prefix + str( re.search(r'"mangas/(.*?)"', str(source_new)).group(1)).replace(" ", "%20") # file_name = "0" + str(x) + ".jpg" logging.debug("Chapter Url : %s" % chapter_url) logging.debug("Image Link : %s" % image_link) file_name = str(globalFunctions.GlobalFunctions().prepend_zeroes( x, last_page_number + 1)) + ".jpg" links.append(image_link) file_names.append(file_name) globalFunctions.GlobalFunctions().multithread_download( chapter_number, comic_name, comic_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number) return 0
def single_chapter(self, comic_url, comic_name, download_directory, conversion, keep_files): chapter_number = int(str(comic_url).split("/")[4]) source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url) # # Total number of pages in a chapter. total_pages = int( str(re.search(r'</select> of (.*?)</div>', str(source)).group(1)).strip()) # print("Total Pages : {0}".format(total_pages)) file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(chapter_number, comic_name) directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) links = [] file_names = [] for page_number in range(1, total_pages + 1): # print(page_number) # Ex URL : http://www.mangareader.net/boku-no-hero-academia/1/Page_Number next_url = str(comic_url) + "/" + str(page_number) # print("Next URL : {0}".format(next_url)) # Let's use the cookies we established in the main connection and maintain the session. next_source, next_cookies = globalFunctions.GlobalFunctions( ).page_downloader(manga_url=next_url, cookies=cookies) img_holder_div = next_source.find_all('div', {'id': 'imgholder'}) for single_node in img_holder_div: x = single_node.findAll('img') for a in x: image_link = str(a['src']).strip() # print("Image Link : {0}".format(image_link)) file_name = str( globalFunctions.GlobalFunctions().prepend_zeroes( page_number, total_pages)) + ".jpg" links.append(image_link) file_names.append(file_name) globalFunctions.GlobalFunctions().multithread_download( chapter_number, comic_name, comic_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number)
def __init__(self, manga_url, download_directory, chapter_range, **kwargs): conversion = kwargs.get("conversion") keep_files = kwargs.get("keep_files") self.logging = kwargs.get("log_flag") self.sorting = kwargs.get("sorting_order") source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=manga_url) chapter_id = str( re.search(r"window.manga_id2\s*=\s*\"(.*?)\";", str(source)).group(1)) mangaChapters.MangaChapters(chapter_id=chapter_id, download_directory=download_directory, conversion=conversion, keep_files=keep_files, chapter_range=chapter_range, sorting_order=self.sorting, force_download="True", comic_url=manga_url)
def __init__(self, manga_url, download_directory, chapter_range, **kwargs): current_directory = kwargs.get("current_directory") conversion = kwargs.get("conversion") keep_files = kwargs.get("keep_files") self.logging = kwargs.get("log_flag") self.sorting = kwargs.get("sorting_order") self.print_index = kwargs.get("print_index") page_souce, cookies_main = globalFunctions.GlobalFunctions( ).page_downloader(manga_url=manga_url) self.comic_name = self.name_cleaner(page_souce, manga_url) if "/p/" in str(manga_url): self.full_series(source=page_souce, comic_url=manga_url, comic_name=self.comic_name, sorting=self.sorting, download_directory=download_directory, chapter_range=chapter_range, conversion=conversion, keep_files=keep_files) else: self.single_chapter(page_souce, manga_url, self.comic_name, download_directory, conversion, keep_files)
def full_series(self, manga_url, comic_name, download_directory, conversion, keep_files): source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=manga_url) chapters = source.findAll('select', {'name': 'chapter'})[0] bypass_first = "otakusmash" in manga_url for option in chapters.findAll('option'): if self.print_index: print('{}: {}'.format(option['value'], option.text)) else: if bypass_first: # Because this website lists the next chapter, which is NOT available. bypass_first = False continue try: self.single_chapter(manga_url + "/" + str(option['value']), comic_name, download_directory, conversion=conversion, keep_files=keep_files) except Exception as ex: logging.error("Error downloading : %s" % str(option['value'])) break # break to continue processing other mangas
def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, conversion, keep_files): series_name_raw = str(comic_url).split("/")[3].strip() source, cookies = globalFunctions.GlobalFunctions().page_downloader(manga_url=comic_url) # a href="/Flying-Witch-Ishizuka-Chihiro/34/1" link_regex = "<a href=\".*/" + str(series_name_raw) + "/(.*?)\"" all_links = list(re.findall(link_regex, str(source))) logging.debug("All Links : %s" % all_links) # Uh, so the logic is that remove all the unnecessary chapters beforehand # and then pass the list for further operations. if chapter_range != "All": # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! starting = int(str(chapter_range).split("-")[0]) - 1 if str(chapter_range).split("-")[1].isdigit(): ending = int(str(chapter_range).split("-")[1]) else: ending = len(all_links) indexes = [x for x in range(starting, ending)] all_links = [all_links[x] for x in indexes][::-1] else: all_links = all_links if self.print_index: link_regex = "<a href=\".*/" + str(series_name_raw) + "/.*>(.*)</a>" # "<a href="https://raw.senmanga.com/Tokyo-Ghoul:RE/10/1" title="Chapter 10 - Raw">Chapter 10 - Raw</a>" all_links = list(re.findall(link_regex, str(source))) idx = len(all_links) for link in all_links: print(str(idx) + ": " + link) idx = idx - 1 return if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for link in all_links: chap_link = "http://raw.senmanga.com/" + str(series_name_raw) + "/" + str( link).strip() try: self.single_chapter(comic_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, keep_files=keep_files) except Exception as ex: logging.error("Error downloading : %s" % chap_link) break # break to continue processing other mangas # if chapter range contains "__EnD__" write new value to config.json # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and (chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(comic_url) elif str(sorting).lower() in ['old', 'asc', 'ascending', 'oldest', 'a']: for link in all_links[::-1]: chap_link = "http://raw.senmanga.com/" + str(series_name_raw) + "/" + str( link).strip() try: self.single_chapter(comic_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, keep_files=keep_files) except Exception as ex: logging.error("Error downloading : %s" % chap_link) break # break to continue processing other mangas # if chapter range contains "__EnD__" write new value to config.json # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and (chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(comic_url)
def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, conversion, keep_files): source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url) all_links = [] chap_holder_div = source.find_all('div', {'id': 'chapterlist'}) # print(comic_name) for single_node in chap_holder_div: x = single_node.findAll('a') for a in x: all_links.append(str(a['href']).strip()) if chapter_range != "All": # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! starting = int(str(chapter_range).split("-")[0]) - 1 if str(chapter_range).split("-")[1].isdigit(): ending = int(str(chapter_range).split("-")[1]) else: ending = len(all_links) indexes = [x for x in range(starting, ending)] all_links = [all_links[x] for x in indexes][::-1] else: all_links = all_links if not all_links: print("Couldn't Find the chapter list") return 1 # all_links.pop(0) # Because this website lists the next chapter, which is NOT available. if self.print_index: idx = len(all_links) for chap_link in all_links: print(str(idx) + ": " + chap_link) idx = idx - 1 return if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in all_links: try: self.single_chapter(comic_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, keep_files=keep_files) # if chapter range contains "__EnD__" write new value to config.json # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and ( chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(comic_url) except Exception as ex: break # break to continue processing other mangas elif str(sorting).lower() in [ 'old', 'asc', 'ascending', 'oldest', 'a' ]: for chap_link in all_links[::-1]: try: self.single_chapter(comic_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, keep_files=keep_files) # if chapter range contains "__EnD__" write new value to config.json # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and ( chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(comic_url) except Exception as e: break # break to continue processing other mangas return 0
def single_chapter(self, comic_url, comic_name, download_directory, conversion, keep_files): # Some chapters have integer values and some have decimal values. We will look for decimal first. try: chapter_number = re.search(r"c(\d+\.\d+)", str(comic_url)).group(1) except: chapter_number = re.search(r"c(\d+)", str(comic_url)).group(1) source, cookies_main = globalFunctions.GlobalFunctions( ).page_downloader(manga_url=comic_url) last_page_number = str( re.search(r'total_pages\ \=\ (.*?) \;', str(source)).group(1)).strip() file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(chapter_number, comic_name) # directory_path = os.path.realpath(file_directory) directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) links = [] file_names = [] for chapCount in range(1, int(last_page_number) + 1): chapter_url = str(comic_url) + '/%s.html' % chapCount logging.debug("Chapter Url : %s" % chapter_url) source_new, cookies_new = globalFunctions.GlobalFunctions( ).page_downloader(manga_url=chapter_url, cookies=cookies_main) image_link_finder = source_new.findAll('section', {'class': 'read_img'}) for link in image_link_finder: x = link.findAll('img') for a in x: image_link = a['src'] if image_link in [ 'http://www.mangahere.cc/media/images/loading.gif' ]: pass # else: # # file_name = "0" + str(chapCount) + ".jpg" # if len(str(chapCount)) < len(str(last_page_number)): # number_of_zeroes = len(str(last_page_number)) - len(str(chapCount)) # # If a chapter has only 9 images, we need to avoid 0*0 case. # if len(str(number_of_zeroes)) == 0: # file_name = str(chapCount) + ".jpg" # else: # file_name = "0" * int(number_of_zeroes) + str(chapCount) + ".jpg" # else: # file_name = str(chapCount) + ".jpg" logging.debug("Image Link : %s" % image_link) file_name = str( globalFunctions.GlobalFunctions().prepend_zeroes( chapCount, len(x))) + ".jpg" file_names.append(file_name) links.append(image_link) globalFunctions.GlobalFunctions().multithread_download( chapter_number, comic_name, comic_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number) return 0
def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, conversion, keep_files): source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url) all_links = re.findall(r"class=\"color_0077\" href=\"(.*?)\"", str(source)) chapter_links = [] for link in all_links: if 'mangahere.cc/manga/' in link: chapter_links.append(link) else: pass logging.debug("All Links : %s" % all_links) # Uh, so the logic is that remove all the unnecessary chapters beforehand # and then pass the list for further operations. if chapter_range != "All": # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! starting = int(str(chapter_range).split("-")[0]) - 1 if str(chapter_range).split("-")[1].isdigit(): ending = int(str(chapter_range).split("-")[1]) else: ending = len(all_links) indexes = [x for x in range(starting, ending)] chapter_links = [chapter_links[x] for x in indexes][::-1] else: chapter_links = chapter_links if self.print_index: idx = chapter_links.__len__() for chap_link in chapter_links: print(str(idx) + ": " + str(chap_link)) idx = idx - 1 return if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in chapter_links: try: self.single_chapter(comic_url=str(chap_link), comic_name=comic_name, download_directory=download_directory, conversion=conversion, keep_files=keep_files) except Exception as ex: logging.error("Error downloading : %s" % chap_link) break # break to continue processing other mangas # if chapter range contains "__EnD__" write new value to config.json # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and ( chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(comic_url) elif str(sorting).lower() in [ 'old', 'asc', 'ascending', 'oldest', 'a' ]: for chap_link in chapter_links[::-1]: try: self.single_chapter(comic_url=str(chap_link), comic_name=comic_name, download_directory=download_directory, conversion=conversion, keep_files=keep_files) except Exception as ex: logging.error("Error downloading : %s" % chap_link) break # break to continue processing other mangas # if chapter range contains "__EnD__" write new value to config.json # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and ( chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(comic_url) return 0
def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, conversion, keep_files): source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url) # print(source) latest_chapter = re.findall(r"no=(\d+)\&", str(source))[1] all_links = [] for x in range(1, int(latest_chapter) + 1): chapter_url = "http://comic.naver.com/webtoon/detail.nhn?titleId=%s&no=%s" % ( comic_name, x) all_links.append(chapter_url) logging.debug("All Links : %s" % all_links) # Uh, so the logic is that remove all the unnecessary chapters beforehand # and then pass the list for further operations. if chapter_range != "All": # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! starting = int(str(chapter_range).split("-")[0]) - 1 if str(chapter_range).split("-")[1].isdigit(): ending = int(str(chapter_range).split("-")[1]) else: ending = len(all_links) indexes = [x for x in range(starting, ending)] all_links = [all_links[x] for x in indexes][::-1] else: all_links = all_links if self.print_index: idx = 0 for chap_link in all_links: idx = idx + 1 print(str(idx) + ": " + chap_link) return if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in all_links: try: self.single_chapter(comic_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, keep_files=keep_files) except Exception as ex: logging.error("Error downloading : %s" % chap_link) break # break to continue processing other mangas # if chapter range contains "__EnD__" write new value to config.json # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and ( chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(comic_url) elif str(sorting).lower() in [ 'old', 'asc', 'ascending', 'oldest', 'a' ]: # print("Running this") for chap_link in all_links[::-1]: try: self.single_chapter(comic_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, keep_files=keep_files) except Exception as ex: logging.error("Error downloading : %s" % chap_link) break # break to continue processing other mangas # if chapter range contains "__EnD__" write new value to config.json # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and ( chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(comic_url) return 0
def single_chapter(self, comic_url, download_directory, conversion, keep_files, comic_name=None, user_name=None, user_password=None, **kwargs): chapter_id = str(str(comic_url).split("#")[-1]).replace("/", "") temp_cookies = kwargs.get("session_cookies") if str(user_name) != "None" and str(user_password) != "None": print("Trying To Log You In...") temp_cookies = self.user_login(username=user_name, password=user_password) """next_page denotes whether there will be a next page or not. Basically, it's like a flag to know whether we're on the last page or not. page_count starts from 0 and will add 1 to it in every iteration, which will in turn give us page number. TRULY GENIUS! <3 """ comic_name = "" chapter_number = "" file_directory = "" directory_path = "" next_page = True page_count = 1 headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', 'Accept-Encoding': 'gzip, deflate', 'referer': 'https://bato.to/reader' } links = [] file_names = [] while next_page: batoto_reader_url = "https://bato.to/areader?id=" + str( chapter_id) + "&p=" + str(page_count) page_source, temp_cookies = globalFunctions.GlobalFunctions( ).page_downloader(manga_url=batoto_reader_url, headers=headers, cookies=temp_cookies) if not comic_name or not chapter_number or not file_directory: comic_name = self.name_cleaner( re.search(r'https://bato.to/comic/_/comics/(.*?)">', str(page_source)).group(1)) chapter_number = re.sub( '[^0-9]+', '', str(re.search(r'Ch\.(.*?)\:', str(page_source)).group(1))) file_directory = globalFunctions.GlobalFunctions( ).create_file_directory(chapter_number, comic_name) directory_path = os.path.realpath( str(download_directory) + os.sep + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) img_link = page_source.find_all("img", {"id": "comic_page"}) current_image_url = "" for x in img_link: current_image_url = str(x['src']).strip() links.append(current_image_url) file_names.append(str(page_count) + str(current_image_url)[-4:]) try: page_count = int( str( re.search(r"next_page = '(.*?)';", str(page_source)).group(1)).split("_")[-1]) next_page = True except Exception as LastPage: next_page = False pass globalFunctions.GlobalFunctions().multithread_download( chapter_number, comic_name, comic_url, directory_path, file_names, links, self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, keep_files, comic_name, chapter_number)
def full_manga(self, manga_url, comic_name, sorting, download_directory, chapter_range, conversion, keep_files): source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=manga_url) # print(source) chapter_text = source.findAll('div', {'class': 'title'}) all_links = [] for link in chapter_text: x = link.findAll('a') for a in x: url = a['href'] all_links.append(url) logging.debug("All Links : %s" % all_links) # Uh, so the logic is that remove all the unnecessary chapters beforehand # and then pass the list for further operations. if chapter_range != "All": # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! starting = int(str(chapter_range).split("-")[0]) - 1 if str(chapter_range).split("-")[1].isdigit(): ending = int(str(chapter_range).split("-")[1]) else: ending = len(all_links) indexes = [x for x in range(starting, ending)] all_links = [all_links[x] for x in indexes][::-1] else: all_links = all_links if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in all_links: try: self.single_chapter(chapter_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, keep_files=keep_files) except Exception as ex: logging.error("Error downloading : %s" % chap_link) break # break to continue processing other mangas # if chapter range contains "__EnD__" write new value to config.json # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and ( chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(manga_url) elif str(sorting).lower() in [ 'old', 'asc', 'ascending', 'oldest', 'a' ]: # print("Running this") for chap_link in all_links[::-1]: try: self.single_chapter(chapter_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, keep_files=keep_files) except Exception as ex: logging.error("Error downloading : %s" % chap_link) break # break to continue processing other mangas # if chapter range contains "__EnD__" write new value to config.json if chapter_range != "All" and chapter_range.split( "-")[1] == "__EnD__": globalFunctions.GlobalFunctions().addOne(manga_url) return 0
def full_series(self, comic_url, sorting, download_directory, chapter_range, conversion, keep_files): source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url) page_list = source.find('div', {'class': 'detail_lst'}) all_pages = page_list.findAll('a') all_pages_link = [] for page in all_pages: if "/list?" in page["href"]: current_page_url = "https://www.webtoons.com{0}".format( str(page["href"]).replace('&', '&').strip()) all_pages_link.append(current_page_url) all_links = [] chapter_links = [] all_links = self.extract_chapter_links(source=source) for next_page in all_pages_link: source, cookies = globalFunctions.GlobalFunctions( ).page_downloader(manga_url=next_page, cookies=cookies) x = self.extract_chapter_links(source=source) all_links = all_links + x # Uh, so the logic is that remove all the unnecessary chapters beforehand # and then pass the list for further operations. if chapter_range != "All": # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! starting = int(str(chapter_range).split("-")[0]) - 1 if str(chapter_range).split("-")[1].isdigit(): ending = int(str(chapter_range).split("-")[1]) else: ending = len(all_links) if ending > len(all_links): ending = len(all_links) indexes = [x for x in range(starting, ending)] all_links = all_links[::-1] chapter_links = [all_links[x] for x in indexes][::-1] else: chapter_links = all_links if self.print_index: idx = chapter_links.__len__() for chap_link in chapter_links: print(str(idx) + ": " + str(chap_link)) idx = idx - 1 return if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in chapter_links: try: self.single_chapter(manga_url=str(chap_link), download_directory=download_directory, conversion=conversion, keep_files=keep_files) except Exception as ex: self.logging.error("Error downloading : %s" % chap_link) break # break to continue processing other mangas # if chapter range contains "__EnD__" write new value to config.json # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and ( chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(comic_url) elif str(sorting).lower() in [ 'old', 'asc', 'ascending', 'oldest', 'a' ]: for chap_link in chapter_links[::-1]: try: self.single_chapter(manga_url=str(chap_link), download_directory=download_directory, conversion=conversion, keep_files=keep_files) except Exception as ex: self.logging.error("Error downloading : %s" % chap_link) break # break to continue processing other mangas # if chapter range contains "__EnD__" write new value to config.json # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and ( chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(comic_url) return 0
def full_series(self, comic_url, sorting, download_directory, chapter_range, conversion, keep_files, user_name=None, user_password=None, **kwargs): all_links = [] session_cookie = None headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', 'Accept-Encoding': 'gzip, deflate', 'referer': 'https://bato.to/' } if str(user_name) != "None" and str(user_password) != "None": print("Trying To Log You In...") session_cookie = self.user_login(username=user_name, password=user_password) else: print( "You are not logged in. You might not be able to download all the listed chapters from Batoto." ) print("") manga_language = kwargs.get("manga_language") page_source, update_cookie = globalFunctions.GlobalFunctions( ).page_downloader(manga_url=comic_url, headers=headers, cookies=session_cookie) class_name = "row lang_{0} chapter_row".format(manga_language) raw_chapters_table = page_source.find_all('tr', {'class': class_name}) for table_data in raw_chapters_table: x = table_data.findAll('a') for a in x: if "/reader#" in str(a['href']): all_links.append(str(a['href']).strip()) if chapter_range != "All": # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! starting = int(str(chapter_range).split("-")[0]) - 1 if (str(chapter_range).split("-")[1]).decode().isdecimal(): ending = int(str(chapter_range).split("-")[1]) else: ending = len(all_links) indexes = [x for x in range(starting, ending)] # [::-1] in sub_list in beginning to start this from the 1st episode and at the last, # it is to reverse the list again, because I'm reverting it again at the end. all_links = [all_links[x] for x in indexes][::-1] else: all_links = all_links if self.print_index: idx = len(all_links) for chap_link in all_links: print(str(idx) + ": " + chap_link) idx = idx - 1 return if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in all_links: try: self.single_chapter(comic_url=chap_link, download_directory=download_directory, conversion=conversion, keep_files=keep_files, session_cookies=session_cookie) except Exception as ex: break # break to continue processing other mangas # if chapter range contains "__EnD__" write new value to config.json # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and ( chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(comic_url) elif str(sorting).lower() in [ 'old', 'asc', 'ascending', 'oldest', 'a' ]: for chap_link in all_links[::-1]: try: self.single_chapter(comic_url=chap_link, download_directory=download_directory, conversion=conversion, keep_files=keep_files, session_cookies=session_cookie) except Exception as ex: break # break to continue processing other mangas # if chapter range contains "__EnD__" write new value to config.json # @Chr1st-oo - modified condition due to some changes on automatic download and config. if chapter_range != "All" and ( chapter_range.split("-")[1] == "__EnD__" or len(chapter_range.split("-")) == 3): globalFunctions.GlobalFunctions().addOne(comic_url) return 0