]>
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' | |
15 | _VALID_URL = r'http://www\.abc\.net\.au/news/[^/]+/[^/]+/(?P<id>\d+)' | |
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 | }, |
17a64763 YCH |
26 | }, { |
27 | 'url': 'http://www.abc.net.au/news/2015-08-17/warren-entsch-introduces-same-sex-marriage-bill/6702326', | |
28 | 'md5': 'db2a5369238b51f9811ad815b69dc086', | |
29 | 'info_dict': { | |
30 | 'id': 'NvqvPeNZsHU', | |
31 | 'ext': 'mp4', | |
32 | 'upload_date': '20150816', | |
33 | 'uploader': 'ABC News (Australia)', | |
34 | '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', | |
35 | 'uploader_id': 'NewsOnABC', | |
36 | 'title': 'Marriage Equality: Warren Entsch introduces same sex marriage bill', | |
37 | }, | |
38 | 'add_ie': ['Youtube'], | |
39 | }] | |
64ce58db JMF |
40 | |
41 | def _real_extract(self, url): | |
ed9266db | 42 | video_id = self._match_id(url) |
64ce58db JMF |
43 | webpage = self._download_webpage(url, video_id) |
44 | ||
17a64763 YCH |
45 | mobj = re.search( |
46 | r'inline(?P<type>Video|YouTube)Data\.push\((?P<json_data>[^)]+)\);', | |
47 | webpage) | |
48 | if mobj is None: | |
49 | raise ExtractorError('Unable to extract video urls') | |
50 | ||
51 | urls_info = self._parse_json( | |
52 | mobj.group('json_data'), video_id, transform_source=js_to_json) | |
53 | ||
54 | if not isinstance(urls_info, list): | |
55 | urls_info = [urls_info] | |
56 | ||
57 | if mobj.group('type') == 'YouTube': | |
58 | return self.playlist_result([ | |
59 | self.url_result(url_info['url']) for url_info in urls_info]) | |
60 | ||
64ce58db JMF |
61 | formats = [{ |
62 | 'url': url_info['url'], | |
c0a65687 YCH |
63 | 'width': int_or_none(url_info.get('width')), |
64 | 'height': int_or_none(url_info.get('height')), | |
65 | 'tbr': int_or_none(url_info.get('bitrate')), | |
66 | 'filesize': int_or_none(url_info.get('filesize')), | |
64ce58db JMF |
67 | } for url_info in urls_info] |
68 | self._sort_formats(formats) | |
69 | ||
70 | return { | |
71 | 'id': video_id, | |
72 | 'title': self._og_search_title(webpage), | |
73 | 'formats': formats, | |
74 | 'description': self._og_search_description(webpage), | |
75 | 'thumbnail': self._og_search_thumbnail(webpage), | |
76 | } |