]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vine.py
Prepare for release.
[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 video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
31 webpage, u'title')
32
33 thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)(\?.*?)?"',
34 webpage, u'thumbnail', fatal=False)
35
36 uploader = self._html_search_regex(r'<div class="user">.*?<h2>(.+?)</h2>',
37 webpage, u'uploader', fatal=False, flags=re.DOTALL)
38
39 return [{
40 'id': video_id,
41 'url': video_url,
42 'ext': 'mp4',
43 'title': video_title,
44 'thumbnail': thumbnail,
45 'uploader': uploader,
46 }]