[csjw] Make description optional

This commit is contained in:
Sergey M․ 2017-07-09 17:05:11 +07:00
parent c319d1c483
commit 0d2f0b0357
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -11,7 +11,7 @@
class CJSWIE(InfoExtractor): class CJSWIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?cjsw\.com/program/(?P<program>[^/]+)/episode/(?P<id>\d+)' _VALID_URL = r'https?://(?:www\.)?cjsw\.com/program/(?P<program>[^/]+)/episode/(?P<id>\d+)'
_TEST = { _TESTS = [{
'url': 'http://cjsw.com/program/freshly-squeezed/episode/20170620', 'url': 'http://cjsw.com/program/freshly-squeezed/episode/20170620',
'md5': 'cee14d40f1e9433632c56e3d14977120', 'md5': 'cee14d40f1e9433632c56e3d14977120',
'info_dict': { 'info_dict': {
@ -22,7 +22,11 @@ class CJSWIE(InfoExtractor):
'series': 'Freshly Squeezed', 'series': 'Freshly Squeezed',
'episode_id': '20170620', 'episode_id': '20170620',
}, },
} }, {
# no description
'url': 'http://cjsw.com/program/road-pops/episode/20170707/',
'only_matching': True,
}]
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
@ -51,7 +55,8 @@ def _real_extract(self, url):
}] }]
description = self._html_search_regex( description = self._html_search_regex(
r'<p>(?P<description>.+?)</p>', webpage, 'description', fatal=False) r'<p>(?P<description>.+?)</p>', webpage, 'description',
default=None)
series = self._search_regex( series = self._search_regex(
r'data-showname=(["\'])(?P<name>(?:(?!\1).)+)\1', webpage, r'data-showname=(["\'])(?P<name>(?:(?!\1).)+)\1', webpage,
'series', default=program, group='name') 'series', default=program, group='name')