69 matches = modelexport_re.search(resp.text)
73 match = matches.group(1)
74 model_export = json.loads(match)
76 if 'legend' not in model_export:
78 legend = model_export[
'legend']
81 if not legend
or not legend[0]:
84 for x, index
in enumerate(legend):
86 logger.debug(
"skip legend enty %s : %s", x, index)
89 photo = model_export[
'main'][index[0]][int(index[1])][index[2]][index[3]][index[4]][index[5]][int(index[6])][
92 author = ecma_unescape(photo.get(
'realname',
''))
93 source = ecma_unescape(photo.get(
'username',
''))
96 title = ecma_unescape(photo.get(
'title',
''))
97 content = html_to_text(ecma_unescape(photo.get(
'description',
'')))
102 for image_size
in image_sizes:
103 if image_size
in photo[
'sizes'][
'data']:
104 size_data = photo[
'sizes'][
'data'][image_size][
'data']
108 logger.debug(
'cannot find valid image size: {0}'.
format(repr(photo[
'sizes'][
'data'])))
111 img_src = size_data[
'url']
112 resolution = f
"{size_data['width']} x {size_data['height']}"
115 if 'n' in photo[
'sizes'][
'data']:
116 thumbnail_src = photo[
'sizes'][
'data'][
'n'][
'data'][
'url']
117 elif 'z' in photo[
'sizes'][
'data']:
118 thumbnail_src = photo[
'sizes'][
'data'][
'z'][
'data'][
'url']
120 thumbnail_src = img_src
122 if 'ownerNsid' not in photo:
131 'thumbnail_src': thumbnail_src,
133 'resolution': resolution,
134 'template':
'images.html',
136 result[
'author'] = author.encode(errors=
'ignore').decode()
137 result[
'source'] = source.encode(errors=
'ignore').decode()
138 result[
'title'] = title.encode(errors=
'ignore').decode()
139 result[
'content'] = content.encode(errors=
'ignore').decode()
140 results.append(result)