- mobj = re.match(self._VALID_URL, url)
- video_id = mobj.group(1).split("-")[-1]
- embed_url = 'http://www.break.com/embed/%s' % video_id
- webpage = self._download_webpage(embed_url, video_id)
- info_json = self._search_regex(r'var embedVars = ({.*})\s*?</script>',
- webpage, 'info json', flags=re.DOTALL)
- info = json.loads(info_json)
- video_url = info['videoUri']
- youtube_id = info.get('youtubeId')
- if youtube_id:
- return self.url_result(youtube_id, 'Youtube')
-
- final_url = video_url + '?' + info['AuthToken']
+ display_id, video_id = re.match(self._VALID_URL, url).groups()
+
+ webpage = self._download_webpage(url, display_id)
+
+ youtube_url = YoutubeIE._extract_url(webpage)
+ if youtube_url:
+ return self.url_result(youtube_url, ie=YoutubeIE.ie_key())
+
+ content = self._parse_json(
+ self._search_regex(
+ r'(?s)content["\']\s*:\s*(\[.+?\])\s*[,\n]', webpage,
+ 'content'),
+ display_id)
+
+ formats = []
+ for video in content:
+ video_url = video.get('url')
+ if not video_url or not isinstance(video_url, compat_str):
+ continue
+ bitrate = int_or_none(self._search_regex(
+ r'(\d+)_kbps', video_url, 'tbr', default=None))
+ formats.append({
+ 'url': video_url,
+ 'format_id': 'http-%d' % bitrate if bitrate else 'http',
+ 'tbr': bitrate,
+ })
+ self._sort_formats(formats)
+
+ title = self._search_regex(
+ (r'title["\']\s*:\s*(["\'])(?P<value>(?:(?!\1).)+)\1',
+ r'<h1[^>]*>(?P<value>[^<]+)'), webpage, 'title', group='value')
+
+ def get(key, name):
+ return int_or_none(self._search_regex(
+ r'%s["\']\s*:\s*["\'](\d+)' % key, webpage, name,
+ default=None))
+
+ age_limit = get('ratings', 'age limit')
+ video_id = video_id or get('pid', 'video id') or display_id
+