From f449c061d04b37f70dafa8c01a2e1fb7a47a9a5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Wed, 2 Nov 2016 01:35:53 +0700 Subject: [PATCH] [nicknight] Improve extraction (closes #10769) --- youtube_dl/extractor/extractors.py | 2 +- youtube_dl/extractor/nick.py | 28 +++++++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 913ffe29a..f30ac5aaf 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -596,7 +596,7 @@ from .nhl import ( from .nick import ( NickIE, NickDeIE, - NickNightAtIE, + NickNightIE, ) from .niconico import NiconicoIE, NiconicoPlaylistIE from .ninecninemedia import ( diff --git a/youtube_dl/extractor/nick.py b/youtube_dl/extractor/nick.py index 36364bee9..7672845bf 100644 --- a/youtube_dl/extractor/nick.py +++ b/youtube_dl/extractor/nick.py @@ -86,6 +86,11 @@ class NickDeIE(MTVServicesInfoExtractor): 'only_matching': True, }] + def _extract_mrss_url(self, webpage, host): + return update_url_query(self._search_regex( + r'data-mrss=(["\'])(?Phttp.+?)\1', webpage, 'mrss url', group='url'), + {'siteKey': host}) + def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') @@ -93,16 +98,14 @@ class NickDeIE(MTVServicesInfoExtractor): webpage = self._download_webpage(url, video_id) - mrss_url = update_url_query(self._search_regex( - r'data-mrss=(["\'])(?Phttp.+?)\1', webpage, 'mrss url', group='url'), - {'siteKey': host}) + mrss_url = self._extract_mrss_url(webpage, host) return self._get_videos_info_from_url(mrss_url, video_id) -class NickNightAtIE(MTVServicesInfoExtractor): - IE_NAME = 'nicknight.de' - _VALID_URL = r'https?://(?:www\.)nicknight\.(?:de|at|tv)/(?:playlist|shows)/(?:[^/]+/)*(?P[^/?#&]+)' +class NickNightIE(NickDeIE): + IE_NAME = 'nicknight' + _VALID_URL = r'https?://(?:www\.)(?Pnicknight\.(?:de|at|tv))/(?:playlist|shows)/(?:[^/]+/)*(?P[^/?#&]+)' _TESTS = [{ 'url': 'http://www.nicknight.at/shows/977-awkward/videos/85987-nimmer-beste-freunde', 'only_matching': True, @@ -114,12 +117,7 @@ class NickNightAtIE(MTVServicesInfoExtractor): 'only_matching': True, }] - def _real_extract(self, url): - video_id = self._match_id(url) - - webpage = self._download_webpage(url, video_id) - - mrss_url = self._search_regex( - r'mrss: (["\'])(?Phttp.+?)\1', webpage, 'mrss url', group='url') - - return self._get_videos_info_from_url(mrss_url, video_id) + def _extract_mrss_url(self, webpage, *args): + return self._search_regex( + r'mrss\s*:\s*(["\'])(?Phttp.+?)\1', webpage, + 'mrss url', group='url')