Skip to content

Commit

Permalink
[vk] add 'tagged' extractor (#2997)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Oct 8, 2022
1 parent 122e1a4 commit 560f7b4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ Consider all sites to be NSFW unless otherwise known.
<tr>
<td>VK</td>
<td>https://vk.com/</td>
<td>Albums, Photos</td>
<td>Albums, Photos, Tagged Photos</td>
<td></td>
</tr>
<tr>
Expand Down
24 changes: 23 additions & 1 deletion gallery_dl/extractor/vk.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class VkPhotosExtractor(VkExtractor):
subcategory = "photos"
pattern = (BASE_PATTERN + r"/(?:"
r"(?:albums|photos|id)(-?\d+)"
r"|(?!album-?\d+_)([^/?#]+))")
r"|(?!(?:album|tag)-?\d+_?)([^/?#]+))")
test = (
("https://vk.com/id398982326", {
"pattern": r"https://sun\d+-\d+\.userapi\.com/s/v1/if1"
Expand Down Expand Up @@ -208,3 +208,25 @@ def metadata(self):
"user": {"id": self.user_id},
"album": {"id": self.album_id},
}


class VkTaggedExtractor(VkExtractor):
"""Extractor for a vk tagged photos"""
subcategory = "tagged"
directory_fmt = ("{category}", "{user[id]}", "tags")
pattern = BASE_PATTERN + r"/tag(-?\d+)$"
test = (
("https://vk.com/tag304303884", {
"count": 44,
}),
)

def __init__(self, match):
VkExtractor.__init__(self, match)
self.user_id = match.group(1)

def photos(self):
return self._pagination("tag{}".format(self.user_id))

def metadata(self):
return {"user": {"id": self.user_id}}

0 comments on commit 560f7b4

Please sign in to comment.