Ejemplo n.º 1
0
def get_files_imgs(actor_index, img_urls, path):
	for i in xrange(len(img_urls)):
		img_url = img_urls[i]
		img_path = "./" + path + "/DB/Face_DB/face_" + str(actor_index) + "_" + str(i) + ".jpg"
		print img_path
		dn = ImageDownloader(img_url, img_path)
		dn.run()
Ejemplo n.º 2
0
def get_files_imgs(actor_index, img_urls, path):
    for i in xrange(len(img_urls)):
        img_url = img_urls[i]
        img_path = "./" + path + "/DB/Face_DB/face_" + str(
            actor_index) + "_" + str(i) + ".jpg"
        print img_path
        dn = ImageDownloader(img_url, img_path)
        dn.run()
Ejemplo n.º 3
0
 def get_and_save_cover(self, keyword, destination, filename):
     image_url = self.cover_grabber.grab(keyword)
     if image_url is not None:
         image_downloader = ImageDownloader(destination)
         file_path = image_downloader.download(image_url, filename)
         if file_path is not None:
             return file_path
         else:
             return None
     else:
         return None
Ejemplo n.º 4
0
 def handle_starttag(self, tag, attrs):
     if tag == 'a':
         for (attribute, value) in attrs:
             if attribute == 'href':
                 url = parse.urljoin(self.baseURL, value)
                 self.links.add(url)
     elif tag == 'img':
         for (attribute, value) in attrs:
             if attribute == "src":
                 url = parse.urljoin(self.baseURL, value)
                 ImageDownloader.downloadImage(url)
Ejemplo n.º 5
0
    def get_and_save_artist(self, keyword, destination, filename):
        infos = self.artist_infos.get(keyword, None)

        if infos['success']:
            image_downloader = ImageDownloader(destination)
            if infos['infos']['image']:
                file_path = image_downloader.download(infos['infos']['image'],
                                                      filename)
                if file_path:
                    infos['infos']['image'] = file_path
                    return infos
                else:
                    return None
            else:
                return None
Ejemplo n.º 6
0
 def get_and_save_artist(self, keyword, destination, filename):
     infos = self.artist_infos.get(keyword)
     if infos['success'] is True:
         image_downloader = ImageDownloader(destination)
         if infos['infos']['image'] is not None:
             file_path = image_downloader.download(infos['infos']['image'],
                                                   filename)
             if file_path is not None:
                 infos['infos']['image'] = file_path
                 return infos
             else:
                 return None
         else:
             return None
     else:
         return None
Ejemplo n.º 7
0
    def generate_missing_translations(self):
        # Cache them off so we can delete them as we go
        spreadsheetRows = self._spreadsheet.rows
        for row in spreadsheetRows:
            # If the row has any empty words, retranslate it
            retranslate = False
            for cell in row.outputWordCells:
                if cell.text is "":
                    retranslate = True
            # If the row is missing an image filepath, we also need to retranslate it
            if row.imgFilepath is "":
                retranslate = True
            elif not exists(row.imgFilepath):
                retranslate = True

            if retranslate:
                outputWordsList = WordTranslator().get_translated_words(
                    row.inputWord, _preferences.outputLangCodes)
                i = 0
                for cell in row.outputWordCells:
                    if i >= len(outputWordsList):
                        break
                    cell.text = outputWordsList[i]
                    i += 1
                # See if an image exists but we just haven't loaded it
                row.imgFilepath = FinalImageCreator.try_get_filepath_for_thumbnail(
                    row.inputWord, _preferences.thumbnailsLocation)
                # If it really doesn't exist, download a new one and then try to find it
                if row.imgFilepath is "":
                    ImageDownloader().get_images_for_words(
                        [row.inputWord], _preferences.thumbnailsLocation)
                    row.imgFilepath = FinalImageCreator.try_get_filepath_for_thumbnail(
                        row.inputWord, _preferences.thumbnailsLocation)
Ejemplo n.º 8
0
 def generate_translations(self):
     inputWords = self._spreadsheet.get_input_words()
     self.reset_spreadsheet()
     translationsDict = WordTranslator().generate_translations_dict(
         inputWords, _preferences.outputLangCodes)
     ImageDownloader().get_images_for_words(list(translationsDict.keys()),
                                            _preferences.thumbnailsLocation)
     self.create_spreadsheet_rows_from_dict(translationsDict)
Ejemplo n.º 9
0
 def download_prev_thumb(self):
     (img, self.tryTime) = ImageDownloader().get_prev_image(
         self.name, self.tryTime - 1)
     ImageDownloader.thumbify_and_save(self.name, img,
                                       _preferences.thumbnailsLocation)
     self.reload_img(0)