- youtube_id = self._html_search_regex(
- r'(?s)id="jsid-video-post-container".*?data-external-id="([^"]+)"',
- webpage, 'video ID')
- title = self._html_search_regex(
- r'(?s)id="jsid-video-post-container".*?data-title="([^"]+)"',
- webpage, 'title', default=None)
- if not title:
- title = self._og_search_title(webpage)
- description = self._html_search_regex(
- r'(?s)<div class="video-caption">.*?<p>(.*?)</p>', webpage,
- 'description', fatal=False)
- view_count_str = self._html_search_regex(
- r'<p><b>([0-9][0-9,]*)</b> views</p>', webpage, 'view count',
- fatal=False)
- view_count = (
- None if view_count_str is None
- else int(view_count_str.replace(',', '')))
+ post_view = self._parse_json(
+ self._search_regex(
+ r'var\s+postView\s*=\s*new\s+app\.PostView\({\s*post:\s*({.+?})\s*,\s*posts:\s*prefetchedCurrentPost',
+ webpage, 'post view'),
+ display_id)
+
+ ie_key = None
+ source_url = post_view.get('sourceUrl')
+ if not source_url:
+ external_video_id = post_view['videoExternalId']
+ external_video_provider = post_view['videoExternalProvider']
+ source_url = self._EXTERNAL_VIDEO_PROVIDER[external_video_provider]['url'] % external_video_id
+ ie_key = self._EXTERNAL_VIDEO_PROVIDER[external_video_provider]['ie_key']
+ title = post_view['title']
+ description = post_view.get('description')
+ view_count = str_to_int(post_view.get('externalView'))
+ thumbnail = post_view.get('thumbnail_700w') or post_view.get('ogImageUrl') or post_view.get('thumbnail_300w')