|
|
@ -10,6 +10,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
from .common import Extractor, Message
|
|
|
|
from .common import Extractor, Message
|
|
|
|
from .. import text, exception
|
|
|
|
from .. import text, exception
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
BASE_PATTERN = r"(?:https://)?(?:www\.|m\.)?vk\.com"
|
|
|
|
BASE_PATTERN = r"(?:https://)?(?:www\.|m\.)?vk\.com"
|
|
|
|
|
|
|
|
|
|
|
@ -24,6 +25,7 @@ class VkExtractor(Extractor):
|
|
|
|
request_interval = (0.5, 1.5)
|
|
|
|
request_interval = (0.5, 1.5)
|
|
|
|
|
|
|
|
|
|
|
|
def items(self):
|
|
|
|
def items(self):
|
|
|
|
|
|
|
|
sub = re.compile(r"/imp[fg]/").sub
|
|
|
|
sizes = "wzyxrqpo"
|
|
|
|
sizes = "wzyxrqpo"
|
|
|
|
|
|
|
|
|
|
|
|
data = self.metadata()
|
|
|
|
data = self.metadata()
|
|
|
@ -40,11 +42,15 @@ class VkExtractor(Extractor):
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
photo["url"] = photo[size + "src"]
|
|
|
|
url = photo[size + "src"]
|
|
|
|
except KeyError:
|
|
|
|
except KeyError:
|
|
|
|
self.log.warning("no photo URL found (%s)", photo.get("id"))
|
|
|
|
self.log.warning("no photo URL found (%s)", photo.get("id"))
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
photo["url"] = sub("/", url.partition("?")[0])
|
|
|
|
|
|
|
|
# photo["url"] = url
|
|
|
|
|
|
|
|
photo["_fallback"] = (url,)
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
_, photo["width"], photo["height"] = photo[size]
|
|
|
|
_, photo["width"], photo["height"] = photo[size]
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|