예제 #1
0
파일: archive.py 프로젝트: Klein69/manga-dl
    def make(self, dst):
        if not len(self.files) and not len(self._writes):
            return

        make_dirs(dirname(dst))

        self._archive = ZipFile(dst, 'w', ZIP_DEFLATED)
        self.__add_files()
        self.__add_writes()
        self._archive.close()
        self._maked()
예제 #2
0
 def loop_chapters(self):
     arc_name = self.get_archive_name()
     arc = self._archive_type()
     path = path_join(dirname(self.get_archive_path()), arc_name + '.%s' % arc)
     url = self.chapter
     temp_path = get_temp_path('{:0>2}_{}-temp_arc.zip'.format(
         self._storage['current_chapter'],
         arc_name
     ))
     self.save_file(url, temp_path)
     rename(temp_path, path)
예제 #3
0
 def _safe_downloader(self, url, file_name, method='get') -> bool:
     try:
         make_dirs(dirname(file_name))
         url = self.normalize_uri(url)
         with open(file_name, 'wb') as out_file:
             response = self.requests(url, method=method, timeout=60)
             out_file.write(response.content)
             response.close()
             out_file.close()
     except OSError as ex:
         self.debug and print(ex)
         return False
     return True
예제 #4
0
    def download_drivder(self):
        url_prefix = 'https://chromedriver.storage.googleapis.com/'
        url = '/chromedriver_linux64.zip'
        if ~platform.find('darwin'):
            url = '/chromedriver_mac64.zip'
        if self.is_win():
            url = '/chromedriver_win32.zip'

        path = storage('driver.zip')

        with open(path, 'wb') as driver:
            driver.write(get(url_prefix + self.driver_version + url).content)
            driver.close()
        with ZipFile(path) as file:
            file.extractall(dirname(self._driver_path()))
예제 #5
0
 def get_arc_path(self):
     path = self.get_archive_name()
     name = dirname(self.get_archive_path())
     arc = self._archive_type()
     return path_join(path, name + '.%s' % arc)