Loading ballontranslator/ui/configpanel.py +2 −1 Original line number Diff line number Diff line Loading @@ -307,7 +307,8 @@ class ConfigPanel(Widget): generalConfigPanel.addTextLabel(label_sources) src_manual_str = self.tr('manual') src_nhentai_str = self.tr('nhentai') self.src_choice_combox = generalConfigPanel.addCombobox([src_manual_str, src_nhentai_str], self.tr('source')) src_mangakakalot_str = self.tr('mangakakalot') self.src_choice_combox = generalConfigPanel.addCombobox([src_manual_str, src_nhentai_str, src_mangakakalot_str], self.tr('source')) self.src_choice_combox.currentIndexChanged.connect(self.on_source_flag_changed) self.src_link_textbox = generalConfigPanel.addLineEdit('source url') self.src_link_textbox.textChanged.connect(self.on_source_link_changed) Loading ballontranslator/ui/dl_manager.py +11 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ dl.translators.SYSTEM_LANG = QLocale.system().name() from .stylewidgets import ProgressMessageBox from .configpanel import ConfigPanel from .misc import ProjImgTrans, DLModuleConfig from .pagesources import SourceBase, nhentai from .pagesources import nhentai, mangakakalot from .constants import PROGRAM_PATH class ModuleThread(QThread): Loading Loading @@ -517,7 +517,8 @@ class DLManager(QObject): LOGGER.info(f'Force download set to {skip_check}') SOURCEMAP = { 0: 'manual', 1: 'nhentai' 1: 'nhentai', 2: 'mangakakalot' } src = SOURCEMAP[self.config.src_choice_flag] if src == 'manual': Loading @@ -528,8 +529,15 @@ class DLManager(QObject): doujin = nhentai() LOGGER.info('Downloading images...') doujin.run(url, skip_check) gallery_number = doujin.ReturnGalleryNumber() gallery_number = doujin.ReturnName() self.imgtrans_proj.load(rf'{PROGRAM_PATH}\ui\pagesources\projects\{gallery_number}') elif src == 'mangakakalot': LOGGER.info('Source download set to mangakakalot') manga = mangakakalot() LOGGER.info('Downloading images...') manga.run(url, skip_check) name = manga.ReturnName() self.imgtrans_proj.load(rf'{PROGRAM_PATH}\ui\pagesources\projects\{name}') else: raise NotImplementedError Loading ballontranslator/ui/pagesources/__init__.py +48 −19 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ from .constants import SOURCE_DOWNLOAD_PATH from .exceptions import SourceNotImplemented import os PROXY = urllib.request.getproxies() Loading @@ -14,11 +15,14 @@ class SourceBase: self.link = '' self.SOURCEMAP = { 0: 'manual', 1: 'nhentai' 1: 'nhentai', 2: 'mangakakalot' } self.source: str = '' self.number_of_pages: int = 0 self.path: str = '' self.path_to_txt: str = '' self.name = '' def SetLink(self, link): self.link = link Loading Loading @@ -58,11 +62,21 @@ class SourceBase: with open(path, 'w') as txt: txt.write(str(self.number_of_pages)) def txt_file(self, number, skip_check): self.path = fr'{SOURCE_DOWNLOAD_PATH}\{number}' self.path_to_txt = rf'{self.path}\pages.txt' skip = False if not os.path.exists(self.path): os.makedirs(self.path) elif os.path.exists(self.path) and skip_check is False: skip = self.CheckFiles(self.path_to_txt) return skip def ReturnName(self): return self.name class nhentai(SourceBase): def __init__(self): super().__init__() self.gallery_number: int = 0 def Help(self): print("""Please use gallery links. To get link follow these steps: + Go to desired doujin Loading @@ -74,15 +88,9 @@ class nhentai(SourceBase): def FetchImages(self, skip_check: bool = False): url = self.link number = (re.search('galleries/(.*)/', url)).group(1) self.gallery_number = number self.name = number i = 1 self.path = fr'{SOURCE_DOWNLOAD_PATH}\{number}' path_to_txt = rf'{self.path}\pages.txt' skip = False if not os.path.exists(self.path): os.makedirs(self.path) elif os.path.exists(self.path) and skip_check is False: skip = self.CheckFiles(path_to_txt) skip = self.txt_file(number, skip_check) if skip is False: while True: try: Loading @@ -97,10 +105,7 @@ class nhentai(SourceBase): print(e) break self.number_of_pages = i - 1 self.SaveNumberOfPages(path_to_txt) def ReturnGalleryNumber(self): return self.gallery_number self.SaveNumberOfPages(self.path_to_txt) def run(self, url, skip_check: bool): self.SetLink(url) Loading @@ -108,7 +113,31 @@ class nhentai(SourceBase): self.FetchImages(skip_check) class mangakakalot(SourceBase): # Does not work yet because of cloudflare def FetchImages(self, skip_check: bool = False): url = self.link self.name = (re.search('chapter/(.*)/chapter', url)).group(1) i = 1 skip = self.txt_file(self.name, skip_check) jpg_link = requests.get(url, proxies=PROXY) jpg_link = (re.search('img src="(.*)/1-o.jpg', jpg_link.text)).group(1) if skip is False: while True: try: img_data = requests.get(f'{jpg_link}/{i}-o.jpg', proxies=PROXY).content if 'access denied' in str(img_data).lower(): break with open(rf'{self.path}\{i}.jpg', 'wb') as image: image.write(img_data) i += 1 time.sleep(1) # Avoiding anti ddos ban except Exception as e: print(e) break self.number_of_pages = i - 1 self.SaveNumberOfPages(self.path_to_txt) def run(self, url, skip_check: bool): self.SetLink(url) self.CheckLink() self.FetchImages(skip_check) Loading
ballontranslator/ui/configpanel.py +2 −1 Original line number Diff line number Diff line Loading @@ -307,7 +307,8 @@ class ConfigPanel(Widget): generalConfigPanel.addTextLabel(label_sources) src_manual_str = self.tr('manual') src_nhentai_str = self.tr('nhentai') self.src_choice_combox = generalConfigPanel.addCombobox([src_manual_str, src_nhentai_str], self.tr('source')) src_mangakakalot_str = self.tr('mangakakalot') self.src_choice_combox = generalConfigPanel.addCombobox([src_manual_str, src_nhentai_str, src_mangakakalot_str], self.tr('source')) self.src_choice_combox.currentIndexChanged.connect(self.on_source_flag_changed) self.src_link_textbox = generalConfigPanel.addLineEdit('source url') self.src_link_textbox.textChanged.connect(self.on_source_link_changed) Loading
ballontranslator/ui/dl_manager.py +11 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ dl.translators.SYSTEM_LANG = QLocale.system().name() from .stylewidgets import ProgressMessageBox from .configpanel import ConfigPanel from .misc import ProjImgTrans, DLModuleConfig from .pagesources import SourceBase, nhentai from .pagesources import nhentai, mangakakalot from .constants import PROGRAM_PATH class ModuleThread(QThread): Loading Loading @@ -517,7 +517,8 @@ class DLManager(QObject): LOGGER.info(f'Force download set to {skip_check}') SOURCEMAP = { 0: 'manual', 1: 'nhentai' 1: 'nhentai', 2: 'mangakakalot' } src = SOURCEMAP[self.config.src_choice_flag] if src == 'manual': Loading @@ -528,8 +529,15 @@ class DLManager(QObject): doujin = nhentai() LOGGER.info('Downloading images...') doujin.run(url, skip_check) gallery_number = doujin.ReturnGalleryNumber() gallery_number = doujin.ReturnName() self.imgtrans_proj.load(rf'{PROGRAM_PATH}\ui\pagesources\projects\{gallery_number}') elif src == 'mangakakalot': LOGGER.info('Source download set to mangakakalot') manga = mangakakalot() LOGGER.info('Downloading images...') manga.run(url, skip_check) name = manga.ReturnName() self.imgtrans_proj.load(rf'{PROGRAM_PATH}\ui\pagesources\projects\{name}') else: raise NotImplementedError Loading
ballontranslator/ui/pagesources/__init__.py +48 −19 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ from .constants import SOURCE_DOWNLOAD_PATH from .exceptions import SourceNotImplemented import os PROXY = urllib.request.getproxies() Loading @@ -14,11 +15,14 @@ class SourceBase: self.link = '' self.SOURCEMAP = { 0: 'manual', 1: 'nhentai' 1: 'nhentai', 2: 'mangakakalot' } self.source: str = '' self.number_of_pages: int = 0 self.path: str = '' self.path_to_txt: str = '' self.name = '' def SetLink(self, link): self.link = link Loading Loading @@ -58,11 +62,21 @@ class SourceBase: with open(path, 'w') as txt: txt.write(str(self.number_of_pages)) def txt_file(self, number, skip_check): self.path = fr'{SOURCE_DOWNLOAD_PATH}\{number}' self.path_to_txt = rf'{self.path}\pages.txt' skip = False if not os.path.exists(self.path): os.makedirs(self.path) elif os.path.exists(self.path) and skip_check is False: skip = self.CheckFiles(self.path_to_txt) return skip def ReturnName(self): return self.name class nhentai(SourceBase): def __init__(self): super().__init__() self.gallery_number: int = 0 def Help(self): print("""Please use gallery links. To get link follow these steps: + Go to desired doujin Loading @@ -74,15 +88,9 @@ class nhentai(SourceBase): def FetchImages(self, skip_check: bool = False): url = self.link number = (re.search('galleries/(.*)/', url)).group(1) self.gallery_number = number self.name = number i = 1 self.path = fr'{SOURCE_DOWNLOAD_PATH}\{number}' path_to_txt = rf'{self.path}\pages.txt' skip = False if not os.path.exists(self.path): os.makedirs(self.path) elif os.path.exists(self.path) and skip_check is False: skip = self.CheckFiles(path_to_txt) skip = self.txt_file(number, skip_check) if skip is False: while True: try: Loading @@ -97,10 +105,7 @@ class nhentai(SourceBase): print(e) break self.number_of_pages = i - 1 self.SaveNumberOfPages(path_to_txt) def ReturnGalleryNumber(self): return self.gallery_number self.SaveNumberOfPages(self.path_to_txt) def run(self, url, skip_check: bool): self.SetLink(url) Loading @@ -108,7 +113,31 @@ class nhentai(SourceBase): self.FetchImages(skip_check) class mangakakalot(SourceBase): # Does not work yet because of cloudflare def FetchImages(self, skip_check: bool = False): url = self.link self.name = (re.search('chapter/(.*)/chapter', url)).group(1) i = 1 skip = self.txt_file(self.name, skip_check) jpg_link = requests.get(url, proxies=PROXY) jpg_link = (re.search('img src="(.*)/1-o.jpg', jpg_link.text)).group(1) if skip is False: while True: try: img_data = requests.get(f'{jpg_link}/{i}-o.jpg', proxies=PROXY).content if 'access denied' in str(img_data).lower(): break with open(rf'{self.path}\{i}.jpg', 'wb') as image: image.write(img_data) i += 1 time.sleep(1) # Avoiding anti ddos ban except Exception as e: print(e) break self.number_of_pages = i - 1 self.SaveNumberOfPages(self.path_to_txt) def run(self, url, skip_check: bool): self.SetLink(url) self.CheckLink() self.FetchImages(skip_check)