1 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..utils import unified_strdate
10 class VineIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:www\.)?vine\.co/(?:v|oembed)/(?P<id>\w+)'
13 'url': 'https://vine.co/v/b9KOOWX7HUx',
14 'md5': '2f36fed6235b16da96ce9b4dc890940d',
19 'alt_title': 'Vine by Jack Dorsey',
20 'description': 'Chicken.',
21 'upload_date': '20130519',
22 'uploader': 'Jack Dorsey',
26 'url': 'https://vine.co/v/MYxVapFvz2z',
27 'md5': '7b9a7cbc76734424ff942eb52c8f1065',
31 'title': 'Fuck Da Police #Mikebrown #justice #ferguson #prayforferguson #protesting #NMOS14',
32 'alt_title': 'Vine by Luna',
33 'description': 'Fuck Da Police #Mikebrown #justice #ferguson #prayforferguson #protesting #NMOS14',
34 'upload_date': '20140815',
36 'uploader_id': '1102363502380728320',
39 'url': 'https://vine.co/v/bxVjBbZlPUH',
40 'md5': 'ea27decea3fa670625aac92771a96b73',
44 'title': '#mw3 #ac130 #killcam #angelofdeath',
45 'alt_title': 'Vine by Z3k3',
46 'description': '#mw3 #ac130 #killcam #angelofdeath',
47 'upload_date': '20130430',
49 'uploader_id': '936470460173008896',
52 'url': 'https://vine.co/oembed/MYxVapFvz2z.json',
53 'only_matching': True,
56 def _real_extract(self, url):
57 video_id = self._match_id(url)
58 webpage = self._download_webpage('https://vine.co/v/' + video_id, video_id)
60 data = self._parse_json(
61 self._html_search_regex(
62 r'window\.POST_DATA = { %s: ({.+?}) };\s*</script>' % video_id,
63 webpage, 'vine data'),
67 'format_id': '%(format)s-%(rate)s' % f,
68 'vcodec': f['format'],
71 } for f in data['videoUrls']]
73 self._sort_formats(formats)
77 'title': self._og_search_title(webpage),
78 'alt_title': self._og_search_description(webpage, default=None),
79 'description': data['description'],
80 'thumbnail': data['thumbnailUrl'],
81 'upload_date': unified_strdate(data['created']),
82 'uploader': data['username'],
83 'uploader_id': data['userIdStr'],
84 'like_count': data['likes']['count'],
85 'comment_count': data['comments']['count'],
86 'repost_count': data['reposts']['count'],
91 class VineUserIE(InfoExtractor):
93 _VALID_URL = r'(?:https?://)?vine\.co/(?P<u>u/)?(?P<user>[^/]+)/?(\?.*)?$'
94 _VINE_BASE_URL = "https://vine.co/"
97 'url': 'https://vine.co/Visa',
101 'playlist_mincount': 46,
104 'url': 'https://vine.co/u/941705360593584128',
105 'only_matching': True,
109 def _real_extract(self, url):
110 mobj = re.match(self._VALID_URL, url)
111 user = mobj.group('user')
114 profile_url = "%sapi/users/profiles/%s%s" % (
115 self._VINE_BASE_URL, 'vanity/' if not u else '', user)
116 profile_data = self._download_json(
117 profile_url, user, note='Downloading user profile data')
119 user_id = profile_data['data']['userId']
121 for pagenum in itertools.count(1):
122 timeline_url = "%sapi/timelines/users/%s?page=%s&size=100" % (
123 self._VINE_BASE_URL, user_id, pagenum)
124 timeline_page = self._download_json(
125 timeline_url, user, note='Downloading page %d' % pagenum)
126 timeline_data.extend(timeline_page['data']['records'])
127 if timeline_page['data']['nextPage'] is None:
131 self.url_result(e['permalinkUrl'], 'Vine') for e in timeline_data]
132 return self.playlist_result(entries, user)