Lets fix vk videos

This commit is contained in:
misha shelemetyev 2016-07-08 15:12:21 -04:00
parent 13b63aa773
commit 50c911507b
2 changed files with 9 additions and 7 deletions

View File

@ -318,7 +318,7 @@ Use `--url`/`-u` to get a list of downloadable resource URLs extracted from the
| :--: | :-- | :-----: | :-----: | :-----: | | :--: | :-- | :-----: | :-----: | :-----: |
| **YouTube** | <https://www.youtube.com/> |✓| | | | **YouTube** | <https://www.youtube.com/> |✓| | |
| **Twitter** | <https://twitter.com/> |✓|✓| | | **Twitter** | <https://twitter.com/> |✓|✓| |
| VK | <http://vk.com/> |✓| | | | VK | <http://vk.com/> |✓|| |
| Vine | <https://vine.co/> |✓| | | | Vine | <https://vine.co/> |✓| | |
| Vimeo | <https://vimeo.com/> |✓| | | | Vimeo | <https://vimeo.com/> |✓| | |
| Vidto | <http://vidto.me/> |✓| | | | Vidto | <http://vidto.me/> |✓| | |

View File

@ -7,12 +7,14 @@ from ..common import *
def get_video_info(url): def get_video_info(url):
video_page = get_content(url) video_page = get_content(url)
title = unescape_html(r1(r'"title":"([^"]+)"', video_page)) title = r1(r'<div class="vv_summary">(.[^>]+?)</div', video_page)
info = dict(re.findall(r'\\"url(\d+)\\":\\"([^"]+)\\"', video_page)) sources = re.findall(r'<source src=\"(.[^>]+?)"', video_page)
for quality in ['1080', '720', '480', '360', '240']: for quality in ['1080', '720', '480', '360', '240']:
if quality in info: for source in sources:
url = re.sub(r'\\\\\\/', r'/', info[quality]) if source.find(quality) != -1:
break url = source
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)
@ -37,7 +39,7 @@ def get_image_info(url):
def vk_download(url, output_dir='.', stream_type=None, merge=True, info_only=False, **kwargs): def vk_download(url, output_dir='.', stream_type=None, merge=True, info_only=False, **kwargs):
link = None link = None
if re.match(r'vk.com/photo', url): if re.match(r'(.+)z\=video(.+)', url):
link, title, ext, size = get_video_info(url) link, title, ext, size = get_video_info(url)
elif re.match(r'(.+)vk\.com\/photo(.+)', url): elif re.match(r'(.+)vk\.com\/photo(.+)', url):
link, title, ext, size = get_image_info(url) link, title, ext, size = get_image_info(url)