From 0463b77a1f83f3f9239c6c5f5d1ca251afd267e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Sat, 25 Jun 2016 23:18:40 +0700 Subject: [PATCH] [polskieradio] Improve extraction (Closes #9813) --- youtube_dl/extractor/polskieradio.py | 119 +++++++++++++++------------ 1 file changed, 68 insertions(+), 51 deletions(-) diff --git a/youtube_dl/extractor/polskieradio.py b/youtube_dl/extractor/polskieradio.py index 5d4b116d8..f5adff08f 100644 --- a/youtube_dl/extractor/polskieradio.py +++ b/youtube_dl/extractor/polskieradio.py @@ -1,74 +1,91 @@ # coding: utf-8 from __future__ import unicode_literals -from .common import InfoExtractor -from ..utils import int_or_none +import re -import calendar -from datetime import datetime +from .common import InfoExtractor +from ..compat import ( + compat_str, + compat_urllib_parse_unquote, +) +from ..utils import ( + int_or_none, + strip_or_none, + unified_timestamp, +) class PolskieRadioIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?polskieradio\.pl/[0-9]+/[0-9]+/Artykul/(?P[0-9]+),.+' + _VALID_URL = r'https?://(?:www\.)?polskieradio\.pl/\d+/\d+/Artykul/(?P[0-9]+)' _TESTS = [{ 'url': 'http://www.polskieradio.pl/7/5102/Artykul/1587943,Prof-Andrzej-Nowak-o-historii-nie-da-sie-myslec-beznamietnie', - 'md5': '2984ee6ce9046d91fc233bc1a864a09a', 'info_dict': { 'id': '1587943', - 'ext': 'mp3', 'title': 'Prof. Andrzej Nowak: o historii nie da się myśleć beznamiętnie', 'description': 'md5:12f954edbf3120c5e7075e17bf9fc5c5', - 'release_date': '20160227', - 'upload_date': '20160227', - 'timestamp': 1456594200, - 'duration': 2364 - } + }, + 'playlist': [{ + 'md5': '2984ee6ce9046d91fc233bc1a864a09a', + 'info_dict': { + 'id': '1540576', + 'ext': 'mp3', + 'title': 'md5:d4623290d4ac983bf924061c75c23a0d', + 'timestamp': 1456594200, + 'upload_date': '20160227', + 'duration': 2364, + }, + }], + }, { + 'url': 'http://www.polskieradio.pl/265/5217/Artykul/1635803,Euro-2016-nie-ma-miejsca-na-blad-Polacy-graja-ze-Szwajcaria-o-cwiercfinal', + 'info_dict': { + 'id': '1635803', + 'title': 'Euro 2016: nie ma miejsca na błąd. Polacy grają ze Szwajcarią o ćwierćfinał', + 'description': 'md5:01cb7d0cad58664095d72b51a1ebada2', + }, + 'playlist_mincount': 12, }, { 'url': 'http://polskieradio.pl/9/305/Artykul/1632955,Bardzo-popularne-slowo-remis', - 'md5': '68a393e25b942c1a76872f56d303a31a', - 'info_dict': { - 'id': '1632955', - 'ext': 'mp3', - 'title': 'Bardzo popularne słowo: remis', - 'description': 'md5:3b58dfae614100abc0f175a0b26d5680', - 'release_date': '20160617', - 'upload_date': '20160617', - 'timestamp': 1466184900, - 'duration': 393 - } + 'only_matching': True, + }, { + 'url': 'http://www.polskieradio.pl/7/5102/Artykul/1587943', + 'only_matching': True, }] def _real_extract(self, url): - video_id = self._match_id(url) - webpage = self._download_webpage(url, video_id) - metadata_string = self._html_search_regex(r'', webpage, 'metadata') - metadata = self._parse_json(metadata_string, video_id) + playlist_id = self._match_id(url) - title = self._og_search_title(webpage) - if title is not None: - title = title.strip() + webpage = self._download_webpage(url, playlist_id) - description = self._og_search_description(webpage) - if description is not None: - description = description.strip() + content = self._search_regex( + r'(?s)]+class="audio atarticle"[^>]*>(.+?)