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.

47 lines
2.0 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .turner import TurnerBaseIE
  5. class TruTVIE(TurnerBaseIE):
  6. _VALID_URL = r'https?://(?:www\.)?trutv\.com(?:(?P<path>/shows/[^/]+/videos/[^/?#]+?)\.html|/full-episodes/[^/]+/(?P<id>\d+))'
  7. _TEST = {
  8. 'url': 'http://www.trutv.com/shows/10-things/videos/you-wont-believe-these-sports-bets.html',
  9. 'md5': '2cdc844f317579fed1a7251b087ff417',
  10. 'info_dict': {
  11. 'id': '/shows/10-things/videos/you-wont-believe-these-sports-bets',
  12. 'ext': 'mp4',
  13. 'title': 'You Won\'t Believe These Sports Bets',
  14. 'description': 'Jamie Lee sits down with a bookie to discuss the bizarre world of illegal sports betting.',
  15. 'upload_date': '20130305',
  16. }
  17. }
  18. def _real_extract(self, url):
  19. path, video_id = re.match(self._VALID_URL, url).groups()
  20. auth_required = False
  21. if path:
  22. data_src = 'http://www.trutv.com/video/cvp/v2/xml/content.xml?id=%s.xml' % path
  23. else:
  24. webpage = self._download_webpage(url, video_id)
  25. video_id = self._search_regex(
  26. r"TTV\.TVE\.episodeId\s*=\s*'([^']+)';",
  27. webpage, 'video id', default=video_id)
  28. auth_required = self._search_regex(
  29. r'TTV\.TVE\.authRequired\s*=\s*(true|false);',
  30. webpage, 'auth required', default='false') == 'true'
  31. data_src = 'http://www.trutv.com/tveverywhere/services/cvpXML.do?titleId=' + video_id
  32. return self._extract_cvp_info(
  33. data_src, path, {
  34. 'secure': {
  35. 'media_src': 'http://androidhls-secure.cdn.turner.com/trutv/big',
  36. 'tokenizer_src': 'http://www.trutv.com/tveverywhere/processors/services/token_ipadAdobe.do',
  37. },
  38. }, {
  39. 'url': url,
  40. 'site_name': 'truTV',
  41. 'auth_required': auth_required,
  42. })