- if url.startswith('//'):
- url = 'https:' + url
- display_id = self._match_id(url)
- webpage = self._download_webpage(url, display_id)
-
- podcast_title = self._search_regex(r'<h2>(.*?)</h2>', webpage, 'show title')
- podcast_episode_title = self._search_regex(r'<h3>(.*?)</h3>', webpage, 'episode title')
- podcast_date = unified_strdate(self._search_regex(r'<div class="release_date">Released: (.*?)</div>', webpage, 'release date'))
- podcast_description = self._search_regex(r'<div id="info_text_body">(.*?)</div>', webpage, 'description')
-
- url0 = self._search_regex(r'var mediaURLLibsyn = "(?P<url0>https?://.*)";', webpage, 'first media URL')
- url1 = self._search_regex(r'var mediaURL = "(?P<url1>https?://.*)";', webpage, 'second media URL')
-
- if url0 != url1:
- formats = [{
- 'url': url0
- }, {
- 'url': url1
- }]
- else:
- formats = [{
- 'url': url0
- }]
+ m = re.match(self._VALID_URL, url)
+ video_id = m.group('id')
+ url = m.group('mainurl')
+ webpage = self._download_webpage(url, video_id)
+
+ podcast_title = self._search_regex(
+ r'<h3>([^<]+)</h3>', webpage, 'podcast title', default=None)
+ if podcast_title:
+ podcast_title = podcast_title.strip()
+ episode_title = self._search_regex(
+ r'(?:<div class="episode-title">|<h4>)([^<]+)</', webpage, 'episode title')
+ if episode_title:
+ episode_title = episode_title.strip()
+
+ title = '%s - %s' % (podcast_title, episode_title) if podcast_title else episode_title
+
+ description = self._html_search_regex(
+ r'<p\s+id="info_text_body">(.+?)</p>', webpage,
+ 'description', default=None)
+ if description:
+ # Strip non-breaking and normal spaces
+ description = description.replace('\u00A0', ' ').strip()
+ release_date = unified_strdate(self._search_regex(
+ r'<div class="release_date">Released: ([^<]+)<', webpage, 'release date', fatal=False))
+
+ data_json = self._search_regex(r'var\s+playlistItem\s*=\s*(\{.*?\});\n', webpage, 'JSON data block')
+ data = json.loads(data_json)
+
+ formats = [{
+ 'url': data['media_url'],
+ 'format_id': 'main',
+ }, {
+ 'url': data['media_url_libsyn'],
+ 'format_id': 'libsyn',
+ }]
+ thumbnail = data.get('thumbnail_url')
+ duration = parse_duration(data.get('duration'))