From ab1e9a2b689789a8b45a4367e1f9523c9b40083c Mon Sep 17 00:00:00 2001 From: Marvin Ewald Date: Wed, 26 Aug 2015 17:10:50 +0200 Subject: [PATCH 1/2] [vivo] Add new extractor --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/vivo.py | 49 ++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 youtube_dl/extractor/vivo.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 1c53a5632..638678edc 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -731,6 +731,7 @@ from .viki import ( VikiIE, VikiChannelIE, ) +from .vivo import VivoIE from .vk import ( VKIE, VKUserVideosIE, diff --git a/youtube_dl/extractor/vivo.py b/youtube_dl/extractor/vivo.py new file mode 100644 index 000000000..2d26d50a0 --- /dev/null +++ b/youtube_dl/extractor/vivo.py @@ -0,0 +1,49 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + +from ..compat import ( + compat_urllib_parse, + compat_urllib_request, +) + +import re + +class VivoIE(InfoExtractor): + _VALID_URL = r'http://(?:www\.)?vivo\.sx/(?P[a-f0-9]{10})' + _TEST = { + 'url': 'http://vivo.sx/d7ddda0e78', + 'md5': '2f36fed6235b16da96ce9b4dc890940d', + 'info_dict': { + 'id': 'd7ddda0e78', + 'ext': 'mp4', + 'title': 'Chicken', + 'alt_title': 'Chicken', + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + url = 'http://vivo.sx/%s' % video_id + + webpage = self._download_webpage(url, video_id) + + # self._sleep(7, video_id) + + headers = { + b'Content-Type': b'application/x-www-form-urlencoded', + } + post = compat_urllib_parse.urlencode(self._hidden_inputs(webpage)) + req = compat_urllib_request.Request(url, post, headers) + webpage = self._download_webpage(req, video_id, note='Downloading video page ...') + + m = re.search(r'
', webpage) + + return { + 'id': video_id, + 'title': m.group("title"), + 'alt_title': m.group("name"), + 'url' : m.group("url"), + 'ext': 'mp4', + } From dacb6a43cdf01a4c8b8dc74524a18810891b063a Mon Sep 17 00:00:00 2001 From: Marvin Ewald Date: Wed, 26 Aug 2015 17:39:22 +0200 Subject: [PATCH 2/2] [vivo] Correct md5 hash --- youtube_dl/extractor/vivo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/vivo.py b/youtube_dl/extractor/vivo.py index 2d26d50a0..427aef25e 100644 --- a/youtube_dl/extractor/vivo.py +++ b/youtube_dl/extractor/vivo.py @@ -14,7 +14,7 @@ class VivoIE(InfoExtractor): _VALID_URL = r'http://(?:www\.)?vivo\.sx/(?P[a-f0-9]{10})' _TEST = { 'url': 'http://vivo.sx/d7ddda0e78', - 'md5': '2f36fed6235b16da96ce9b4dc890940d', + 'md5': '15b3af41be0b4fe01f4df075c2678b2c', 'info_dict': { 'id': 'd7ddda0e78', 'ext': 'mp4',