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.

59 lines
2.4 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .turner import TurnerBaseIE
  5. from ..utils import (
  6. extract_attributes,
  7. ExtractorError,
  8. )
  9. class TBSIE(TurnerBaseIE):
  10. _VALID_URL = r'https?://(?:www\.)?(?P<site>tbs|tntdrama)\.com/videos/(?:[^/]+/)+(?P<id>[^/?#]+)\.html'
  11. _TESTS = [{
  12. 'url': 'http://www.tbs.com/videos/people-of-earth/season-1/extras/2007318/theatrical-trailer.html',
  13. 'md5': '9e61d680e2285066ade7199e6408b2ee',
  14. 'info_dict': {
  15. 'id': '2007318',
  16. 'ext': 'mp4',
  17. 'title': 'Theatrical Trailer',
  18. 'description': 'Catch the latest comedy from TBS, People of Earth, premiering Halloween night--Monday, October 31, at 9/8c.',
  19. }
  20. }, {
  21. 'url': 'http://www.tntdrama.com/videos/good-behavior/season-1/extras/1538823/you-better-run.html',
  22. 'md5': 'ce53c6ead5e9f3280b4ad2031a6fab56',
  23. 'info_dict': {
  24. 'id': '1538823',
  25. 'ext': 'mp4',
  26. 'title': 'You Better Run',
  27. 'description': 'Letty Raines must figure out what she\'s running toward while running away from her past. Good Behavior premieres November 15 at 9/8c.',
  28. }
  29. }]
  30. def _real_extract(self, url):
  31. domain, display_id = re.match(self._VALID_URL, url).groups()
  32. site = domain[:3]
  33. webpage = self._download_webpage(url, display_id)
  34. video_params = extract_attributes(self._search_regex(r'(<[^>]+id="page-video"[^>]*>)', webpage, 'video params'))
  35. if video_params.get('isAuthRequired') == 'true':
  36. raise ExtractorError(
  37. 'This video is only available via cable service provider subscription that'
  38. ' is not currently supported.', expected=True)
  39. query = None
  40. clip_id = video_params.get('clipid')
  41. if clip_id:
  42. query = 'id=' + clip_id
  43. else:
  44. query = 'titleId=' + video_params['titleid']
  45. return self._extract_cvp_info(
  46. 'http://www.%s.com/service/cvpXml?%s' % (domain, query), display_id, {
  47. 'default': {
  48. 'media_src': 'http://ht.cdn.turner.com/%s/big' % site,
  49. },
  50. 'secure': {
  51. 'media_src': 'http://androidhls-secure.cdn.turner.com/%s/big' % site,
  52. 'tokenizer_src': 'http://www.%s.com/video/processors/services/token_ipadAdobe.do' % domain,
  53. },
  54. })