]>
Commit | Line | Data |
---|---|---|
64ce58db JMF |
1 | from __future__ import unicode_literals |
2 | ||
3 | import re | |
64ce58db JMF |
4 | |
5 | from .common import InfoExtractor | |
17a64763 YCH |
6 | from ..utils import ( |
7 | ExtractorError, | |
8 | js_to_json, | |
c0a65687 | 9 | int_or_none, |
17a64763 | 10 | ) |
64ce58db JMF |
11 | |
12 | ||
13 | class ABCIE(InfoExtractor): | |
14 | IE_NAME = 'abc.net.au' | |
5886b38d | 15 | _VALID_URL = r'https?://www\.abc\.net\.au/news/(?:[^/]+/){1,2}(?P<id>\d+)' |
64ce58db | 16 | |
17a64763 | 17 | _TESTS = [{ |
732c848c MK |
18 | 'url': 'http://www.abc.net.au/news/2014-11-05/australia-to-staff-ebola-treatment-centre-in-sierra-leone/5868334', |
19 | 'md5': 'cb3dd03b18455a661071ee1e28344d9f', | |
64ce58db | 20 | 'info_dict': { |
732c848c | 21 | 'id': '5868334', |
64ce58db | 22 | 'ext': 'mp4', |
732c848c MK |
23 | 'title': 'Australia to help staff Ebola treatment centre in Sierra Leone', |
24 | 'description': 'md5:809ad29c67a05f54eb41f2a105693a67', | |
64ce58db | 25 | }, |
5c5a3ecf | 26 | 'skip': 'this video has expired', |
17a64763 YCH |
27 | }, { |
28 | 'url': 'http://www.abc.net.au/news/2015-08-17/warren-entsch-introduces-same-sex-marriage-bill/6702326', | |
29 | 'md5': 'db2a5369238b51f9811ad815b69dc086', | |
30 | 'info_dict': { | |
31 | 'id': 'NvqvPeNZsHU', | |
32 | 'ext': 'mp4', | |
33 | 'upload_date': '20150816', | |
34 | 'uploader': 'ABC News (Australia)', | |
35 | 'description': 'Government backbencher Warren Entsch introduces a cross-party sponsored bill to legalise same-sex marriage, saying the bill is designed to promote "an inclusive Australia, not a divided one.". Read more here: http://ab.co/1Mwc6ef', | |
36 | 'uploader_id': 'NewsOnABC', | |
37 | 'title': 'Marriage Equality: Warren Entsch introduces same sex marriage bill', | |
38 | }, | |
39 | 'add_ie': ['Youtube'], | |
5c5a3ecf | 40 | 'skip': 'Not accessible from Travis CI server', |
7687b354 | 41 | }, { |
42 | 'url': 'http://www.abc.net.au/news/2015-10-23/nab-lifts-interest-rates-following-westpac-and-cba/6880080', | |
43 | 'md5': 'b96eee7c9edf4fc5a358a0252881cc1f', | |
44 | 'info_dict': { | |
45 | 'id': '6880080', | |
46 | 'ext': 'mp3', | |
47 | 'title': 'NAB lifts interest rates, following Westpac and CBA', | |
48 | 'description': 'md5:f13d8edc81e462fce4a0437c7dc04728', | |
49 | }, | |
d97da29d JMF |
50 | }, { |
51 | 'url': 'http://www.abc.net.au/news/2015-10-19/6866214', | |
52 | 'only_matching': True, | |
17a64763 | 53 | }] |
64ce58db JMF |
54 | |
55 | def _real_extract(self, url): | |
ed9266db | 56 | video_id = self._match_id(url) |
64ce58db JMF |
57 | webpage = self._download_webpage(url, video_id) |
58 | ||
17a64763 | 59 | mobj = re.search( |
7687b354 | 60 | r'inline(?P<type>Video|Audio|YouTube)Data\.push\((?P<json_data>[^)]+)\);', |
17a64763 YCH |
61 | webpage) |
62 | if mobj is None: | |
5c5a3ecf | 63 | expired = self._html_search_regex(r'(?s)class="expired-(?:video|audio)".+?<span>(.+?)</span>', webpage, 'expired', None) |
64 | if expired: | |
65 | raise ExtractorError('%s said: %s' % (self.IE_NAME, expired), expected=True) | |
17a64763 YCH |
66 | raise ExtractorError('Unable to extract video urls') |
67 | ||
68 | urls_info = self._parse_json( | |
69 | mobj.group('json_data'), video_id, transform_source=js_to_json) | |
70 | ||
71 | if not isinstance(urls_info, list): | |
72 | urls_info = [urls_info] | |
73 | ||
74 | if mobj.group('type') == 'YouTube': | |
75 | return self.playlist_result([ | |
76 | self.url_result(url_info['url']) for url_info in urls_info]) | |
77 | ||
64ce58db JMF |
78 | formats = [{ |
79 | 'url': url_info['url'], | |
7687b354 | 80 | 'vcodec': url_info.get('codec') if mobj.group('type') == 'Video' else 'none', |
c0a65687 YCH |
81 | 'width': int_or_none(url_info.get('width')), |
82 | 'height': int_or_none(url_info.get('height')), | |
83 | 'tbr': int_or_none(url_info.get('bitrate')), | |
84 | 'filesize': int_or_none(url_info.get('filesize')), | |
64ce58db | 85 | } for url_info in urls_info] |
7687b354 | 86 | |
64ce58db JMF |
87 | self._sort_formats(formats) |
88 | ||
89 | return { | |
90 | 'id': video_id, | |
91 | 'title': self._og_search_title(webpage), | |
92 | 'formats': formats, | |
93 | 'description': self._og_search_description(webpage), | |
94 | 'thumbnail': self._og_search_thumbnail(webpage), | |
95 | } |