1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 02:14:32 +01:00

[Stitcher] - Reorganized call to json data accessing of {config} and {feed} to support return of show_title and publication_date in response to ticket #20510

This commit is contained in:
zanechen 2019-04-24 20:51:07 -04:00
parent 85b6335d55
commit e5e6e82aae

View File

@ -14,6 +14,19 @@ from ..utils import (
class StitcherIE(InfoExtractor): class StitcherIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?stitcher\.com/podcast/(?:[^/]+/)+e/(?:(?P<display_id>[^/#?&]+?)-)?(?P<id>\d+)(?:[/#?&]|$)' _VALID_URL = r'https?://(?:www\.)?stitcher\.com/podcast/(?:[^/]+/)+e/(?:(?P<display_id>[^/#?&]+?)-)?(?P<id>\d+)(?:[/#?&]|$)'
_TESTS = [{ _TESTS = [{
'url': 'http://www.stitcher.com/podcast/the-talking-machines/e/40789481?autoplay=true',
'md5': '730312cac3a909c9732747b66962eb74',
'info_dict': {
'id': '40789481',
'ext': 'mp3',
'title': 'Machine Learning Mastery and Cancer Clusters',
'show_name': 'Talking Machines',
'description': 'md5:50da9e5ec6d37867069c480edbcf8b94',
'publication_date': 'Oct 8, 2015',
'duration': 1604,
'thumbnail': r're:^https?://.*\.jpg',
},
}, {
'url': 'http://www.stitcher.com/podcast/the-talking-machines/e/40789481?autoplay=true', 'url': 'http://www.stitcher.com/podcast/the-talking-machines/e/40789481?autoplay=true',
'md5': '391dd4e021e6edeb7b8e68fbf2e9e940', 'md5': '391dd4e021e6edeb7b8e68fbf2e9e940',
'info_dict': { 'info_dict': {
@ -54,10 +67,16 @@ class StitcherIE(InfoExtractor):
webpage = self._download_webpage(url, display_id) webpage = self._download_webpage(url, display_id)
episode = self._parse_json( # Safe grab 'config' json data using get()
js_to_json(self._search_regex( config = self._parse_json(
r'(?s)var\s+stitcher(?:Config)?\s*=\s*({.+?});\n', webpage, 'episode config')), js_to_json(self._search_regex(r'(?s)var\s+stitcher(?:Config)?\s*=\s*({.+?});\n', webpage, 'episode config')),
display_id)['config']['episode'] display_id).get('config')
# Safe grab 'episode' json data using get()
episode = config.get('episode')
# Safe grab 'episode' json data using get()
feed = config.get('feed')
title = unescapeHTML(episode['title']) title = unescapeHTML(episode['title'])
formats = [{ formats = [{
@ -69,12 +88,16 @@ class StitcherIE(InfoExtractor):
r'Episode Info:\s*</span>([^<]+)<', webpage, 'description', fatal=False) r'Episode Info:\s*</span>([^<]+)<', webpage, 'description', fatal=False)
duration = int_or_none(episode.get('duration')) duration = int_or_none(episode.get('duration'))
thumbnail = episode.get('episodeImage') thumbnail = episode.get('episodeImage')
pub_date = episode.get('pubDate')
show_name = feed.get('name')
return { return {
'id': audio_id, 'id': audio_id,
'display_id': display_id, 'display_id': display_id,
'title': title, 'title': title,
'show_name': show_name,
'description': description, 'description': description,
'publication_date': pub_date,
'duration': duration, 'duration': duration,
'thumbnail': thumbnail, 'thumbnail': thumbnail,
'formats': formats, 'formats': formats,