You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.4 KiB

  1. import re
  2. import json
  3. from .common import InfoExtractor
  4. from ..utils import determine_ext
  5. class BreakIE(InfoExtractor):
  6. _VALID_URL = r'(?:http://)?(?:www\.)?break\.com/video/([^/]+)'
  7. _TEST = {
  8. u'url': u'http://www.break.com/video/when-girls-act-like-guys-2468056',
  9. u'file': u'2468056.mp4',
  10. u'md5': u'a3513fb1547fba4fb6cfac1bffc6c46b',
  11. u'info_dict': {
  12. u"title": u"When Girls Act Like D-Bags"
  13. }
  14. }
  15. def _real_extract(self, url):
  16. mobj = re.match(self._VALID_URL, url)
  17. video_id = mobj.group(1).split("-")[-1]
  18. embed_url = 'http://www.break.com/embed/%s' % video_id
  19. webpage = self._download_webpage(embed_url, video_id)
  20. info_json = self._search_regex(r'var embedVars = ({.*?});', webpage,
  21. u'info json', flags=re.DOTALL)
  22. info = json.loads(info_json)
  23. video_url = info['videoUri']
  24. m_youtube = re.search(r'(https?://www\.youtube\.com/watch\?v=.*)', video_url)
  25. if m_youtube is not None:
  26. return self.url_result(m_youtube.group(1), 'Youtube')
  27. final_url = video_url + '?' + info['AuthToken']
  28. return [{
  29. 'id': video_id,
  30. 'url': final_url,
  31. 'ext': determine_ext(final_url),
  32. 'title': info['contentName'],
  33. 'thumbnail': info['thumbUri'],
  34. }]