Ejemplo n.º 1
0
    def get_key(self, key):
        """
        Return metadata about key
        Args:
            key: ID who's metadata we'd like to extract

        Returns:
            RecordMetadata: Returns ParserMetadata object containing metadata about item
        """
        item = self.item_info[key]
        image_name = os.path.basename(item['url'])

        if key in self.tags_data:
            tags = self.tags_data[key]
        else:
            tags = None

        if key in self.tags_data:
            captions = self.captions_data[key]
        else:
            captions = None

        return RecordMetadata(id=key,
                              image_name=image_name,
                              tags=tags,
                              captions=captions)

        return self.item_info[key]
Ejemplo n.º 2
0
    def get_key(self, key):
        """
        Return metadata about key
        Args:
            key: ID who's metadata we'd like to extract

        Returns:
            RecordMetadata: Returns ParserMetadata object containing metadata about item
        """
        item = self.item_info[key]
        return RecordMetadata(id=key, image_name=item['fname'], tags=item['tags'], captions=item['captions'])
Ejemplo n.º 3
0
 def get_key(self, key):
     """
     Get the description of that record by key
     Args:
         key: key
     Returns:
         (image file name, caption, tags): Returns image file name, caption string, list of tag strings
     """
     item = self.item_info[key]
     return RecordMetadata(id=key,
                           image_name=item['image_name'],
                           tags=item['tags'],
                           captions=item['captions'])
Ejemplo n.º 4
0
    def download_image(self, tokens):
        mapping = dict(zip(META_FIELDS, tokens))
        if mapping['image_or_video'] == 0:
            key = mapping['photo_id']

            image_url = mapping['download_url']
            fname = key
            # May need to add an extension to this
            download_if_not_present(fname, image_url)

            self.item_info[key] = RecordMetadata(
                id=key,
                image_name=fname,
                tags=mapping['user_tags'],
                captions=mapping['description'])