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.

106 lines
4.1 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_DESC = 'Fox News and Fox Business Video'
  7. _VALID_URL = r'https?://(?P<host>video\.(?:insider\.)?fox(?:news|business)\.com)/v/(?:video-embed\.html\?video_id=)?(?P<id>\d+)'
  8. _TESTS = [
  9. {
  10. 'url': 'http://video.foxnews.com/v/3937480/frozen-in-time/#sp=show-clips',
  11. 'md5': '32aaded6ba3ef0d1c04e238d01031e5e',
  12. 'info_dict': {
  13. 'id': '3937480',
  14. 'ext': 'flv',
  15. 'title': 'Frozen in Time',
  16. 'description': '16-year-old girl is size of toddler',
  17. 'duration': 265,
  18. 'timestamp': 1304411491,
  19. 'upload_date': '20110503',
  20. 'thumbnail': 're:^https?://.*\.jpg$',
  21. },
  22. },
  23. {
  24. 'url': 'http://video.foxnews.com/v/3922535568001/rep-luis-gutierrez-on-if-obamas-immigration-plan-is-legal/#sp=show-clips',
  25. 'md5': '5846c64a1ea05ec78175421b8323e2df',
  26. 'info_dict': {
  27. 'id': '3922535568001',
  28. 'ext': 'mp4',
  29. 'title': "Rep. Luis Gutierrez on if Obama's immigration plan is legal",
  30. 'description': "Congressman discusses president's plan",
  31. 'duration': 292,
  32. 'timestamp': 1417662047,
  33. 'upload_date': '20141204',
  34. 'thumbnail': 're:^https?://.*\.jpg$',
  35. },
  36. 'params': {
  37. # m3u8 download
  38. 'skip_download': True,
  39. },
  40. },
  41. {
  42. 'url': 'http://video.foxnews.com/v/video-embed.html?video_id=3937480&d=video.foxnews.com',
  43. 'only_matching': True,
  44. },
  45. {
  46. 'url': 'http://video.foxbusiness.com/v/4442309889001',
  47. 'only_matching': True,
  48. },
  49. {
  50. # From http://insider.foxnews.com/2016/08/25/univ-wisconsin-student-group-pushing-silence-certain-words
  51. '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',
  52. 'only_matching': True,
  53. },
  54. ]
  55. def _real_extract(self, url):
  56. host, video_id = re.match(self._VALID_URL, url).groups()
  57. info = self._extract_feed_info(
  58. 'http://%s/v/feed/video/%s.js?template=fox' % (host, video_id))
  59. info['id'] = video_id
  60. return info
  61. class FoxNewsInsiderIE(InfoExtractor):
  62. _VALID_URL = r'https?://insider\.foxnews\.com/([^/]+/)+(?P<id>[a-z-]+)'
  63. IE_NAME = 'foxnews:insider'
  64. _TEST = {
  65. 'url': 'http://insider.foxnews.com/2016/08/25/univ-wisconsin-student-group-pushing-silence-certain-words',
  66. 'md5': 'a10c755e582d28120c62749b4feb4c0c',
  67. 'info_dict': {
  68. 'id': '5099377331001',
  69. 'display_id': 'univ-wisconsin-student-group-pushing-silence-certain-words',
  70. 'ext': 'mp4',
  71. 'title': 'Student Group: Saying \'Politically Correct,\' \'Trash\' and \'Lame\' Is Offensive',
  72. 'description': 'Is campus censorship getting out of control?',
  73. 'timestamp': 1472168725,
  74. 'upload_date': '20160825',
  75. 'thumbnail': 're:^https?://.*\.jpg$',
  76. },
  77. 'add_ie': [FoxNewsIE.ie_key()],
  78. }
  79. def _real_extract(self, url):
  80. display_id = self._match_id(url)
  81. webpage = self._download_webpage(url, display_id)
  82. embed_url = self._html_search_meta('embedUrl', webpage, 'embed URL')
  83. title = self._og_search_title(webpage)
  84. description = self._og_search_description(webpage)
  85. return {
  86. '_type': 'url_transparent',
  87. 'ie_key': FoxNewsIE.ie_key(),
  88. 'url': embed_url,
  89. 'display_id': display_id,
  90. 'title': title,
  91. 'description': description,
  92. }