def _get_size_info(self, opt): size = Util.contents(opt) link = Util.full_url(opt['value']) selected = opt.has_key('selected') and opt['selected'] == 'selected' if selected and link == self.page_url + '?g2_imageViewsIndex=0': link = self.page_url page_soup = Util.get_soup(link) img = _get_img_tag(page_soup) info = {} info['width'], info['height'] = self._get_dimensions(size, img) info['page_url'] = link info['image_url'] = Util.full_url(img['src']) info['is_full_size'] = size == self.full_size if info['is_full_size']: self.full_size_img_url = info['image_url'] return info
def __init__(self, page_url): self.page_url = page_url main_soup = Util.get_soup(page_url) sizes_div = main_soup('div', 'block-core-PhotoSizes giInfo')[0] selects = sizes_div('select') # 0 or 1 select tags. if selects: options = selects[0]('option') self.full_size_img_url = '' self.full_size = _get_size(sizes_div('a')[0]) self.width, self.height = self._get_dimensions(self.full_size) self.size_info = [ self._get_size_info(opt) for opt in options ] else: # Only one size for this image. img = _get_img_tag(main_soup) self.full_size_img_url = Util.full_url(img['src']) self.full_size = _get_size(sizes_div) self.width, self.height = self._get_dimensions(self.full_size, img) self.size_info = []