1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from ..compat import compat_str
16 class ABCIE(InfoExtractor):
17 IE_NAME = 'abc.net.au'
18 _VALID_URL = r'https?://(?:www\.)?abc\.net\.au/news/(?:[^/]+/){1,2}(?P<id>\d+)'
21 'url': 'http://www.abc.net.au/news/2014-11-05/australia-to-staff-ebola-treatment-centre-in-sierra-leone/5868334',
22 'md5': 'cb3dd03b18455a661071ee1e28344d9f',
26 'title': 'Australia to help staff Ebola treatment centre in Sierra Leone',
27 'description': 'md5:809ad29c67a05f54eb41f2a105693a67',
29 'skip': 'this video has expired',
31 'url': 'http://www.abc.net.au/news/2015-08-17/warren-entsch-introduces-same-sex-marriage-bill/6702326',
32 'md5': 'db2a5369238b51f9811ad815b69dc086',
36 'upload_date': '20150816',
37 'uploader': 'ABC News (Australia)',
38 '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',
39 'uploader_id': 'NewsOnABC',
40 'title': 'Marriage Equality: Warren Entsch introduces same sex marriage bill',
42 'add_ie': ['Youtube'],
43 'skip': 'Not accessible from Travis CI server',
45 'url': 'http://www.abc.net.au/news/2015-10-23/nab-lifts-interest-rates-following-westpac-and-cba/6880080',
46 'md5': 'b96eee7c9edf4fc5a358a0252881cc1f',
50 'title': 'NAB lifts interest rates, following Westpac and CBA',
51 'description': 'md5:f13d8edc81e462fce4a0437c7dc04728',
54 'url': 'http://www.abc.net.au/news/2015-10-19/6866214',
55 'only_matching': True,
58 def _real_extract(self, url):
59 video_id = self._match_id(url)
60 webpage = self._download_webpage(url, video_id)
63 r'inline(?P<type>Video|Audio|YouTube)Data\.push\((?P<json_data>[^)]+)\);',
66 expired = self._html_search_regex(r'(?s)class="expired-(?:video|audio)".+?<span>(.+?)</span>', webpage, 'expired', None)
68 raise ExtractorError('%s said: %s' % (self.IE_NAME, expired), expected=True)
69 raise ExtractorError('Unable to extract video urls')
71 urls_info = self._parse_json(
72 mobj.group('json_data'), video_id, transform_source=js_to_json)
74 if not isinstance(urls_info, list):
75 urls_info = [urls_info]
77 if mobj.group('type') == 'YouTube':
78 return self.playlist_result([
79 self.url_result(url_info['url']) for url_info in urls_info])
82 'url': url_info['url'],
83 'vcodec': url_info.get('codec') if mobj.group('type') == 'Video' else 'none',
84 'width': int_or_none(url_info.get('width')),
85 'height': int_or_none(url_info.get('height')),
86 'tbr': int_or_none(url_info.get('bitrate')),
87 'filesize': int_or_none(url_info.get('filesize')),
88 } for url_info in urls_info]
90 self._sort_formats(formats)
94 'title': self._og_search_title(webpage),
96 'description': self._og_search_description(webpage),
97 'thumbnail': self._og_search_thumbnail(webpage),
101 class ABCIViewIE(InfoExtractor):
102 IE_NAME = 'abc.net.au:iview'
103 _VALID_URL = r'https?://iview\.abc\.net\.au/programs/[^/]+/(?P<id>[^/?#]+)'
105 # ABC iview programs are normally available for 14 days only.
107 'url': 'http://iview.abc.net.au/programs/diaries-of-a-broken-mind/ZX9735A001S00',
108 'md5': 'cde42d728b3b7c2b32b1b94b4a548afc',
110 'id': 'ZX9735A001S00',
112 'title': 'Diaries Of A Broken Mind',
113 'description': 'md5:7de3903874b7a1be279fe6b68718fc9e',
114 'upload_date': '20161010',
115 'uploader_id': 'abc2',
116 'timestamp': 1476064920,
118 'skip': 'Video gone',
121 def _real_extract(self, url):
122 video_id = self._match_id(url)
123 webpage = self._download_webpage(url, video_id)
124 video_params = self._parse_json(self._search_regex(
125 r'videoParams\s*=\s*({.+?});', webpage, 'video params'), video_id)
126 title = video_params.get('title') or video_params['seriesTitle']
127 stream = next(s for s in video_params['playlist'] if s.get('type') == 'program')
130 try_get(stream, lambda x: x['hds-unmetered'], compat_str)]
132 # May have higher quality video
134 stream, lambda x: x['streams']['hds']['sd'], compat_str)
136 format_urls.append(sd_url.replace('metered', 'um'))
139 for format_url in format_urls:
142 self._extract_akamai_formats(format_url, video_id))
143 self._sort_formats(formats)
146 src_vtt = stream.get('captions', {}).get('src-vtt')
156 'description': self._html_search_meta(['og:description', 'twitter:description'], webpage),
157 'thumbnail': self._html_search_meta(['og:image', 'twitter:image:src'], webpage),
158 'duration': int_or_none(video_params.get('eventDuration')),
159 'timestamp': parse_iso8601(video_params.get('pubDate'), ' '),
160 'series': video_params.get('seriesTitle'),
161 'series_id': video_params.get('seriesHouseNumber') or video_id[:7],
162 'episode_number': int_or_none(self._html_search_meta('episodeNumber', webpage, default=None)),
163 'episode': self._html_search_meta('episode_title', webpage, default=None),
164 'uploader_id': video_params.get('channel'),
166 'subtitles': subtitles,