def download_file(self, url: str, dst: str = None, callback: callable = None) -> bool: if not dst: name = basename(remove_file_query_params(url)) dst = path_join(get_temp_path(), name) return self._download_one_file_helper(url, dst, callback)
def prepare_cookies(self): _storage = storage('.passwords.json') if not is_file(_storage): copy(path_join(root_path(), 'manga_py', '.passwords.json.dist'), _storage) file = open(_storage, 'r').read() data = self.json.loads(file).get('hentai_chan_me', {}) cookies = self._login(**data) for i in cookies: self._storage['cookies'][i] = cookies[i]
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)
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)
def test_root_path(self): self.assertEqual(path.realpath(fs.path_join(root_path, '..')), fs.root_path())