cbs.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. sanitized_Request,
  5. smuggle_url,
  6. )
  7. class CBSIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?(?:cbs\.com/shows/[^/]+/(?:video|artist)|colbertlateshow\.com/(?:video|podcasts))/[^/]+/(?P<id>[^/]+)'
  9. _TESTS = [{
  10. 'url': 'http://www.cbs.com/shows/garth-brooks/video/_u7W953k6la293J7EPTd9oHkSPs6Xn6_/connect-chat-feat-garth-brooks/',
  11. 'info_dict': {
  12. 'id': '4JUVEwq3wUT7',
  13. 'display_id': 'connect-chat-feat-garth-brooks',
  14. 'ext': 'flv',
  15. 'title': 'Connect Chat feat. Garth Brooks',
  16. 'description': 'Connect with country music singer Garth Brooks, as he chats with fans on Wednesday November 27, 2013. Be sure to tune in to Garth Brooks: Live from Las Vegas, Friday November 29, at 9/8c on CBS!',
  17. 'duration': 1495,
  18. },
  19. 'params': {
  20. # rtmp download
  21. 'skip_download': True,
  22. },
  23. '_skip': 'Blocked outside the US',
  24. }, {
  25. 'url': 'http://www.cbs.com/shows/liveonletterman/artist/221752/st-vincent/',
  26. 'info_dict': {
  27. 'id': 'WWF_5KqY3PK1',
  28. 'display_id': 'st-vincent',
  29. 'ext': 'flv',
  30. 'title': 'Live on Letterman - St. Vincent',
  31. 'description': 'Live On Letterman: St. Vincent in concert from New York\'s Ed Sullivan Theater on Tuesday, July 16, 2014.',
  32. 'duration': 3221,
  33. },
  34. 'params': {
  35. # rtmp download
  36. 'skip_download': True,
  37. },
  38. '_skip': 'Blocked outside the US',
  39. }, {
  40. 'url': 'http://colbertlateshow.com/video/8GmB0oY0McANFvp2aEffk9jZZZ2YyXxy/the-colbeard/',
  41. 'only_matching': True,
  42. }, {
  43. 'url': 'http://www.colbertlateshow.com/podcasts/dYSwjqPs_X1tvbV_P2FcPWRa_qT6akTC/in-the-bad-room-with-stephen/',
  44. 'only_matching': True,
  45. }]
  46. def _real_extract(self, url):
  47. display_id = self._match_id(url)
  48. request = sanitized_Request(url)
  49. # Android UA is served with higher quality (720p) streams (see
  50. # https://github.com/rg3/youtube-dl/issues/7490)
  51. request.add_header('User-Agent', 'Mozilla/5.0 (Linux; Android 4.4; Nexus 5)')
  52. webpage = self._download_webpage(request, display_id)
  53. real_id = self._search_regex(
  54. [r"video\.settings\.pid\s*=\s*'([^']+)';", r"cbsplayer\.pid\s*=\s*'([^']+)';"],
  55. webpage, 'real video ID')
  56. return {
  57. '_type': 'url_transparent',
  58. 'ie_key': 'ThePlatform',
  59. 'url': smuggle_url(
  60. 'http://link.theplatform.com/s/dJ5BDC/%s?mbr=true&manifest=m3u' % real_id,
  61. {'force_smil_url': True}),
  62. 'display_id': display_id,
  63. }