def single_chapter(self, chapter_id, comic_name, chapter_number, download_directory, conversion, keep_files): image_api_link = "https://api.mangarockhd.com/query/web400/pages?oid=" + str(chapter_id) source, cookies = globalFunctions.GlobalFunctions().page_downloader(manga_url=image_api_link) json_parse = json.loads(str(source)) 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) links = [] file_names = [] for current_chapter, image_link in enumerate(json_parse["data"]): # file_name = str(json_parse["data"].index(image_link)) + ".mri" current_chapter += 1 file_name = str(globalFunctions.GlobalFunctions().prepend_zeroes(current_chapter, len(json_parse["data"]))) + ".mri" file_names.append(file_name) links.append(image_link) globalFunctions.GlobalFunctions().multithread_download(chapter_number, comic_name, None, directory_path, file_names, links, self.logging) print("Decrypting Files...") self.file_decryption(path_to_files=directory_path) # Calling the method that does the magic! 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, delete_files): chapter_number = str(comic_url).split("/")[5].split("?")[0].replace( "-", " - ") source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url) image_list = re.findall(r"lstImages.push\(\"(.*?)\"\);", str(source)) file_directory = str(comic_name) + '/' + str(chapter_number) + "/" # 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) globalFunctions.GlobalFunctions().info_printer(comic_name, chapter_number) image_len = len(image_list) if str(self.image_quality).lower().strip() in [ "low", "worst", "bad", "cancer", "mobile" ]: print("Downloading In Low Quality...") for link in image_list: link = link.replace("\\", "") # file_name = str(link).split("/")[-1].strip() #file_name = "0" + str(image_list.index(link)) + ".jpg" if len(str(image_list.index(link))) < len(str(image_len)): number_of_zeroes = len(str(image_len)) - len( str(image_list.index(link))) # If a chapter has only 9 images, we need to avoid 0*0 case. if len(str(number_of_zeroes)) == 0: file_name = str(image_list.index(link)) + ".jpg" else: file_name = "0" * int(number_of_zeroes) + str( image_list.index(link)) + ".jpg" else: file_name = str(image_list.index(link)) + ".jpg" logging.debug("Image Link : %s" % link) link = link.replace("=s1600", "=s0") # Change low quality to best. if str(self.image_quality).lower().strip() in [ "low", "worst", "bad", "cancer", "mobile" ]: link = link.replace("=s0", "=s1600") globalFunctions.GlobalFunctions().downloader( link, file_name, comic_url, directory_path) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, delete_files, comic_name, chapter_number) return 0
def single_chapter(self, comic_url, comic_name, download_directory, conversion, delete_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 = str(comic_name) + '/' + str(chapter_number) + "/" # directory_path = os.path.realpath(file_directory) directory_path = os.path.realpath(str(download_directory) + "/" + str(file_directory)) globalFunctions.GlobalFunctions().info_printer(comic_name, chapter_number) if not os.path.exists(directory_path): os.makedirs(directory_path) for x in range(1, last_page_number + 1): chapter_url = str(comic_url) + "/" + str(x) source_new, cookies_new = globalFunctions.GlobalFunctions().page_downloader(manga_url=chapter_url) image_link = "http://www.omgbeaupeep.com/comics/mangas/" + 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) globalFunctions.GlobalFunctions().downloader(image_link, file_name, chapter_url, directory_path, log_flag=self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, delete_files, comic_name, chapter_number) return 0
def single_chapter(self, chapter_url, comic_name, **kwargs): 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 = str(comic_name) + '/' + "Chapter " + str( chapter_number) + "/" directory_path = os.path.realpath(file_directory) if not os.path.exists(file_directory): os.makedirs(file_directory) globalFunctions.GlobalFunctions().info_printer(comic_name, chapter_number) for link in img_links: link = link.replace("\\", "") file_name = "0" + str(link).split("/")[-1].strip() globalFunctions.GlobalFunctions().downloader(link, file_name, chapter_url, directory_path, log_flag=self.logging) 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 full_manga(self, manga_url, comic_name, sorting, download_directory, chapter_range, conversion, delete_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: self.single_chapter(chapter_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) # 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) elif str(sorting).lower() in [ 'old', 'asc', 'ascending', 'oldest', 'a' ]: # print("Running this") for chap_link in all_links[::-1]: self.single_chapter(chapter_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) # 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) print("Finished Downloading") return 0
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, source, comic_url, comic_name, download_directory, conversion, delete_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 = str(comic_name) + '/' + str(chapter_number) + "/" directory_path = os.path.realpath(str(download_directory) + "/" + str(file_directory)) globalFunctions.GlobalFunctions().info_printer(comic_name, chapter_number) if not os.path.exists(directory_path): os.makedirs(directory_path) for image_link in img_list: file_name = str(img_list.index(image_link)) if len(str(file_name)) < len(str(img_list.index(img_list[-1]))): number_of_zeroes = len(str(img_list.index(img_list[-1]))) - len(str(file_name)) # If a chapter has only 9 images, we need to avoid 0*0 case. if len(str(number_of_zeroes)) == 0: file_name = str(img_list.index(image_link)) + "." + str(image_link).split(".")[-1] else: file_name = "0" * int(number_of_zeroes) + str(img_list.index(image_link)) + "." + \ str(image_link).split(".")[-1] else: file_name = str(img_list.index(image_link)) + "." + str(image_link).split(".")[-1] logging.debug("image_link : %s" % image_link) globalFunctions.GlobalFunctions().downloader(image_link, file_name, comic_url, directory_path, log_flag=self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, delete_files, comic_name, chapter_number)
def full_series(self, source, comic_url, comic_name, sorting, download_directory, chapter_range, conversion, delete_files): all_links = re.findall(r'http://striputopija.blogspot.rs/\d+/\d+/\d+|_.html', str(source)) 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 ending = int(str(chapter_range).split("-")[1]) 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, becasue I'm reverting it again at the end. all_links = [all_links[::-1][x] for x in indexes][::-1] else: pass if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in all_links: page_souce, cookies_main = globalFunctions.GlobalFunctions().page_downloader( manga_url=chap_link + ".html") self.single_chapter(source=page_souce, comic_url=chap_link + ".html", comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) elif str(sorting).lower() in ['old', 'asc', 'ascending', 'oldest', 'a']: for chap_link in all_links[::-1]: page_souce, cookies_main = globalFunctions.GlobalFunctions().page_downloader( manga_url=chap_link + ".html") self.single_chapter(source=page_souce, comic_url=chap_link + ".html", comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) print("Finished Downloading") 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 = str(comic_name) + '/' + str(chapter_number) + "/" file_directory = file_directory.replace(":", "-") directory_path = os.path.realpath(file_directory) if not os.path.exists(file_directory): os.makedirs(file_directory) globalFunctions.GlobalFunctions().info_printer(comic_name, chapter_number) print(image_list) 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) globalFunctions.GlobalFunctions().downloader(link_edited, file_name, comic_url, directory_path) return 0
def single_chapter(self, comic_url, comic_name, download_directory, conversion, delete_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 = str(comic_name) + '/' + chapter_number + "/" directory_path = os.path.realpath(str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) globalFunctions.GlobalFunctions().info_printer(comic_name, chapter_number) for image_link in img_list: globalFunctions.GlobalFunctions().downloader(image_link, str(int(img_list.index(image_link)) + 1) + ".jpg", comic_url, directory_path, log_flag=self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, delete_files, comic_name, chapter_number)
def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, conversion, delete_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] # if chapter range contains "__EnD__" write new value to config.json if chapter_range.split("-")[1] == "__EnD__": globalFunctions.GlobalFunctions().saveNewRange( comic_url, len(all_links)) 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 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, delete_files=delete_files) except Exception as e: pass 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, delete_files=delete_files) except Exception as e: pass print("Finished Downloading") return 0
def single_chapter(self, comic_url, comic_name): # 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) img_regex = r'http://imgcomic.naver.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 = str(comic_name) + '/' + str(chapter_number) + "/" directory_path = os.path.realpath(file_directory) if not os.path.exists(file_directory): os.makedirs(file_directory) globalFunctions.GlobalFunctions().info_printer(comic_name, chapter_number) for link in image_list: # link = link.replace("\\", "") # file_name = str(link).split("/")[-1].strip() file_name = "0" + str( image_list.index(link)) + ".jpg" # 0 for #18 (Leading 0s) globalFunctions.GlobalFunctions().downloader(link, file_name, comic_url, directory_path, log_flag=self.logging)
def single_chapter(self, source, comic_url, comic_name, download_directory, conversion, delete_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 = str(comic_name) + '/' + str(chapter_number) + "/" file_directory = file_directory.replace(":", "-") directory_path = os.path.realpath(str(download_directory) + "/" + str(file_directory)) globalFunctions.GlobalFunctions().info_printer(comic_name, chapter_number, total_chapters=len(img_list)) if not os.path.exists(directory_path): os.makedirs(directory_path) 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" globalFunctions.GlobalFunctions().downloader(image_link, file_name, comic_url, directory_path, log_flag=self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, delete_files, comic_name, chapter_number)
def single_chapter(self, chapter_id, comic_name, chapter_number, download_directory, conversion, delete_files): image_api_link = "https://api.mangarockhd.com/query/web400/pages?oid=" + str( chapter_id) source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=image_api_link) json_parse = json.loads(str(source)) file_directory = str(comic_name) + os.sep + str( chapter_number) + os.sep directory_path = os.path.realpath( str(download_directory) + os.sep + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) globalFunctions.GlobalFunctions().info_printer(comic_name, chapter_number) for image_link in json_parse["data"]: file_name = str(json_parse["data"].index(image_link)) + ".mri" globalFunctions.GlobalFunctions().downloader(image_link, file_name, None, directory_path, log_flag=self.logging) print("Decrypting Files...") self.file_decryption(path_to_files=directory_path ) # Calling the method that does the magic! globalFunctions.GlobalFunctions().conversion(directory_path, conversion, delete_files, comic_name, chapter_number)
def single_chapter(self, comic_url, comic_name, download_directory, conversion, delete_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) globalFunctions.GlobalFunctions().info_printer( comic_name, chapter_number, total_chapters=len(img_list)) for page_count, image_link in enumerate(img_list, start=1): globalFunctions.GlobalFunctions().downloader( "https://hqbr.com.br" + str(image_link), str(page_count) + ".jpg", comic_url, directory_path, log_flag=self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, delete_files, comic_name, chapter_number)
def single_chapter(self, chapter_url, comic_name, download_directory, conversion, delete_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 = str(comic_name) + '/' + "Chapter " + str(chapter_number) + "/" # 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) globalFunctions.GlobalFunctions().info_printer(comic_name, chapter_number) print("Img Links : {0}".format(img_links)) print("LEN Img Links : {0}".format(str(len(img_links)))) for link in img_links: new_link = link.replace("\\", "") file_name = str(img_links.index(link)) + ".jpg" globalFunctions.GlobalFunctions().downloader(new_link, file_name, chapter_url, directory_path, log_flag=self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, delete_files, comic_name, chapter_number) return 0
def single_chapter(self, comic_url, comic_name, download_directory, conversion, keep_files): # print("Received Comic Url : {0}".format(comic_url)) print("Fooling CloudFlare...Please Wait...") chapter_number = str(comic_url).split("/")[5].split("?")[0].replace( "-", " - ") source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url, scrapper_delay=10) img_list = re.findall(r"lstImages.push\(\"(.*?)\"\);", str(source)) 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) # image_len = len(image_list) if str(self.image_quality).lower().strip() in [ "low", "worst", "bad", "cancer", "mobile" ]: print("Downloading In Low Quality...") links = [] file_names = [] for current_chapter, image_link in enumerate(img_list): image_link = image_link.replace("\\", "") logging.debug("Image Link : %s" % image_link) image_link = image_link.replace("=s1600", "=s0").replace( "/s1600", "/s0") # Change low quality to best. if str(self.image_quality).lower().strip() in [ "low", "worst", "bad", "cancer", "mobile" ]: image_link = image_link.replace("=s0", "=s1600").replace( "/s0", "/s1600") 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 full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, conversion, delete_files): source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url) all_links = [] chap_holder_div = source.find_all('table', {'id': 'listing'}) for single_node in chap_holder_div: x = single_node.findAll('a') for a in x: all_links.append("http://www.mangareader.net" + str(a['href']).strip()) logging.debug("all_links : %s" % all_links) 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)] # [::-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 str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in all_links: self.single_chapter(comic_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) # if chapter range contains "__EnD__" write new value to config.json if chapter_range != "All" and chapter_range.split( "-")[1] == "__EnD__": globalFunctions.GlobalFunctions().addOne(comic_url) elif str(sorting).lower() in [ 'old', 'asc', 'ascending', 'oldest', 'a' ]: for chap_link in all_links[::-1]: self.single_chapter(comic_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) # if chapter range contains "__EnD__" write new value to config.json if chapter_range != "All" and chapter_range.split( "-")[1] == "__EnD__": globalFunctions.GlobalFunctions().addOne(comic_url) print("Finished Downloading") return 0
def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, conversion, delete_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.co/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]).decode().isdecimal(): 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] #if chapter range contains "__EnD__" write new value to config.json if chapter_range.split("-")[1] == "__EnD__": globalFunctions.GlobalFunctions().saveNewRange( comic_url, len(all_links)) else: chapter_links = chapter_links if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in chapter_links: self.single_chapter(comic_url=str(chap_link), comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) elif str(sorting).lower() in [ 'old', 'asc', 'ascending', 'oldest', 'a' ]: for chap_link in chapter_links[::-1]: self.single_chapter(comic_url=str(chap_link), comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) print("Finished Downloading") 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 full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, conversion, delete_files): # http://mangafox.la/rss/gentleman_devil.xml # Parsing RSS would be faster than parsing the whole page. rss_url = str(comic_url).replace("/manga/", "/rss/") + ".xml" source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=rss_url) # all_links = re.findall(r"href=\"(.*?)\" title=\"Thanks for", str(source)) all_links_temp = re.findall(r"<link/>(.*?).html", str(source)) all_links = ["http:" + str(link) + ".html" for link in all_links_temp] 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[len(all_links) - 1 - x] for x in indexes][::-1] # if chapter range contains "__EnD__" write new value to config.json if chapter_range.split("-")[1] == "__EnD__": globalFunctions.GlobalFunctions().saveNewRange( comic_url, len(all_links)) else: all_links = all_links if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in all_links: self.single_chapter(comic_url=str(chap_link), comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) elif str(sorting).lower() in [ 'old', 'asc', 'ascending', 'oldest', 'a' ]: for chap_link in all_links[::-1]: self.single_chapter(comic_url=str(chap_link), comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) print("Waiting For 5 Seconds...") time.sleep(5) # Test wait for the issue #23 print("Finished Downloading") return 0
def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, conversion, delete_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 str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in all_links: self.single_chapter(comic_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) # if chapter range contains "__EnD__" write new value to config.json if chapter_range.split("-")[1] == "__EnD__": 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]: self.single_chapter(comic_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) # if chapter range contains "__EnD__" write new value to config.json if chapter_range.split("-")[1] == "__EnD__": globalFunctions.GlobalFunctions().addOne(comic_url) print("Finished Downloading") return 0
def single_chapter(self, comic_url, comic_name, download_directory, conversion, delete_files): chapter_number = int(str(comic_url).split("/")[4]) source, cookies = globalFunctions.GlobalFunctions().page_downloader( manga_url=comic_url) """While inspecting this website, I found something cool. We don't have to traverse each and every page to get the next image link. They're incrementing the image file number by "6". For Example : Manga Name : http://www.mangareader.net/shingeki-no-kyojin/100 1st Image : http://i998.mangareader.net/shingeki-no-kyojin/100/shingeki-no-kyojin-10120141.jpg 2nd Image : http://i998.mangareader.net/shingeki-no-kyojin/100/shingeki-no-kyojin-10120147.jpg 3rd Image : http://i999.mangareader.net/shingeki-no-kyojin/100/shingeki-no-kyojin-10120153.jpg 4th Image : http://i999.mangareader.net/shingeki-no-kyojin/100/shingeki-no-kyojin-10120159.jpg Check the increment of 6. """ # Total number of pages in a chapter. total_pages = int( str(re.search(r'</select> of (.*?)</div>', str(source)).group(1)).strip()) img_list = [] image_link = "" img_holder_div = 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) img_list.append(str(image_link).strip()) for image_count in range(1, total_pages): image_link = self.link_builder(image_link) img_list.append(image_link) file_directory = str(comic_name) + '/' + str(chapter_number) + "/" directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) if not os.path.exists(directory_path): os.makedirs(directory_path) globalFunctions.GlobalFunctions().info_printer(comic_name, chapter_number) for image_link in img_list: globalFunctions.GlobalFunctions().downloader( image_link, str(int(img_list.index(image_link)) + 1) + ".jpg", comic_url, directory_path, log_flag=self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, delete_files, comic_name, chapter_number)
def single_chapter(self, comic_url, comic_name, download_directory, conversion, delete_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 = str(comic_name) + '/' + str(chapter_number) + "/" # directory_path = os.path.realpath(file_directory) directory_path = os.path.realpath(str(download_directory) + "/" + str(file_directory)) globalFunctions.GlobalFunctions().info_printer(comic_name, chapter_number) if not os.path.exists(directory_path): os.makedirs(directory_path) 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.co/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) globalFunctions.GlobalFunctions().downloader(image_link, file_name, chapter_url, directory_path, log_flag=self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, delete_files, comic_name, chapter_number) return 0
def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, conversion, delete_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 = "<td><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 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() self.single_chapter(comic_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) # if chapter range contains "__EnD__" write new value to config.json if chapter_range != "All" and chapter_range.split( "-")[1] == "__EnD__": 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() self.single_chapter(comic_url=chap_link, comic_name=comic_name, download_directory=download_directory, conversion=conversion, delete_files=delete_files) # if chapter range contains "__EnD__" write new value to config.json if chapter_range != "All" and chapter_range.split( "-")[1] == "__EnD__": globalFunctions.GlobalFunctions().addOne(comic_url)
def single_chapter(self, comic_url, comic_name, download_directory, conversion, delete_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 = str(comic_name) + '/' + str(chapter_number) + "/" file_directory = file_directory.replace(":", "-") # directory_path = os.path.realpath(file_directory) directory_path = os.path.realpath( str(download_directory) + "/" + str(file_directory)) globalFunctions.GlobalFunctions().info_printer( comic_name, chapter_number, total_chapters=last_page_number) if not os.path.exists(directory_path): os.makedirs(directory_path) for x in range(0, last_page_number + 1): if x is 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" globalFunctions.GlobalFunctions().downloader( ddl_image, file_name, referer, directory_path, cookies=cookies_main, log_flag=self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, delete_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 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 = int( 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, delete_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) img_regex = r'http://imgcomic.naver.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 = str(comic_name) + '/' + str(chapter_number) + "/" file_directory = file_directory.replace(":", "-") # 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) globalFunctions.GlobalFunctions().info_printer( comic_name, chapter_number, total_chapters=len(image_list)) for link in image_list: # link = link.replace("\\", "") # file_name = str(link).split("/")[-1].strip() file_name = "0" + str(image_list.index(link)) + ".jpg" if len(str(file_name)) < len(str(image_list[-1])): number_of_zeroes = len(str(image_list[-1])) - len( str(file_name)) # If a chapter has only 9 images, we need to avoid 0*0 case. if len(str(number_of_zeroes)) == 0: file_name = str(image_list.index(link)) + ".jpg" else: file_name = "0" * int(number_of_zeroes) + str( image_list.index(link)) + ".jpg" else: file_name = str(image_list.index(link)) + ".jpg" globalFunctions.GlobalFunctions().downloader(link, file_name, comic_url, directory_path, log_flag=self.logging) globalFunctions.GlobalFunctions().conversion(directory_path, conversion, delete_files, comic_name, chapter_number) return 0