2 from __future__ import unicode_literals
7 from .common import InfoExtractor
14 class VineIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?vine\.co/(?:v|oembed)/(?P<id>\w+)'
17 'url': 'https://vine.co/v/b9KOOWX7HUx',
18 'md5': '2f36fed6235b16da96ce9b4dc890940d',
23 'alt_title': 'Vine by Jack Dorsey',
24 'upload_date': '20130519',
25 'uploader': 'Jack Dorsey',
33 'url': 'https://vine.co/v/MYxVapFvz2z',
34 'md5': '7b9a7cbc76734424ff942eb52c8f1065',
38 'title': 'Fuck Da Police #Mikebrown #justice #ferguson #prayforferguson #protesting #NMOS14',
39 'alt_title': 'Vine by Mars Ruiz',
40 'upload_date': '20140815',
41 'uploader': 'Mars Ruiz',
42 'uploader_id': '1102363502380728320',
49 'url': 'https://vine.co/v/bxVjBbZlPUH',
50 'md5': 'ea27decea3fa670625aac92771a96b73',
54 'title': '#mw3 #ac130 #killcam #angelofdeath',
55 'alt_title': 'Vine by Z3k3',
56 'upload_date': '20130430',
58 'uploader_id': '936470460173008896',
65 'url': 'https://vine.co/oembed/MYxVapFvz2z.json',
66 'only_matching': True,
68 'url': 'https://vine.co/v/e192BnZnZ9V',
72 'title': 'ยิ้ม~ เขิน~ อาย~ น่าร้ากอ้ะ >//< @n_whitewo @orlameena #lovesicktheseries #lovesickseason2',
73 'alt_title': 'Vine by Pimry_zaa',
74 'upload_date': '20150705',
75 'uploader': 'Pimry_zaa',
76 'uploader_id': '1135760698325307392',
83 'skip_download': True,
87 def _real_extract(self, url):
88 video_id = self._match_id(url)
89 webpage = self._download_webpage('https://vine.co/v/' + video_id, video_id)
91 data = self._parse_json(
93 r'window\.POST_DATA\s*=\s*{\s*%s\s*:\s*({.+?})\s*};\s*</script>' % video_id,
94 webpage, 'vine data'),
98 'format_id': '%(format)s-%(rate)s' % f,
99 'vcodec': f.get('format'),
100 'quality': f.get('rate'),
101 'url': f['videoUrl'],
102 } for f in data['videoUrls'] if f.get('videoUrl')]
104 self._sort_formats(formats)
106 username = data.get('username')
110 'title': data.get('description') or self._og_search_title(webpage),
111 'alt_title': 'Vine by %s' % username if username else self._og_search_description(webpage, default=None),
112 'thumbnail': data.get('thumbnailUrl'),
113 'upload_date': unified_strdate(data.get('created')),
114 'uploader': username,
115 'uploader_id': data.get('userIdStr'),
116 'view_count': int_or_none(data.get('loops', {}).get('count')),
117 'like_count': int_or_none(data.get('likes', {}).get('count')),
118 'comment_count': int_or_none(data.get('comments', {}).get('count')),
119 'repost_count': int_or_none(data.get('reposts', {}).get('count')),
124 class VineUserIE(InfoExtractor):
125 IE_NAME = 'vine:user'
126 _VALID_URL = r'(?:https?://)?vine\.co/(?P<u>u/)?(?P<user>[^/]+)/?(\?.*)?$'
127 _VINE_BASE_URL = 'https://vine.co/'
130 'url': 'https://vine.co/Visa',
134 'playlist_mincount': 46,
137 'url': 'https://vine.co/u/941705360593584128',
138 'only_matching': True,
142 def _real_extract(self, url):
143 mobj = re.match(self._VALID_URL, url)
144 user = mobj.group('user')
147 profile_url = '%sapi/users/profiles/%s%s' % (
148 self._VINE_BASE_URL, 'vanity/' if not u else '', user)
149 profile_data = self._download_json(
150 profile_url, user, note='Downloading user profile data')
152 user_id = profile_data['data']['userId']
154 for pagenum in itertools.count(1):
155 timeline_url = '%sapi/timelines/users/%s?page=%s&size=100' % (
156 self._VINE_BASE_URL, user_id, pagenum)
157 timeline_page = self._download_json(
158 timeline_url, user, note='Downloading page %d' % pagenum)
159 timeline_data.extend(timeline_page['data']['records'])
160 if timeline_page['data']['nextPage'] is None:
164 self.url_result(e['permalinkUrl'], 'Vine') for e in timeline_data]
165 return self.playlist_result(entries, user)