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.

140 lines
5.2 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .amp import AMPIE
  4. from .common import InfoExtractor
  5. class FoxNewsIE(AMPIE):
  6. IE_NAME = 'foxnews'
  7. IE_DESC = 'Fox News and Fox Business Video'
  8. _VALID_URL = r'https?://(?P<host>video\.(?:insider\.)?fox(?:news|business)\.com)/v/(?:video-embed\.html\?video_id=)?(?P<id>\d+)'
  9. _TESTS = [
  10. {
  11. 'url': 'http://video.foxnews.com/v/3937480/frozen-in-time/#sp=show-clips',
  12. 'md5': '32aaded6ba3ef0d1c04e238d01031e5e',
  13. 'info_dict': {
  14. 'id': '3937480',
  15. 'ext': 'flv',
  16. 'title': 'Frozen in Time',
  17. 'description': '16-year-old girl is size of toddler',
  18. 'duration': 265,
  19. 'timestamp': 1304411491,
  20. 'upload_date': '20110503',
  21. 'thumbnail': r're:^https?://.*\.jpg$',
  22. },
  23. },
  24. {
  25. 'url': 'http://video.foxnews.com/v/3922535568001/rep-luis-gutierrez-on-if-obamas-immigration-plan-is-legal/#sp=show-clips',
  26. 'md5': '5846c64a1ea05ec78175421b8323e2df',
  27. 'info_dict': {
  28. 'id': '3922535568001',
  29. 'ext': 'mp4',
  30. 'title': "Rep. Luis Gutierrez on if Obama's immigration plan is legal",
  31. 'description': "Congressman discusses president's plan",
  32. 'duration': 292,
  33. 'timestamp': 1417662047,
  34. 'upload_date': '20141204',
  35. 'thumbnail': r're:^https?://.*\.jpg$',
  36. },
  37. 'params': {
  38. # m3u8 download
  39. 'skip_download': True,
  40. },
  41. },
  42. {
  43. 'url': 'http://video.foxnews.com/v/video-embed.html?video_id=3937480&d=video.foxnews.com',
  44. 'only_matching': True,
  45. },
  46. {
  47. 'url': 'http://video.foxbusiness.com/v/4442309889001',
  48. 'only_matching': True,
  49. },
  50. {
  51. # From http://insider.foxnews.com/2016/08/25/univ-wisconsin-student-group-pushing-silence-certain-words
  52. 'url': 'http://video.insider.foxnews.com/v/video-embed.html?video_id=5099377331001&autoplay=true&share_url=http://insider.foxnews.com/2016/08/25/univ-wisconsin-student-group-pushing-silence-certain-words&share_title=Student%20Group:%20Saying%20%27Politically%20Correct,%27%20%27Trash%27%20and%20%27Lame%27%20Is%20Offensive&share=true',
  53. 'only_matching': True,
  54. },
  55. ]
  56. def _real_extract(self, url):
  57. host, video_id = re.match(self._VALID_URL, url).groups()
  58. info = self._extract_feed_info(
  59. 'http://%s/v/feed/video/%s.js?template=fox' % (host, video_id))
  60. info['id'] = video_id
  61. return info
  62. class FoxNewsArticleIE(InfoExtractor):
  63. _VALID_URL = r'https?://(?:www\.)?foxnews\.com/(?!v)([^/]+/)+(?P<id>[a-z-]+)'
  64. IE_NAME = 'foxnews:article'
  65. _TEST = {
  66. 'url': 'http://www.foxnews.com/politics/2016/09/08/buzz-about-bud-clinton-camp-denies-claims-wore-earpiece-at-forum.html',
  67. 'md5': '62aa5a781b308fdee212ebb6f33ae7ef',
  68. 'info_dict': {
  69. 'id': '5116295019001',
  70. 'ext': 'mp4',
  71. 'title': 'Trump and Clinton asked to defend positions on Iraq War',
  72. 'description': 'Veterans react on \'The Kelly File\'',
  73. 'timestamp': 1473299755,
  74. 'upload_date': '20160908',
  75. },
  76. }
  77. def _real_extract(self, url):
  78. display_id = self._match_id(url)
  79. webpage = self._download_webpage(url, display_id)
  80. video_id = self._html_search_regex(
  81. r'data-video-id=([\'"])(?P<id>[^\'"]+)\1',
  82. webpage, 'video ID', group='id')
  83. return self.url_result(
  84. 'http://video.foxnews.com/v/' + video_id,
  85. FoxNewsIE.ie_key())
  86. class FoxNewsInsiderIE(InfoExtractor):
  87. _VALID_URL = r'https?://insider\.foxnews\.com/([^/]+/)+(?P<id>[a-z-]+)'
  88. IE_NAME = 'foxnews:insider'
  89. _TEST = {
  90. 'url': 'http://insider.foxnews.com/2016/08/25/univ-wisconsin-student-group-pushing-silence-certain-words',
  91. 'md5': 'a10c755e582d28120c62749b4feb4c0c',
  92. 'info_dict': {
  93. 'id': '5099377331001',
  94. 'display_id': 'univ-wisconsin-student-group-pushing-silence-certain-words',
  95. 'ext': 'mp4',
  96. 'title': 'Student Group: Saying \'Politically Correct,\' \'Trash\' and \'Lame\' Is Offensive',
  97. 'description': 'Is campus censorship getting out of control?',
  98. 'timestamp': 1472168725,
  99. 'upload_date': '20160825',
  100. 'thumbnail': r're:^https?://.*\.jpg$',
  101. },
  102. 'params': {
  103. # m3u8 download
  104. 'skip_download': True,
  105. },
  106. 'add_ie': [FoxNewsIE.ie_key()],
  107. }
  108. def _real_extract(self, url):
  109. display_id = self._match_id(url)
  110. webpage = self._download_webpage(url, display_id)
  111. embed_url = self._html_search_meta('embedUrl', webpage, 'embed URL')
  112. title = self._og_search_title(webpage)
  113. description = self._og_search_description(webpage)
  114. return {
  115. '_type': 'url_transparent',
  116. 'ie_key': FoxNewsIE.ie_key(),
  117. 'url': embed_url,
  118. 'display_id': display_id,
  119. 'title': title,
  120. 'description': description,
  121. }