]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/aol.py
Prepare for upload.
[youtubedl] / 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 _TESTS = [{
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 'url': 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316',
35 'info_dict': {
36 'id': '152147',
37 'title': 'Brace Yourself - Today\'s Weirdest News',
38 },
39 'playlist_mincount': 10,
40 }]
41
42 def _real_extract(self, url):
43 mobj = re.match(self._VALID_URL, url)
44 video_id = mobj.group('id')
45
46 playlist_id = mobj.group('playlist_id')
47 if playlist_id and not self._downloader.params.get('noplaylist'):
48 self.to_screen('Downloading playlist %s - add --no-playlist to just download video %s' % (playlist_id, video_id))
49
50 webpage = self._download_webpage(url, playlist_id)
51 title = self._html_search_regex(
52 r'<h1 class="video-title[^"]*">(.+?)</h1>', webpage, 'title')
53 playlist_html = self._search_regex(
54 r"(?s)<ul\s+class='video-related[^']*'>(.*?)</ul>", webpage,
55 'playlist HTML')
56 entries = [{
57 '_type': 'url',
58 'url': 'aol-video:%s' % m.group('id'),
59 'ie_key': 'Aol',
60 } for m in re.finditer(
61 r"<a\s+href='.*videoid=(?P<id>[0-9]+)'\s+class='video-thumb'>",
62 playlist_html)]
63
64 return {
65 '_type': 'playlist',
66 'id': playlist_id,
67 'display_id': mobj.group('playlist_display_id'),
68 'title': title,
69 'entries': entries,
70 }
71
72 return FiveMinIE._build_result(video_id)