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.

133 lines
5.0 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. ExtractorError,
  7. int_or_none,
  8. )
  9. class AolIE(InfoExtractor):
  10. IE_NAME = 'on.aol.com'
  11. _VALID_URL = r'(?:aol-video:|https?://on\.aol\.com/(?:[^/]+/)*(?:[^/?#&]+-)?)(?P<id>[^/?#&]+)'
  12. _TESTS = [{
  13. # video with 5min ID
  14. 'url': 'http://on.aol.com/video/u-s--official-warns-of-largest-ever-irs-phone-scam-518167793?icid=OnHomepageC2Wide_MustSee_Img',
  15. 'md5': '18ef68f48740e86ae94b98da815eec42',
  16. 'info_dict': {
  17. 'id': '518167793',
  18. 'ext': 'mp4',
  19. 'title': 'U.S. Official Warns Of \'Largest Ever\' IRS Phone Scam',
  20. 'description': 'A major phone scam has cost thousands of taxpayers more than $1 million, with less than a month until income tax returns are due to the IRS.',
  21. 'timestamp': 1395405060,
  22. 'upload_date': '20140321',
  23. 'uploader': 'Newsy Studio',
  24. },
  25. 'params': {
  26. # m3u8 download
  27. 'skip_download': True,
  28. }
  29. }, {
  30. # video with vidible ID
  31. 'url': 'http://on.aol.com/video/netflix-is-raising-rates-5707d6b8e4b090497b04f706?context=PC:homepage:PL1944:1460189336183',
  32. 'info_dict': {
  33. 'id': '5707d6b8e4b090497b04f706',
  34. 'ext': 'mp4',
  35. 'title': 'Netflix is Raising Rates',
  36. 'description': 'Netflix is rewarding millions of it’s long-standing members with an increase in cost. Veuer’s Carly Figueroa has more.',
  37. 'upload_date': '20160408',
  38. 'timestamp': 1460123280,
  39. 'uploader': 'Veuer',
  40. },
  41. 'params': {
  42. # m3u8 download
  43. 'skip_download': True,
  44. }
  45. }, {
  46. 'url': 'http://on.aol.com/partners/abc-551438d309eab105804dbfe8/sneak-peek-was-haley-really-framed-570eaebee4b0448640a5c944',
  47. 'only_matching': True,
  48. }, {
  49. 'url': 'http://on.aol.com/shows/park-bench-shw518173474-559a1b9be4b0c3bfad3357a7?context=SH:SHW518173474:PL4327:1460619712763',
  50. 'only_matching': True,
  51. }, {
  52. 'url': 'http://on.aol.com/video/519442220',
  53. 'only_matching': True,
  54. }, {
  55. 'url': 'aol-video:5707d6b8e4b090497b04f706',
  56. 'only_matching': True,
  57. }]
  58. def _real_extract(self, url):
  59. video_id = self._match_id(url)
  60. response = self._download_json(
  61. 'https://feedapi.b2c.on.aol.com/v1.0/app/videos/aolon/%s/details' % video_id,
  62. video_id)['response']
  63. if response['statusText'] != 'Ok':
  64. raise ExtractorError('%s said: %s' % (self.IE_NAME, response['statusText']), expected=True)
  65. video_data = response['data']
  66. formats = []
  67. m3u8_url = video_data.get('videoMasterPlaylist')
  68. if m3u8_url:
  69. formats.extend(self._extract_m3u8_formats(
  70. m3u8_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
  71. for rendition in video_data.get('renditions', []):
  72. video_url = rendition.get('url')
  73. if not video_url:
  74. continue
  75. ext = rendition.get('format')
  76. if ext == 'm3u8':
  77. formats.extend(self._extract_m3u8_formats(
  78. video_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
  79. else:
  80. f = {
  81. 'url': video_url,
  82. 'format_id': rendition.get('quality'),
  83. }
  84. mobj = re.search(r'(\d+)x(\d+)', video_url)
  85. if mobj:
  86. f.update({
  87. 'width': int(mobj.group(1)),
  88. 'height': int(mobj.group(2)),
  89. })
  90. formats.append(f)
  91. self._sort_formats(formats, ('width', 'height', 'tbr', 'format_id'))
  92. return {
  93. 'id': video_id,
  94. 'title': video_data['title'],
  95. 'duration': int_or_none(video_data.get('duration')),
  96. 'timestamp': int_or_none(video_data.get('publishDate')),
  97. 'view_count': int_or_none(video_data.get('views')),
  98. 'description': video_data.get('description'),
  99. 'uploader': video_data.get('videoOwner'),
  100. 'formats': formats,
  101. }
  102. class AolFeaturesIE(InfoExtractor):
  103. IE_NAME = 'features.aol.com'
  104. _VALID_URL = r'https?://features\.aol\.com/video/(?P<id>[^/?#]+)'
  105. _TESTS = [{
  106. 'url': 'http://features.aol.com/video/behind-secret-second-careers-late-night-talk-show-hosts',
  107. 'md5': '7db483bb0c09c85e241f84a34238cc75',
  108. 'info_dict': {
  109. 'id': '519507715',
  110. 'ext': 'mp4',
  111. 'title': 'What To Watch - February 17, 2016',
  112. },
  113. 'add_ie': ['FiveMin'],
  114. }]
  115. def _real_extract(self, url):
  116. display_id = self._match_id(url)
  117. webpage = self._download_webpage(url, display_id)
  118. return self.url_result(self._search_regex(
  119. r'<script type="text/javascript" src="(https?://[^/]*?5min\.com/Scripts/PlayerSeed\.js[^"]+)"',
  120. webpage, '5min embed url'), 'FiveMin')