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.

56 lines
2.3 KiB

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