def run(self): if self.site_name == 'dm5': from sites import DM5 as SiteClass elif self.site_name == 'ck101': from sites import Ck101 as SiteClass elif self.site_name == 'dmzj': from sites import Dmzj as SiteClass elif self.site_name == 'manhua_dmzj': from sites import manhua_Dmzj as SiteClass elif self.site_name == 'ehentai': from sites import Ehentai as SiteClass try: self.website_object = SiteClass(self.user_input_url) self.comic_name = self.website_object.get_name() self.ref_box = self.website_object.get_parent_info() self.status_report_signal.emit( '%s, total %d chapters detected.' % (self.comic_name, len(self.ref_box))) if self.latest_limit is not False: if self.latest_limit > len(self.ref_box): raise ValueError self.ref_box = self.ref_box[-self.latest_limit:] self.main_loop(self.ref_box) except ValueError: self.stop_signal.emit( 'Chapters selected out of range, maximum %s chapters' % len(self.ref_box)) except ConnectionError as e: self.stop_signal.emit('%s, consider using a proxy or a VPN.' % e)
class WorkingThread(QThread): status_report_signal = pyqtSignal(str) progress_report_signal = pyqtSignal(float) stop_signal = pyqtSignal(str) def __init__(self, site_name, url, checkbox_value): super(WorkingThread, self).__init__() self.site_name = site_name self.user_input_url = url self.latest_limit = checkbox_value def run(self): if self.site_name == 'dm5': from sites import DM5 as SiteClass elif self.site_name == 'ck101': from sites import Ck101 as SiteClass elif self.site_name == 'dmzj': from sites import Dmzj as SiteClass elif self.site_name == 'ehentai': from sites import Ehentai as SiteClass try: self.website_object = SiteClass(self.user_input_url) self.comic_name = self.website_object.get_name() self.ref_box = self.website_object.get_parent_info() self.status_report_signal.emit('%s, total %d chapters detected.' % (self.comic_name, len(self.ref_box))) if self.latest_limit is not False: if self.latest_limit > len(self.ref_box): raise ValueError self.ref_box = self.ref_box[-self.latest_limit:] self.main_loop(self.ref_box) except ValueError as e: self.stop_signal.emit('Chapters selected out of range, maximum %s chapters' % len(self.ref_box)) except ConnectionError as e: self.stop_signal.emit('%s, consider using a proxy or a VPN.' % e) def main_loop(self, refer_box): for ref_tuple in refer_box: title, parent_link = ref_tuple total_page = self.website_object.get_page_info(parent_link) for page in range(1, total_page + 1): vague_path = self.website_object.get_path(self.comic_name, title, page) + '*' if glob.glob(vague_path): self.status_report_signal.emit('%s page %d already existed.' % (title, page)) else: try: link = self.website_object.get_image_link(parent_link, page) self.status_report_signal.emit('Downloading %s' % title) self.website_object.down(self.comic_name, parent_link, link, title, page) progress = page / self.website_object.get_page_info(parent_link) self.progress_report_signal.emit(progress * 100) except: errlog = 'Error occurred when downloading %s, Page %d.' % (title, page) self.status_report_signal.emit(errlog) self.stop_signal.emit('All Done!')
class WorkingThread(QThread): status_report_signal = pyqtSignal(str) progress_report_signal = pyqtSignal(float) stop_signal = pyqtSignal(str) def __init__(self, site_name, url, checkbox_value): super(WorkingThread, self).__init__() self.site_name = site_name self.user_input_url = url self.latest_limit = checkbox_value def run(self): if self.site_name == 'dm5': from sites import DM5 as SiteClass elif self.site_name == 'ck101': from sites import Ck101 as SiteClass self.website_object = SiteClass(self.user_input_url) self.comic_name = self.website_object.get_name() self.ref_box = self.website_object.get_parent_info() self.status_report_signal.emit('%s, total %d chapters detected.' % (self.comic_name, len(self.ref_box))) try: if self.latest_limit is not False: if self.latest_limit > len(self.ref_box): raise ValueError self.ref_box = self.ref_box[-self.latest_limit:] self.main_loop(self.ref_box) except ValueError as e: self.stop_signal.emit( 'Chapters selected out of range, maximum %s chapters' % len(self.ref_box)) def main_loop(self, refer_box): for ref_tuple in refer_box: title, parent_link = ref_tuple total_page = self.website_object.get_page_info(parent_link) for page in range(1, total_page + 1): link = self.website_object.get_image_link(parent_link, page) try: self.status_report_signal.emit('Downloading %s' % title) self.website_object.down(self.comic_name, parent_link, link, title, page) progress = page / self.website_object.get_page_info( parent_link) self.progress_report_signal.emit(progress * 100) except: errlog = 'Error occurred when downloading %s, Page %d.' % ( title, page) self.status_report_signal.emit(errlog) self.stop_signal.emit('All Done!')
def run(self): if self.site_name == 'dm5': from sites import DM5 as SiteClass elif self.site_name == 'ck101': from sites import Ck101 as SiteClass self.website_object = SiteClass(self.user_input_url) self.comic_name = self.website_object.get_name() self.ref_box = self.website_object.get_parent_info() self.status_report_signal.emit('%s, total %d chapters detected.' % (self.comic_name, len(self.ref_box))) try: if self.latest_limit is not False: if self.latest_limit > len(self.ref_box): raise ValueError self.ref_box = self.ref_box[-self.latest_limit:] self.main_loop(self.ref_box) except ValueError as e: self.stop_signal.emit('Chapters selected out of range, maximum %s chapters' % len(self.ref_box))
def run(self): if self.site_name == 'dm5': from sites import DM5 as SiteClass elif self.site_name == 'ck101': from sites import Ck101 as SiteClass self.website_object = SiteClass(self.user_input_url) self.comic_name = self.website_object.get_name() self.ref_box = self.website_object.get_parent_info() self.status_report_signal.emit('%s, total %d chapters detected.' % (self.comic_name, len(self.ref_box))) try: if self.latest_limit is not False: if self.latest_limit > len(self.ref_box): raise ValueError self.ref_box = self.ref_box[-self.latest_limit:] self.main_loop(self.ref_box) except ValueError as e: self.stop_signal.emit( 'Chapters selected out of range, maximum %s chapters' % len(self.ref_box))
print('Options:\n\t-u\t Download comics from specific origin') print('\t-l\tOptional. Download latest x chapters from origin') print('\t-h\tPrint this help') sys.exit() elif opt in ('-u', '--url'): user_input_url = arg elif opt in ('-l', '--latest'): fetch_latest = int(arg) except getopt.GetoptError as e: print('%s\n\nUsage: python3 driveit.py -u <URL>\nSee driveit.py -h for details' % e) sys.exit(2) base = SharedBase(user_input_url) if base.get_site_name() is 'dm5': from sites import DM5 as SiteClass elif base.get_site_name() is 'ck101': from sites import Ck101 as SiteClass elif base.get_site_name() is 'dmzj': from sites import Dmzj as SiteClass elif base.get_site_name() is 'ehentai': from sites import Ehentai as SiteClass try: website_object = SiteClass(user_input_url) comic_name = website_object.get_name() ref_box = website_object.get_parent_info() print('%s, total %d chapters detected.' % (comic_name, len(ref_box))) main_loop(ref_box, fetch_latest) except ConnectionError as e: print('%s, consider using a proxy or a VPN.' % e)
from base import SharedBase def main_loop(refer_box): for ref_tuple in refer_box: title, parent_link = ref_tuple total_page = website_object.get_page_info(parent_link) for page in range(1, total_page + 1): link = website_object.get_image_link(parent_link, page) try: website_object.down(comic_name, parent_link, link, title, page) print('%s page %d has been downloaded successfully' % (title, page)) except: print('Error occurred when downloading %s, Page %d.' % (title, page)) user_input_url = input('URL?\n') base = SharedBase(user_input_url) if base.get_site_name() is 'dm5': from sites import DM5 as SiteClass elif base.get_site_name() is 'ck101': from sites import Ck101 as SiteClass website_object = SiteClass(user_input_url) comic_name = website_object.get_name() ref_box = website_object.get_parent_info() print('%s, total %d chapters detected.' % (comic_name, len(ref_box))) main_loop(ref_box)
class WorkingThread(QThread): status_report_signal = pyqtSignal(str) progress_report_signal = pyqtSignal(bool) stop_signal = pyqtSignal(str) chapter_start_signal = pyqtSignal(tuple) def __init__(self, site_name, url, checkbox_value, threads, save_dir): super(WorkingThread, self).__init__() self.site_name = site_name self.user_input_url = url self.latest_limit = checkbox_value self.threads = threads self.save_dir = save_dir def run(self): if self.site_name == 'dm5': from sites import DM5 as SiteClass elif self.site_name == 'ck101': from sites import Ck101 as SiteClass elif self.site_name == 'dmzj': from sites import Dmzj as SiteClass elif self.site_name == 'manhua_dmzj': from sites import manhua_Dmzj as SiteClass elif self.site_name == 'ehentai': from sites import Ehentai as SiteClass try: self.website_object = SiteClass(self.user_input_url) self.comic_name = self.website_object.get_name() self.ref_box = self.website_object.get_parent_info() self.status_report_signal.emit( '%s, total %d chapters detected.' % (self.comic_name, len(self.ref_box))) if self.latest_limit is not False: if self.latest_limit > len(self.ref_box): raise ValueError self.ref_box = self.ref_box[-self.latest_limit:] self.main_loop(self.ref_box) except ValueError: self.stop_signal.emit( 'Chapters selected out of range, maximum %s chapters' % len(self.ref_box)) except ConnectionError as e: self.stop_signal.emit('%s, consider using a proxy or a VPN.' % e) def main_loop(self, refer_box): # for ref_tuple in refer_box: # title, parent_link = ref_tuple # total_page = self.website_object.get_page_info(parent_link) # for page in range(1, total_page + 1): # vague_path = self.website_object.get_path(self.comic_name, title, page) + '*' # if glob.glob(vague_path): # self.status_report_signal.emit('%s page %d already existed.' % (title, page)) # else: # try: # link = self.website_object.get_image_link(parent_link, page) # self.status_report_signal.emit('Downloading %s' % title) # self.website_object.down(self.comic_name, parent_link, link, title, page) # progress = page / self.website_object.get_page_info(parent_link) # self.progress_report_signal.emit(progress * 100) # except: # errlog = 'Error occurred when downloading %s, Page %d.' % (title, page) # self.status_report_signal.emit(errlog) # self.stop_signal.emit('All Done!') for refer_tuple in refer_box: parent_title, parent_link = refer_tuple total_page = self.website_object.get_page_info(parent_link) jobs = list() for page in range(1, total_page + 1): jobs.append((parent_title, parent_link, page, total_page)) pool_size = self.threads pool = ThreadPool(processes=pool_size) # self.status_report_signal.emit('Downloading %s' % parent_title) self.chapter_start_signal.emit((parent_title, total_page)) pool.map(self.loop_thread, jobs) pool.close() pool.join() self.stop_signal.emit('All Done!') def loop_thread(self, args): parent_title, parent_link, page, total_page = args vague_path = self.website_object.get_path(self.comic_name, parent_title, page) + '*' if glob.glob(vague_path): self.status_report_signal.emit('%s page %d already existed.' % (parent_title, page)) else: try: link = self.website_object.get_image_link(parent_link, page) self.website_object.down(self.comic_name, parent_link, link, parent_title, page, self.save_dir) self.progress_report_signal.emit(True) except: self.status_report_signal.emit( 'Error occurred when downloading %s, Page %d.' % (parent_title, page))