From cad47378c8a71e6e9fcafe61cb60c8ca542af063 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 20 Sep 2018 22:56:01 +0800 Subject: [PATCH] [abc] iView: add support for downloading the latest episode of a show This allows to download using only the show URL instead of having to find out the latest episode URL manually. Test using Aussie Rangers which doesn't have an expiry date and is quite old so it is unlikely to get a new episode, which would cause the test to fail. The show and latest video URLs are: https://iview.abc.net.au/show/aussie-rangers https://iview.abc.net.au/show/aussie-rangers/series/0/video/IP1502W001S00 --- youtube_dl/extractor/abc.py | 35 ++++++++++++++++++++++++++++++ youtube_dl/extractor/extractors.py | 1 + 2 files changed, 36 insertions(+) diff --git a/youtube_dl/extractor/abc.py b/youtube_dl/extractor/abc.py index 4ac323bf6..1f19c9635 100644 --- a/youtube_dl/extractor/abc.py +++ b/youtube_dl/extractor/abc.py @@ -191,3 +191,38 @@ class ABCIViewIE(InfoExtractor): 'subtitles': subtitles, 'is_live': is_live, } + + +class ABCIViewShowLatestEpisodeIE(InfoExtractor): + IE_NAME = 'abc.net.au:iview:show:latest-episode' + _VALID_URL = r'https?://iview\.abc\.net\.au/show/(?P[^/]+)$' + _GEO_COUNTRIES = ['AU'] + + _TESTS = [{ + 'url': 'https://iview.abc.net.au/show/aussie-rangers', + 'md5': 'd0ef57fb44165e5947f04b06ad30205f', + 'info_dict': { + 'id': 'IP1502W001S00', + 'ext': 'mp4', + 'title': 'Episode 1', + 'series': "Aussie Rangers", + 'description': 'md5:b2b899da064bdec43c3a291314ade444', + 'upload_date': '20171204', + 'uploader_id': 'abc2', + 'timestamp': 1512354840, + }, + 'params': { + 'skip_download': True, + }, + }] + + def _real_extract(self, url): + show_id = self._match_id(url) + webpage = self._download_webpage(url, show_id) + webpage_data = self._search_regex( + r'window\.__INITIAL_STATE__\s*=\s*"(.+)"\s*;', + webpage, 'initial state') + json_data = unescapeHTML(webpage_data).encode('utf-8').decode('unicode_escape') + video_data = self._parse_json(json_data, show_id) + url = video_data['page']['pageData']['_embedded']['highlightVideo']['shareUrl'] + return self.url_result(url) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index ddeb70284..a899bf692 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from .abc import ( ABCIE, ABCIViewIE, + ABCIViewShowLatestEpisodeIE, ) from .abcnews import ( AbcNewsIE,