]>
Commit | Line | Data |
---|---|---|
bffb245a | 1 | import re |
2 | ||
a820dc72 | 3 | from .yahoo import YahooIE |
bffb245a | 4 | from ..utils import ( |
5 | ExtractorError, | |
6 | int_or_none, | |
4dfbf869 | 7 | parse_qs, |
3052a30d | 8 | url_or_none, |
bffb245a | 9 | ) |
f8286385 JMF |
10 | |
11 | ||
6368e2e6 | 12 | class AolIE(YahooIE): # XXX: Do not subclass from concrete IE |
9751a457 | 13 | _WORKING = False |
9045d28b | 14 | IE_NAME = 'aol.com' |
a820dc72 | 15 | _VALID_URL = r'(?:aol-video:|https?://(?:www\.)?aol\.(?:com|ca|co\.uk|de|jp)/video/(?:[^/]+/)*)(?P<id>\d{9}|[0-9a-f]{24}|[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})' |
f8286385 | 16 | |
22a6f150 | 17 | _TESTS = [{ |
5565be9d | 18 | # video with 5min ID |
9045d28b | 19 | 'url': 'https://www.aol.com/video/view/u-s--official-warns-of-largest-ever-irs-phone-scam/518167793/', |
f8286385 JMF |
20 | 'md5': '18ef68f48740e86ae94b98da815eec42', |
21 | 'info_dict': { | |
22 | 'id': '518167793', | |
23 | 'ext': 'mp4', | |
24 | 'title': 'U.S. Official Warns Of \'Largest Ever\' IRS Phone Scam', | |
bffb245a | 25 | '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.', |
26 | 'timestamp': 1395405060, | |
27 | 'upload_date': '20140321', | |
28 | 'uploader': 'Newsy Studio', | |
f8286385 | 29 | }, |
bffb245a | 30 | 'params': { |
31 | # m3u8 download | |
32 | 'skip_download': True, | |
add96eb9 | 33 | }, |
bffb245a | 34 | }, { |
5565be9d | 35 | # video with vidible ID |
9045d28b | 36 | 'url': 'https://www.aol.com/video/view/netflix-is-raising-rates/5707d6b8e4b090497b04f706/', |
bffb245a | 37 | 'info_dict': { |
38 | 'id': '5707d6b8e4b090497b04f706', | |
39 | 'ext': 'mp4', | |
40 | 'title': 'Netflix is Raising Rates', | |
41 | 'description': 'Netflix is rewarding millions of it’s long-standing members with an increase in cost. Veuer’s Carly Figueroa has more.', | |
42 | 'upload_date': '20160408', | |
43 | 'timestamp': 1460123280, | |
44 | 'uploader': 'Veuer', | |
45 | }, | |
46 | 'params': { | |
47 | # m3u8 download | |
48 | 'skip_download': True, | |
add96eb9 | 49 | }, |
5565be9d | 50 | }, { |
9045d28b | 51 | 'url': 'https://www.aol.com/video/view/park-bench-season-2-trailer/559a1b9be4b0c3bfad3357a7/', |
5565be9d | 52 | 'only_matching': True, |
53 | }, { | |
9045d28b | 54 | 'url': 'https://www.aol.com/video/view/donald-trump-spokeswoman-tones-down-megyn-kelly-attacks/519442220/', |
5565be9d | 55 | 'only_matching': True, |
964f4933 | 56 | }, { |
9045d28b | 57 | 'url': 'aol-video:5707d6b8e4b090497b04f706', |
964f4933 S |
58 | 'only_matching': True, |
59 | }, { | |
9045d28b | 60 | 'url': 'https://www.aol.com/video/playlist/PL8245/5ca79d19d21f1a04035db606/', |
964f4933 | 61 | 'only_matching': True, |
cb6cd76f RA |
62 | }, { |
63 | 'url': 'https://www.aol.ca/video/view/u-s-woman-s-family-arrested-for-murder-first-pinned-on-panhandler-police/5c7ccf45bc03931fa04b2fe1/', | |
64 | 'only_matching': True, | |
65 | }, { | |
66 | 'url': 'https://www.aol.co.uk/video/view/-one-dead-and-22-hurt-in-bus-crash-/5cb3a6f3d21f1a072b457347/', | |
67 | 'only_matching': True, | |
68 | }, { | |
69 | 'url': 'https://www.aol.de/video/view/eva-braun-privataufnahmen-von-hitlers-geliebter-werden-digitalisiert/5cb2d49de98ab54c113d3d5d/', | |
70 | 'only_matching': True, | |
71 | }, { | |
72 | 'url': 'https://www.aol.jp/video/playlist/5a28e936a1334d000137da0c/5a28f3151e642219fde19831/', | |
73 | 'only_matching': True, | |
a820dc72 RA |
74 | }, { |
75 | # Yahoo video | |
76 | 'url': 'https://www.aol.com/video/play/991e6700-ac02-11ea-99ff-357400036f61/24bbc846-3e30-3c46-915e-fe8ccd7fcc46/', | |
77 | 'only_matching': True, | |
22a6f150 | 78 | }] |
f8286385 JMF |
79 | |
80 | def _real_extract(self, url): | |
1d4c9ed9 | 81 | video_id = self._match_id(url) |
a820dc72 RA |
82 | if '-' in video_id: |
83 | return self._extract_yahoo_video(video_id, 'us') | |
bffb245a | 84 | |
85 | response = self._download_json( | |
add96eb9 | 86 | f'https://feedapi.b2c.on.aol.com/v1.0/app/videos/aolon/{video_id}/details', |
bffb245a | 87 | video_id)['response'] |
88 | if response['statusText'] != 'Ok': | |
add96eb9 | 89 | raise ExtractorError('{} said: {}'.format(self.IE_NAME, response['statusText']), expected=True) |
bffb245a | 90 | |
91 | video_data = response['data'] | |
92 | formats = [] | |
9045d28b | 93 | m3u8_url = url_or_none(video_data.get('videoMasterPlaylist')) |
bffb245a | 94 | if m3u8_url: |
95 | formats.extend(self._extract_m3u8_formats( | |
96 | m3u8_url, video_id, 'mp4', m3u8_id='hls', fatal=False)) | |
97 | for rendition in video_data.get('renditions', []): | |
3052a30d | 98 | video_url = url_or_none(rendition.get('url')) |
bffb245a | 99 | if not video_url: |
100 | continue | |
101 | ext = rendition.get('format') | |
102 | if ext == 'm3u8': | |
103 | formats.extend(self._extract_m3u8_formats( | |
104 | video_url, video_id, 'mp4', m3u8_id='hls', fatal=False)) | |
105 | else: | |
106 | f = { | |
107 | 'url': video_url, | |
108 | 'format_id': rendition.get('quality'), | |
109 | } | |
110 | mobj = re.search(r'(\d+)x(\d+)', video_url) | |
111 | if mobj: | |
112 | f.update({ | |
113 | 'width': int(mobj.group(1)), | |
114 | 'height': int(mobj.group(2)), | |
115 | }) | |
9045d28b | 116 | else: |
4dfbf869 | 117 | qs = parse_qs(video_url) |
9045d28b RA |
118 | f.update({ |
119 | 'width': int_or_none(qs.get('w', [None])[0]), | |
120 | 'height': int_or_none(qs.get('h', [None])[0]), | |
121 | }) | |
bffb245a | 122 | formats.append(f) |
bffb245a | 123 | |
124 | return { | |
125 | 'id': video_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'), | |
132 | 'formats': formats, | |
133 | } |