+
+
+class VineUserIE(InfoExtractor):
+ IE_NAME = 'vine:user'
+ _VALID_URL = r'https?://vine\.co/(?P<u>u/)?(?P<user>[^/]+)'
+ _VINE_BASE_URL = 'https://vine.co/'
+ _TESTS = [{
+ 'url': 'https://vine.co/itsruthb',
+ 'info_dict': {
+ 'id': 'itsruthb',
+ 'title': 'Ruth B',
+ 'description': '| Instagram/Twitter: itsruthb | still a lost boy from neverland',
+ },
+ 'playlist_mincount': 611,
+ }, {
+ 'url': 'https://vine.co/u/942914934646415360',
+ 'only_matching': True,
+ }]
+
+ @classmethod
+ def suitable(cls, url):
+ return False if VineIE.suitable(url) else super(VineUserIE, cls).suitable(url)
+
+ def _real_extract(self, url):
+ mobj = re.match(self._VALID_URL, url)
+ user = mobj.group('user')
+ u = mobj.group('u')
+
+ profile_url = '%sapi/users/profiles/%s%s' % (
+ self._VINE_BASE_URL, 'vanity/' if not u else '', user)
+ profile_data = self._download_json(
+ profile_url, user, note='Downloading user profile data')
+
+ data = profile_data['data']
+ user_id = data.get('userId') or data['userIdStr']
+ profile = self._download_json(
+ 'https://archive.vine.co/profiles/%s.json' % user_id, user_id)
+ entries = [
+ self.url_result(
+ 'https://vine.co/v/%s' % post_id, ie='Vine', video_id=post_id)
+ for post_id in profile['posts']
+ if post_id and isinstance(post_id, compat_str)]
+ return self.playlist_result(
+ entries, user, profile.get('username'), profile.get('description'))