Esempio n. 1
0
def parse_image_urls(illustration):
    if 'original_image_url' in illustration['meta_single_page']:
        url = illustration['meta_single_page']['original_image_url']
        if illustration['type'] == 'ugoira':
            url = url.replace("img-original", 'img-zip-ugoira')
            url = re.findall('(.*)_ugoira0\..*', url)[0]
            url = "%s%s" % (url, '_ugoira1920x1080.zip')
        file_name = '%s.%s' % (
            illustration['id'],
            guess_extension(url)
        )
        yield ImageItem(
            name=file_name,
            url=url,
        )
    else:
        dir_name = normalize_filename(illustration['title'])
        images = illustration['meta_pages']
        for index, image in enumerate(images):
            url = image['image_urls']['original']
            name = "%s.%s" % (index, guess_extension(url))
            yield ImageItem(
                name=name,
                url=url,
                meta={
                    'is_comic': True,
                    'dir_name': dir_name,
                }
            )
Esempio n. 2
0
 def tasks(self):
     for pin_meta in self._board.pins:
         pin_item = mk_pin(pin_meta)
         yield ImageItem(
             url=pin_item.url,
             name=pin_item.filename,
         )
Esempio n. 3
0
 def tasks(self):
     for board, pin_meta in self._boards_pins:
         pin_item = mk_pin(pin_meta)
         yield ImageItem(url=pin_item.url,
                         name=pin_item.filename,
                         meta={
                             'board_name': board.title,
                         })
Esempio n. 4
0
 def _mk_item(self, image_url, title, has_many=False):
     name = get_filename_fom_url(image_url)
     meta = dict(title=title, has_many=has_many)
     meta['search_keyword'] = self._search_keyword
     return ImageItem(
         image_url,
         name=name,
         meta=meta,
     )
Esempio n. 5
0
 def _yield_image_items(self, data, album_name=None):
     for summary in data:
         for image_item in self._get_image_item_from_detail(summary, ):
             if album_name is not None:
                 image_item = ImageItem(
                     url=image_item.url,
                     name=image_item.name,
                     meta={"album_name": album_name},
                 )
             yield image_item
Esempio n. 6
0
 def _mk_item(self, image_url, title, has_many=False):
     if image_url.endswith("restricted") or image_url.endswith(
             "main-image"):
         name = "_".join(image_url.split("/")[-3:]) + ".jpg"
     else:
         name = get_filename_fom_url(image_url)
     meta = dict(title=title, has_many=has_many)
     meta['search_keyword'] = self._search_keyword
     return ImageItem(
         image_url,
         name=name,
         meta=meta,
     )
Esempio n. 7
0
def parse_single_artwork(artwork_dict: dict):
    """
    {
        "liked":false,
        "tags":[

        ],
        "hide_as_adult":false,
        "visible_on_artstation":true,
        "assets":[
            {
                "has_image":true,
                "has_embedded_player":false,
                "player_embedded":null,
                "oembed":null,
                "id":12260469,
                "title_formatted":"",
                "image_url":"https://cdnb.artstation.com/p/assets/images/images/012/260/469/large/ham-sung-choul-braveking-180809-1-mini.jpg?1533864344",
                "width":1300,
                "height":2434,
                "position":0,
                "asset_type":"image",
                "viewport_constraint_type":"constrained"
            },
            {
                "has_image":false,
                "has_embedded_player":false,
                "player_embedded":null,
                "oembed":null,
                "id":12260473,
                "title_formatted":"",
                "image_url":"https://cdnb.artstation.com/p/assets/covers/images/012/260/473/large/ham-sung-choul-braveking-180809-1-mini-2.jpg?1533864353",
                "width":822,
                "height":822,
                "position":1,
                "asset_type":"cover",
                "viewport_constraint_type":"constrained"
            }
        ],
        "collections":[

        ],
        "user":{
            "followed":true,
            "following_back":false,
            "blocked":false,
            "is_staff":false,
            "id":199106,
            "username":"******",
            "headline":"freelance artist",
            "full_name":"Ham Sung-Choul(braveking)",
            "permalink":"https://www.artstation.com/braveking",
            "medium_avatar_url":"https://cdna.artstation.com/p/users/avatars/000/199/106/medium/ab27ac7f48de117074c14963a3371914.jpg?1461412259",
            "large_avatar_url":"https://cdna.artstation.com/p/users/avatars/000/199/106/large/ab27ac7f48de117074c14963a3371914.jpg?1461412259",
            "small_cover_url":"https://cdn.artstation.com/static_media/placeholders/user/cover/default.jpg",
            "pro_member":false
        },
        "medium":null,
        "categories":[
            {
                "name":"Characters",
                "id":1
            },
            {
                "name":"Fantasy",
                "id":2
            },
            {
                "name":"Concept Art",
                "id":3
            }
        ],
        "software_items":[

        ],
        "id":3513664,
        "user_id":199106,
        "title":"doodle",
        "description":"<p></p>",
        "description_html":"<p></p>",
        "created_at":"2018-08-09T07:50:11.347-05:00",
        "updated_at":"2018-08-10T01:55:50.964-05:00",
        "views_count":3257,
        "likes_count":699,
        "comments_count":1,
        "permalink":"https://www.artstation.com/artwork/mr5aZ",
        "cover_url":"https://cdnb.artstation.com/p/assets/covers/images/012/260/473/medium/ham-sung-choul-braveking-180809-1-mini-2.jpg?1533864353",
        "published_at":"2018-08-09T07:50:19.308-05:00",
        "editor_pick":true,
        "adult_content":false,
        "admin_adult_content":false,
        "slug":"doodle-184-a5ea10f5-e98e-46e2-866e-63ae54fd443a",
        "suppressed":false,
        "hash_id":"mr5aZ",
        "visible":true
    }
    :rtype: list[ImageItem]
    """
    assets = artwork_dict['assets']
    assets = [asset for asset in assets if asset['has_image']]
    images = (ImageItem(
        url=asset['image_url'],
        name=get_name_from_url,
    ) for asset in assets)
    return images
Esempio n. 8
0
 def tasks(self):
     for image_url in get_images(self.base_url, self.album_id):
         yield ImageItem(
             url=image_url,
             name=get_filename_fom_url(image_url),
         )