]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vine.py
651ba317dcd8fffefb2ac938c9f09d5de8356865
[youtubedl] / youtube_dl / extractor / vine.py
1 import re
2
3 from .common import InfoExtractor
4
5
6 class VineIE(InfoExtractor):
7 _VALID_URL = r'(?:https?://)?(?:www\.)?vine\.co/v/(?P<id>\w+)'
8 _TEST = {
9 u'url': u'https://vine.co/v/b9KOOWX7HUx',
10 u'file': u'b9KOOWX7HUx.mp4',
11 u'md5': u'2f36fed6235b16da96ce9b4dc890940d',
12 u'info_dict': {
13 u"uploader": u"Jack Dorsey",
14 u"title": u"Chicken."
15 }
16 }
17
18 def _real_extract(self, url):
19 mobj = re.match(self._VALID_URL, url)
20
21 video_id = mobj.group('id')
22 webpage_url = 'https://vine.co/v/' + video_id
23 webpage = self._download_webpage(webpage_url, video_id)
24
25 self.report_extraction(video_id)
26
27 video_url = self._html_search_regex(r'<meta property="twitter:player:stream" content="(.+?)"',
28 webpage, u'video URL')
29
30 uploader = self._html_search_regex(r'<p class="username">(.*?)</p>',
31 webpage, u'uploader', fatal=False, flags=re.DOTALL)
32
33 return [{
34 'id': video_id,
35 'url': video_url,
36 'ext': 'mp4',
37 'title': self._og_search_title(webpage),
38 'thumbnail': self._og_search_thumbnail(webpage),
39 'uploader': uploader,
40 }]