[vk] prevent exceptions for broken/invalid photos (#2774)
This commit is contained in:
@@ -39,13 +39,18 @@ class VkExtractor(Extractor):
|
|||||||
self.log.warning("no photo URL found (%s)", photo.get("id"))
|
self.log.warning("no photo URL found (%s)", photo.get("id"))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
photo["url"] = photo[size + "src"]
|
||||||
|
except KeyError:
|
||||||
|
self.log.warning("no photo URL found (%s)", photo.get("id"))
|
||||||
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_, photo["width"], photo["height"] = photo[size]
|
_, photo["width"], photo["height"] = photo[size]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# photo without width/height entries (#2535)
|
# photo without width/height entries (#2535)
|
||||||
photo["width"] = photo["height"] = 0
|
photo["width"] = photo["height"] = 0
|
||||||
|
|
||||||
photo["url"] = photo[size + "src"]
|
|
||||||
photo["id"] = photo["id"].rpartition("_")[2]
|
photo["id"] = photo["id"].rpartition("_")[2]
|
||||||
photo.update(data)
|
photo.update(data)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user