2014-02-10 14:48:46 -05:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2013-06-23 16:59:51 -04:00
|
|
|
import re
|
2013-07-23 05:41:05 -04:00
|
|
|
import json
|
2013-06-23 16:59:51 -04:00
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
|
|
|
|
|
|
|
class BreakIE(InfoExtractor):
|
2014-10-03 07:57:18 -04:00
|
|
|
_VALID_URL = r'http://(?:www\.)?break\.com/video/(?:[^/]+/)*.+-(?P<id>\d+)'
|
|
|
|
_TESTS = [{
|
2014-02-10 14:48:46 -05:00
|
|
|
'url': 'http://www.break.com/video/when-girls-act-like-guys-2468056',
|
2014-10-03 07:57:18 -04:00
|
|
|
'md5': '33aa4ff477ecd124d18d7b5d23b87ce5',
|
2014-02-10 14:48:46 -05:00
|
|
|
'info_dict': {
|
|
|
|
'id': '2468056',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'When Girls Act Like D-Bags',
|
2013-06-27 14:46:46 -04:00
|
|
|
}
|
2014-10-03 07:57:18 -04:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.break.com/video/ugc/baby-flex-2773063',
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
2013-06-23 16:59:51 -04:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2014-10-03 07:57:18 -04:00
|
|
|
video_id = self._match_id(url)
|
|
|
|
webpage = self._download_webpage(
|
|
|
|
'http://www.break.com/embed/%s' % video_id, video_id)
|
|
|
|
info = json.loads(self._search_regex(
|
|
|
|
r'var embedVars = ({.*})\s*?</script>',
|
|
|
|
webpage, 'info json', flags=re.DOTALL))
|
2013-07-23 05:41:05 -04:00
|
|
|
video_url = info['videoUri']
|
2014-04-04 13:01:18 -04:00
|
|
|
youtube_id = info.get('youtubeId')
|
|
|
|
if youtube_id:
|
|
|
|
return self.url_result(youtube_id, 'Youtube')
|
|
|
|
|
2013-07-23 05:41:05 -04:00
|
|
|
final_url = video_url + '?' + info['AuthToken']
|
2014-02-10 14:48:46 -05:00
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'url': final_url,
|
|
|
|
'title': info['contentName'],
|
2013-07-23 05:41:05 -04:00
|
|
|
'thumbnail': info['thumbUri'],
|
2014-02-10 14:48:46 -05:00
|
|
|
}
|