[vine] Fix uploader extraction
[youtube-dl] / youtube_dl / extractor / vine.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class VineIE(InfoExtractor):
9     _VALID_URL = r'https?://(?:www\.)?vine\.co/v/(?P<id>\w+)'
10     _TEST = {
11         'url': 'https://vine.co/v/b9KOOWX7HUx',
12         'md5': '2f36fed6235b16da96ce9b4dc890940d',
13         'info_dict': {
14             'id': 'b9KOOWX7HUx',
15             'ext': 'mp4',
16             'uploader': 'Jack Dorsey',
17             'title': 'Chicken.',
18         },
19     }
20
21     def _real_extract(self, url):
22         mobj = re.match(self._VALID_URL, url)
23
24         video_id = mobj.group('id')
25         webpage_url = 'https://vine.co/v/' + video_id
26         webpage = self._download_webpage(webpage_url, video_id)
27
28         self.report_extraction(video_id)
29
30         video_url = self._html_search_meta('twitter:player:stream', webpage,
31             'video URL')
32
33         twitter_title  = self._html_search_meta('twitter:title', webpage,
34             'twitter title')
35         uploader = re.sub('\'s post on Vine', '', twitter_title)
36
37         return {
38             'id': video_id,
39             'url': video_url,
40             'ext': 'mp4',
41             'title': self._og_search_title(webpage),
42             'thumbnail': self._og_search_thumbnail(webpage),
43             'uploader': uploader,
44         }