mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 08:43:58 +03:00
you get vk photos
This commit is contained in:
parent
e0408c8037
commit
04fe6cd5a4
@ -4,7 +4,8 @@ __all__ = ['vk_download']
|
|||||||
|
|
||||||
from ..common import *
|
from ..common import *
|
||||||
|
|
||||||
def vk_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
|
|
||||||
|
def get_video_info(url):
|
||||||
video_page = get_content(url)
|
video_page = get_content(url)
|
||||||
title = unescape_html(r1(r'"title":"([^"]+)"', video_page))
|
title = unescape_html(r1(r'"title":"([^"]+)"', video_page))
|
||||||
info = dict(re.findall(r'\\"url(\d+)\\":\\"([^"]+)\\"', video_page))
|
info = dict(re.findall(r'\\"url(\d+)\\":\\"([^"]+)\\"', video_page))
|
||||||
@ -13,12 +14,39 @@ def vk_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
|
|||||||
url = re.sub(r'\\\\\\/', r'/', info[quality])
|
url = re.sub(r'\\\\\\/', r'/', info[quality])
|
||||||
break
|
break
|
||||||
assert url
|
assert url
|
||||||
|
|
||||||
type, ext, size = url_info(url)
|
type, ext, size = url_info(url)
|
||||||
|
|
||||||
print_info(site_info, title, type, size)
|
print_info(site_info, title, type, size)
|
||||||
if not info_only:
|
|
||||||
download_urls([url], title, ext, size, output_dir, merge=merge)
|
return url, title, ext, size
|
||||||
|
|
||||||
|
|
||||||
|
def get_image_info(url):
|
||||||
|
image_page = get_content(url)
|
||||||
|
# used for title - vk page owner
|
||||||
|
page_of = re.findall(r'Sender:</dt><dd><a href=.*>(.[^>]+?)</a', image_page)
|
||||||
|
# used for title - date when photo was uploaded
|
||||||
|
photo_date = re.findall(r'<span class="item_date">(.[^>]+?)</span', image_page)
|
||||||
|
|
||||||
|
title = (' ').join(page_of + photo_date)
|
||||||
|
image_link = r1(r'href="([^"]+)" class=\"mva_item\" target="_blank">Download full size', image_page)
|
||||||
|
type, ext, size = url_info(image_link)
|
||||||
|
print_info(site_info, title, type, size)
|
||||||
|
|
||||||
|
return image_link, title, ext, size
|
||||||
|
|
||||||
|
|
||||||
|
def vk_download(url, output_dir='.', stream_type=None, merge=True, info_only=False, **kwargs):
|
||||||
|
link = None
|
||||||
|
if re.match(r'vk.com/photo', url):
|
||||||
|
link, title, ext, size = get_video_info(url)
|
||||||
|
elif re.match(r'(.+)vk\.com\/photo(.+)', url):
|
||||||
|
link, title, ext, size = get_image_info(url)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError('Nothing to download here')
|
||||||
|
|
||||||
|
if not info_only and link is not None:
|
||||||
|
download_urls([link], title, ext, size, output_dir, merge=merge)
|
||||||
|
|
||||||
|
|
||||||
site_info = "VK.com"
|
site_info = "VK.com"
|
||||||
download = vk_download
|
download = vk_download
|
||||||
|
Loading…
Reference in New Issue
Block a user