aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/vk.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/vk.py')
-rw-r--r--gallery_dl/extractor/vk.py31
1 files changed, 26 insertions, 5 deletions
diff --git a/gallery_dl/extractor/vk.py b/gallery_dl/extractor/vk.py
index 8fb9bbf..23f6ea2 100644
--- a/gallery_dl/extractor/vk.py
+++ b/gallery_dl/extractor/vk.py
@@ -9,7 +9,7 @@
"""Extractors for https://vk.com/"""
from .common import Extractor, Message
-from .. import text
+from .. import text, exception
BASE_PATTERN = r"(?:https://)?(?:www\.|m\.)?vk\.com"
@@ -39,9 +39,15 @@ class VkExtractor(Extractor):
self.log.warning("no photo URL found (%s)", photo.get("id"))
continue
- photo.update(data)
- photo["url"], photo["width"], photo["height"] = photo[size]
+ try:
+ photo["url"], photo["width"], photo["height"] = photo[size]
+ except ValueError:
+ # photo without width/height entries (#2535)
+ photo["url"] = photo[size + "src"]
+ photo["width"] = photo["height"] = 0
+
photo["id"] = photo["id"].rpartition("_")[2]
+ photo.update(data)
text.nameext_from_url(photo["url"], photo)
yield Message.Url, photo["url"], photo
@@ -66,6 +72,10 @@ class VkExtractor(Extractor):
url, method="POST", headers=headers, data=data,
).json()["payload"][1]
+ if len(payload) < 4:
+ self.log.debug(payload)
+ raise exception.AuthorizationError(payload[0])
+
total = payload[1]
photos = payload[3]
@@ -105,7 +115,7 @@ class VkPhotosExtractor(VkExtractor):
},
}),
("https://vk.com/cosplayinrussia", {
- "range": "25-35",
+ "range": "15-25",
"keywords": {
"id": r"re:\d+",
"user": {
@@ -117,6 +127,12 @@ class VkPhotosExtractor(VkExtractor):
},
},
}),
+ # photos without width/height (#2535)
+ ("https://vk.com/id76957806", {
+ "pattern": r"https://sun\d+-\d+\.userapi\.com/",
+ "range": "1-9",
+ "count": 9,
+ }),
("https://m.vk.com/albums398982326"),
("https://www.vk.com/id398982326?profile=1"),
("https://vk.com/albums-165740836"),
@@ -150,7 +166,8 @@ class VkPhotosExtractor(VkExtractor):
'<h1 class="page_name">', "<")).replace(" ", " "),
"info": text.unescape(text.remove_html(extr(
'<span class="current_text">', '</span'))),
- "id" : extr('<a href="/albums', '"'),
+ "id" : (extr('<a href="/albums', '"') or
+ extr('data-from-id="', '"')),
}}
@@ -166,6 +183,10 @@ class VkAlbumExtractor(VkExtractor):
("https://vk.com/album-165740836_281339889", {
"count": 12,
}),
+ # "Access denied" (#2556)
+ ("https://vk.com/album-53775183_00", {
+ "exception": exception.AuthorizationError,
+ }),
)
def __init__(self, match):