]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/aol.py
Merge branch 'ustream-embed-recorded2' of https://github.com/anovicecodemonkey/youtub...
[youtube-dl] / youtube_dl / extractor / aol.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from .fivemin import FiveMinIE
7
8
9 class AolIE(InfoExtractor):
10     IE_NAME = 'on.aol.com'
11     _VALID_URL = r'''(?x)
12         (?:
13             aol-video:|
14             http://on\.aol\.com/
15             (?:
16                 video/.*-|
17                 playlist/(?P<playlist_display_id>[^/?#]+?)-(?P<playlist_id>[0-9]+)[?#].*_videoid=
18             )
19         )
20         (?P<id>[0-9]+)
21         (?:$|\?)
22     '''
23
24     _TEST = {
25         'url': 'http://on.aol.com/video/u-s--official-warns-of-largest-ever-irs-phone-scam-518167793?icid=OnHomepageC2Wide_MustSee_Img',
26         'md5': '18ef68f48740e86ae94b98da815eec42',
27         'info_dict': {
28             'id': '518167793',
29             'ext': 'mp4',
30             'title': 'U.S. Official Warns Of \'Largest Ever\' IRS Phone Scam',
31         },
32         'add_ie': ['FiveMin'],
33     }
34
35     def _real_extract(self, url):
36         mobj = re.match(self._VALID_URL, url)
37         video_id = mobj.group('id')
38
39         playlist_id = mobj.group('playlist_id')
40         if playlist_id and not self._downloader.params.get('noplaylist'):
41             self.to_screen('Downloading playlist %s - add --no-playlist to just download video %s' % (playlist_id, video_id))
42
43             webpage = self._download_webpage(url, playlist_id)
44             title = self._html_search_regex(
45                 r'<h1 class="video-title[^"]*">(.+?)</h1>', webpage, 'title')
46             playlist_html = self._search_regex(
47                 r"(?s)<ul\s+class='video-related[^']*'>(.*?)</ul>", webpage,
48                 'playlist HTML')
49             entries = [{
50                 '_type': 'url',
51                 'url': 'aol-video:%s' % m.group('id'),
52                 'ie_key': 'Aol',
53             } for m in re.finditer(
54                 r"<a\s+href='.*videoid=(?P<id>[0-9]+)'\s+class='video-thumb'>",
55                 playlist_html)]
56
57             return {
58                 '_type': 'playlist',
59                 'id': playlist_id,
60                 'display_id': mobj.group('playlist_display_id'),
61                 'title': title,
62                 'entries': entries,
63             }
64
65         return FiveMinIE._build_result(video_id)