From d45bfb0eebc2b7d80ef0128ed5d066d21daea02b Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Mon, 3 Sep 2018 09:43:33 -0500 Subject: [PATCH] Started using VK API V 5.84 --- src/controller/posts.py | 12 ++++++------ src/sessionmanager/vkSessionHandler.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/controller/posts.py b/src/controller/posts.py index eb887aa..13cac86 100644 --- a/src/controller/posts.py +++ b/src/controller/posts.py @@ -181,7 +181,8 @@ class postController(object): if len(self.images) < index-1: log.exception("Error in loading image {0} in a list with {1} images".format(index, len(self.images))) return - url = self.get_photo_url(self.images[index]["photo"], 604) + # Get's photo URL. + url = self.get_photo_url(self.images[index]["photo"], "x") if url != "": img = requests.get(url) image = wx.ImageFromStream(cStringIO.StringIO(requests.get(url).content)) @@ -194,12 +195,11 @@ class postController(object): output.speak(_(u"Loaded photo {0} of {1}").format(index+1, len(self.images))) return - def get_photo_url(self, photo, size=1080): - possible_sizes = [1280, 604, 130, 75] + def get_photo_url(self, photo, size="x"): url = "" - for i in possible_sizes: - if photo.has_key("photo_{0}".format(i,)) and i == size: - url = photo["photo_{0}".format(i,)] + for i in photo["sizes"]: + if i["type"] == size: + url = i["url"] break return url diff --git a/src/sessionmanager/vkSessionHandler.py b/src/sessionmanager/vkSessionHandler.py index f4629ca..6d1ad2f 100644 --- a/src/sessionmanager/vkSessionHandler.py +++ b/src/sessionmanager/vkSessionHandler.py @@ -8,7 +8,7 @@ class vkObject(object): def __init__(self): self.api_key = keys.keyring.get_api_key() - self.api_version = 5.69 + self.api_version = 5.84 log.debug("Created vkSession using VK API Version %s" % (self.api_version,)) def login(self, user, password):