]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/vine.py
release 2014.04.30.1
[yt-dlp.git] / youtube_dl / extractor / vine.py
CommitLineData
5dc733f0
JMF
1from __future__ import unicode_literals
2
eb1634cb 3import re
f919201e 4import json
eb1634cb
PH
5
6from .common import InfoExtractor
f919201e 7from ..utils import unified_strdate
eb1634cb
PH
8
9
10class VineIE(InfoExtractor):
5dc733f0 11 _VALID_URL = r'https?://(?:www\.)?vine\.co/v/(?P<id>\w+)'
6f5ac90c 12 _TEST = {
5dc733f0
JMF
13 'url': 'https://vine.co/v/b9KOOWX7HUx',
14 'md5': '2f36fed6235b16da96ce9b4dc890940d',
15 'info_dict': {
16 'id': 'b9KOOWX7HUx',
17 'ext': 'mp4',
5dc733f0 18 'title': 'Chicken.',
f919201e
S
19 'description': 'Chicken.',
20 'upload_date': '20130519',
21 'uploader': 'Jack Dorsey',
22 'uploader_id': '76',
5dc733f0 23 },
6f5ac90c 24 }
eb1634cb
PH
25
26 def _real_extract(self, url):
27 mobj = re.match(self._VALID_URL, url)
eb1634cb 28 video_id = mobj.group('id')
eb1634cb 29
f919201e 30 webpage = self._download_webpage('https://vine.co/v/' + video_id, video_id)
eb1634cb 31
f919201e
S
32 data = json.loads(self._html_search_regex(
33 r'window\.POST_DATA = { %s: ({.+?}) }' % video_id, webpage, 'vine data'))
acd69589 34 print(json.dumps(data, indent=2))
f919201e
S
35 formats = [
36 {
37 'url': data['videoLowURL'],
38 'ext': 'mp4',
39 'format_id': 'low',
40 },
41 {
42 'url': data['videoUrl'],
43 'ext': 'mp4',
44 'format_id': 'standard',
45 }
46 ]
eb1634cb 47
5dc733f0
JMF
48 return {
49 'id': video_id,
5dc733f0 50 'title': self._og_search_title(webpage),
f919201e
S
51 'description': data['description'],
52 'thumbnail': data['thumbnailUrl'],
53 'upload_date': unified_strdate(data['created']),
54 'uploader': data['username'],
55 'uploader_id': data['userIdStr'],
56 'like_count': data['likes']['count'],
57 'comment_count': data['comments']['count'],
58 'repost_count': data['reposts']['count'],
59 'formats': formats,
acd69589 60 }