1 from __future__ import unicode_literals
7 from .common import InfoExtractor
8 from ..utils import unified_strdate
11 class VineIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?vine\.co/v/(?P<id>\w+)'
14 'url': 'https://vine.co/v/b9KOOWX7HUx',
15 'md5': '2f36fed6235b16da96ce9b4dc890940d',
20 'description': 'Chicken.',
21 'upload_date': '20130519',
22 'uploader': 'Jack Dorsey',
27 def _real_extract(self, url):
28 video_id = self._match_id(url)
29 webpage = self._download_webpage('https://vine.co/v/' + video_id, video_id)
31 data = json.loads(self._html_search_regex(
32 r'window\.POST_DATA = { %s: ({.+?}) }' % video_id, webpage, 'vine data'))
35 'url': data['videoLowURL'],
39 'url': data['videoUrl'],
41 'format_id': 'standard',
46 'title': self._og_search_title(webpage),
47 'description': data['description'],
48 'thumbnail': data['thumbnailUrl'],
49 'upload_date': unified_strdate(data['created']),
50 'uploader': data['username'],
51 'uploader_id': data['userIdStr'],
52 'like_count': data['likes']['count'],
53 'comment_count': data['comments']['count'],
54 'repost_count': data['reposts']['count'],
59 class VineUserIE(InfoExtractor):
61 _VALID_URL = r'(?:https?://)?vine\.co/(?P<u>u/)?(?P<user>[^/]+)/?(\?.*)?$'
62 _VINE_BASE_URL = "https://vine.co/"
65 'url': 'https://vine.co/Visa',
69 'playlist_mincount': 46,
72 'url': 'https://vine.co/u/941705360593584128',
73 'only_matching': True,
77 def _real_extract(self, url):
78 mobj = re.match(self._VALID_URL, url)
79 user = mobj.group('user')
82 profile_url = "%sapi/users/profiles/%s%s" % (
83 self._VINE_BASE_URL, 'vanity/' if not u else '', user)
84 profile_data = self._download_json(
85 profile_url, user, note='Downloading user profile data')
87 user_id = profile_data['data']['userId']
89 for pagenum in itertools.count(1):
90 timeline_url = "%sapi/timelines/users/%s?page=%s&size=100" % (
91 self._VINE_BASE_URL, user_id, pagenum)
92 timeline_page = self._download_json(
93 timeline_url, user, note='Downloading page %d' % pagenum)
94 timeline_data.extend(timeline_page['data']['records'])
95 if timeline_page['data']['nextPage'] is None:
99 self.url_result(e['permalinkUrl'], 'Vine') for e in timeline_data]
100 return self.playlist_result(entries, user)