[csjw] Fix issues and improve extraction (closes #13525)
parent
d2b9f362fa
commit
c319d1c483
1 changed files with 41 additions and 16 deletions
@ -1,41 +1,66 @@ |
|||||||
# coding: utf-8 |
|
||||||
from __future__ import unicode_literals |
from __future__ import unicode_literals |
||||||
|
|
||||||
|
import re |
||||||
|
|
||||||
from .common import InfoExtractor |
from .common import InfoExtractor |
||||||
|
from ..utils import ( |
||||||
|
determine_ext, |
||||||
|
unescapeHTML, |
||||||
|
) |
||||||
|
|
||||||
|
|
||||||
class CJSWIE(InfoExtractor): |
class CJSWIE(InfoExtractor): |
||||||
_VALID_URL = r'https?://(?:www\.)?cjsw\.com/program/\S+/(?P<id>[0-9]+)' |
_VALID_URL = r'https?://(?:www\.)?cjsw\.com/program/(?P<program>[^/]+)/episode/(?P<id>\d+)' |
||||||
IE_NAME = 'cjsw' |
|
||||||
_TEST = { |
_TEST = { |
||||||
'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': { |
||||||
'id': '20170620', |
'id': '91d9f016-a2e7-46c5-8dcb-7cbcd7437c41', |
||||||
'ext': 'mp3', |
'ext': 'mp3', |
||||||
'title': 'Freshly Squeezed', |
'title': 'Freshly Squeezed – Episode June 20, 2017', |
||||||
'description': 'Sled Island artists featured // Live session with Phi Pho, followed by a live session with Sinzere & The Late Nights! // Stay Fresh Y\'all!!', |
'description': 'md5:c967d63366c3898a80d0c7b0ff337202', |
||||||
} |
'series': 'Freshly Squeezed', |
||||||
|
'episode_id': '20170620', |
||||||
|
}, |
||||||
} |
} |
||||||
|
|
||||||
def _real_extract(self, url): |
def _real_extract(self, url): |
||||||
episode_id = self._match_id(url) |
mobj = re.match(self._VALID_URL, url) |
||||||
|
program, episode_id = mobj.group('program', 'id') |
||||||
|
audio_id = '%s/%s' % (program, episode_id) |
||||||
|
|
||||||
webpage = self._download_webpage(url, episode_id) |
webpage = self._download_webpage(url, episode_id) |
||||||
|
|
||||||
title = self._search_regex( |
title = unescapeHTML(self._search_regex( |
||||||
r'<button[^>]+data-showname=(["\'])(?P<title>(?!\1).+?)\1[^>]*>', webpage, 'title', group='title') |
(r'<h1[^>]+class=["\']episode-header__title["\'][^>]*>(?P<title>[^<]+)', |
||||||
description = self._html_search_regex( |
r'data-audio-title=(["\'])(?P<title>(?:(?!\1).)+)\1'), |
||||||
r'<p>(?P<description>.+?)</p>', webpage, 'description', fatal=False) |
webpage, 'title', group='title')) |
||||||
|
|
||||||
|
audio_url = self._search_regex( |
||||||
|
r'<button[^>]+data-audio-src=(["\'])(?P<url>(?:(?!\1).)+)\1', |
||||||
|
webpage, 'audio url', group='url') |
||||||
|
|
||||||
|
audio_id = self._search_regex( |
||||||
|
r'/([\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})\.mp3', |
||||||
|
audio_url, 'audio id', default=audio_id) |
||||||
|
|
||||||
formats = [{ |
formats = [{ |
||||||
'url': self._search_regex( |
'url': audio_url, |
||||||
r'<button[^>]+data-audio-src=(["\'])(?P<audio_url>(?!\1).+?)\1[^>]*>', webpage, 'audio_url', group='audio_url'), |
'ext': determine_ext(audio_url, 'mp3'), |
||||||
'ext': 'mp3', |
|
||||||
'vcodec': 'none', |
'vcodec': 'none', |
||||||
}] |
}] |
||||||
|
|
||||||
|
description = self._html_search_regex( |
||||||
|
r'<p>(?P<description>.+?)</p>', webpage, 'description', fatal=False) |
||||||
|
series = self._search_regex( |
||||||
|
r'data-showname=(["\'])(?P<name>(?:(?!\1).)+)\1', webpage, |
||||||
|
'series', default=program, group='name') |
||||||
|
|
||||||
return { |
return { |
||||||
'id': episode_id, |
'id': audio_id, |
||||||
'title': title, |
'title': title, |
||||||
'description': description, |
'description': description, |
||||||
'formats': formats, |
'formats': formats, |
||||||
|
'series': series, |
||||||
|
'episode_id': episode_id, |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue