2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
   9     compat_urllib_parse_urlparse
, 
  18 class AolIE(InfoExtractor
): 
  20     _VALID_URL 
= r
'(?:aol-video:|https?://(?:www\.)?aol\.(?:com|ca|co\.uk|de|jp)/video/(?:[^/]+/)*)(?P<id>[0-9a-f]+)' 
  24         'url': 'https://www.aol.com/video/view/u-s--official-warns-of-largest-ever-irs-phone-scam/518167793/', 
  25         'md5': '18ef68f48740e86ae94b98da815eec42', 
  29             'title': 'U.S. Official Warns Of \'Largest Ever\' IRS Phone Scam', 
  30             '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.', 
  31             'timestamp': 1395405060, 
  32             'upload_date': '20140321', 
  33             'uploader': 'Newsy Studio', 
  37             'skip_download': True, 
  40         # video with vidible ID 
  41         'url': 'https://www.aol.com/video/view/netflix-is-raising-rates/5707d6b8e4b090497b04f706/', 
  43             'id': '5707d6b8e4b090497b04f706', 
  45             'title': 'Netflix is Raising Rates', 
  46             'description': 'Netflix is rewarding millions of it’s long-standing members with an increase in cost. Veuer’s Carly Figueroa has more.', 
  47             'upload_date': '20160408', 
  48             'timestamp': 1460123280, 
  53             'skip_download': True, 
  56         'url': 'https://www.aol.com/video/view/park-bench-season-2-trailer/559a1b9be4b0c3bfad3357a7/', 
  57         'only_matching': True, 
  59         'url': 'https://www.aol.com/video/view/donald-trump-spokeswoman-tones-down-megyn-kelly-attacks/519442220/', 
  60         'only_matching': True, 
  62         'url': 'aol-video:5707d6b8e4b090497b04f706', 
  63         'only_matching': True, 
  65         'url': 'https://www.aol.com/video/playlist/PL8245/5ca79d19d21f1a04035db606/', 
  66         'only_matching': True, 
  68         'url': 'https://www.aol.ca/video/view/u-s-woman-s-family-arrested-for-murder-first-pinned-on-panhandler-police/5c7ccf45bc03931fa04b2fe1/', 
  69         'only_matching': True, 
  71         'url': 'https://www.aol.co.uk/video/view/-one-dead-and-22-hurt-in-bus-crash-/5cb3a6f3d21f1a072b457347/', 
  72         'only_matching': True, 
  74         'url': 'https://www.aol.de/video/view/eva-braun-privataufnahmen-von-hitlers-geliebter-werden-digitalisiert/5cb2d49de98ab54c113d3d5d/', 
  75         'only_matching': True, 
  77         'url': 'https://www.aol.jp/video/playlist/5a28e936a1334d000137da0c/5a28f3151e642219fde19831/', 
  78         'only_matching': True, 
  81     def _real_extract(self
, url
): 
  82         video_id 
= self
._match
_id
(url
) 
  84         response 
= self
._download
_json
( 
  85             'https://feedapi.b2c.on.aol.com/v1.0/app/videos/aolon/%s/details' % video_id
, 
  87         if response
['statusText'] != 'Ok': 
  88             raise ExtractorError('%s said: %s' % (self
.IE_NAME
, response
['statusText']), expected
=True) 
  90         video_data 
= response
['data'] 
  92         m3u8_url 
= url_or_none(video_data
.get('videoMasterPlaylist')) 
  94             formats
.extend(self
._extract
_m
3u8_formats
( 
  95                 m3u8_url
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False)) 
  96         for rendition 
in video_data
.get('renditions', []): 
  97             video_url 
= url_or_none(rendition
.get('url')) 
 100             ext 
= rendition
.get('format') 
 102                 formats
.extend(self
._extract
_m
3u8_formats
( 
 103                     video_url
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False)) 
 107                     'format_id': rendition
.get('quality'), 
 109                 mobj 
= re
.search(r
'(\d+)x(\d+)', video_url
) 
 112                         'width': int(mobj
.group(1)), 
 113                         'height': int(mobj
.group(2)), 
 116                     qs 
= compat_parse_qs(compat_urllib_parse_urlparse(video_url
).query
) 
 118                         'width': int_or_none(qs
.get('w', [None])[0]), 
 119                         'height': int_or_none(qs
.get('h', [None])[0]), 
 122         self
._sort
_formats
(formats
, ('width', 'height', 'tbr', 'format_id')) 
 126             'title': video_data
['title'], 
 127             'duration': int_or_none(video_data
.get('duration')), 
 128             'timestamp': int_or_none(video_data
.get('publishDate')), 
 129             'view_count': int_or_none(video_data
.get('views')), 
 130             'description': video_data
.get('description'), 
 131             'uploader': video_data
.get('videoOwner'),