def test_should_download_the_images_in_a_folder(self): folder = Chibi_temp_path() episode = self.site.series[0].episodes[0] episode.download(folder) self.assertTrue(next(folder.ls())) for f in folder.ls(): properties = f.open().properties self.assertGreater(properties.size, 1024)
def test_should_can_compress_the_download_files(self): folder = Chibi_temp_path() folder_compress = Chibi_temp_path() episode = self.site.series[0].episodes[0] episode.download(folder) result = episode.compress(folder_compress, folder) self.assertIsInstance(result, Chibi_path) self.assertTrue(result.exists) self.assertTrue(result.endswith(".cbz")) self.assertIn(result, folder_compress)
def test_compress_episode_should_create_a_new_file(self): self.assertTrue(self.site.urls) for url in self.site.urls: path = Chibi_temp_path() path_output = Chibi_temp_path() url.download(path) path_result = url.compress(path_output, path) self.assertTrue(path_result.endswith('cbz')) self.assertTrue(path_result.properties.mime, 'application/zip') self.assertGreater(path_result.properties.size, 100000)
def test_download_episode_should_download_the_images(self): self.assertTrue(self.site.urls) for url in self.site.urls: path = Chibi_temp_path() path_output = url.download(path) self.assertEqual(path, path_output) ls = list(path.ls()) self.assertEqual(len(url.images), len(ls)) for img in ls: self.assertGreater(img.properties.size, 10000)
def get(self, *args, **kw): temp_dir = Chibi_temp_path() pdf = self.download(temp_dir) data = pdf_to_dicts(pdf) response = Response(response=object(), url=self) response._native = data return response
def test_should_return_the_table_of_the_pdf(self): result = list_of_pdf.get() self.assertTrue(result.native) for link in result.native: temp_folder = Chibi_temp_path() pdf = link.download(temp_folder) table = pdf_to_dicts(pdf) self.assertIsInstance(table, list) for t in table: self.assertIsInstance(t, dict) self.assertIn('number_case', t) self.assertIn('age', t) self.assertIn('state', t) self.assertIn('symptom_start_date', t) self.assertIn('arrive_date_to_mexico', t) self.assertIn('status', t) self.assertIn('arrive_from', t) self.assertIn('sex', t)
def download(self, path): logger.info('iniciando descarga de la serie "{}" de "{}"'.format( self.title, self.url)) path += self.title path = path.made_safe() path.mkdir() for episode in self.episodes: episode_path = path + episode.file_name_mkv if (episode_path.exists): logger.info(("ignorando el episodio {} se encontro " "en el destino").format(episode.name)) continue temp_folder = Chibi_temp_path() try: episode.download(temp_folder) except Episode_not_have_media: logger.error( ("el episodio {} no esta disponible posiblemente el " "login no esta correcto").format(episode.name)) continue mkv = episode.pack(temp_folder) mkv.move(path)
def download( self, path ): serie_path = ( path + self.name ).made_safe() serie_path.mkdir() logger.info( "iniciando descarga de la serie '{}' de {}".format( self.name, self.url ) ) for episode in self.episodes: episode_path = serie_path + episode.file_name if ( episode_path.exists ): logger.info( ( "ignorando el episodio {} se encontro " "en el destino" ).format( episode.title ) ) continue downlaod_folder = Chibi_temp_path() try: episode.download( downlaod_folder ) except Exception as e: logger.exception( "paso un problema cuando intento de " "descargar el episodio" ) continue episode.compress( serie_path, downlaod_folder )
def setUp(self): self.root_dir = Chibi_temp_path() self.touhas_db = self.root_dir + 'touhas'
def test_should_donwload_all_the_serie(self): folder = Chibi_temp_path() serie = self.site.series[0] serie.download(folder) download_files = list(next(folder.ls()).ls()) self.assertEqual(len(serie.episodes), download_files)
def setUp(self): self.repo_url = 'https://github.com/dem4ply/chibi_command.git' self.root_dir = Chibi_temp_path() self.old_dir = current_dir()
def setUp(self): self.download_folder = Chibi_temp_path() self.lenna_url = Chibi_url('http://www.lenna.org/len_std.jpg')