2015-10-19 03:36:07 +02:00
|
|
|
from __future__ import unicode_literals
|
2015-10-20 19:12:13 +02:00
|
|
|
|
|
|
|
import re
|
|
|
|
|
2015-10-19 03:36:07 +02:00
|
|
|
from .common import InfoExtractor
|
2015-10-20 19:12:13 +02:00
|
|
|
from ..utils import (
|
2021-01-01 13:26:37 +01:00
|
|
|
clean_html,
|
|
|
|
ExtractorError,
|
2015-10-20 19:12:13 +02:00
|
|
|
int_or_none,
|
2021-01-01 13:26:37 +01:00
|
|
|
str_or_none,
|
|
|
|
try_get,
|
2015-10-20 19:12:13 +02:00
|
|
|
)
|
2015-10-19 03:36:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
class StitcherIE(InfoExtractor):
|
2021-01-01 13:26:37 +01:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?stitcher\.com/(?:podcast|show)/(?:[^/]+/)+e(?:pisode)?/(?:(?P<display_id>[^/#?&]+?)-)?(?P<id>\d+)(?:[/#?&]|$)'
|
2015-10-20 19:12:13 +02:00
|
|
|
_TESTS = [{
|
2015-10-19 03:36:07 +02:00
|
|
|
'url': 'http://www.stitcher.com/podcast/the-talking-machines/e/40789481?autoplay=true',
|
2021-01-01 13:26:37 +01:00
|
|
|
'md5': 'e9635098e0da10b21a0e2b85585530f6',
|
2015-10-19 03:36:07 +02:00
|
|
|
'info_dict': {
|
|
|
|
'id': '40789481',
|
|
|
|
'ext': 'mp3',
|
2015-10-20 19:12:13 +02:00
|
|
|
'title': 'Machine Learning Mastery and Cancer Clusters',
|
2021-01-01 13:26:37 +01:00
|
|
|
'description': 'md5:547adb4081864be114ae3831b4c2b42f',
|
2015-10-20 19:12:13 +02:00
|
|
|
'duration': 1604,
|
2017-01-02 13:08:07 +01:00
|
|
|
'thumbnail': r're:^https?://.*\.jpg',
|
2021-01-01 13:26:37 +01:00
|
|
|
'upload_date': '20180126',
|
|
|
|
'timestamp': 1516989316,
|
2015-10-20 19:12:13 +02:00
|
|
|
},
|
|
|
|
}, {
|
|
|
|
'url': 'http://www.stitcher.com/podcast/panoply/vulture-tv/e/the-rare-hourlong-comedy-plus-40846275?autoplay=true',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '40846275',
|
|
|
|
'display_id': 'the-rare-hourlong-comedy-plus',
|
|
|
|
'ext': 'mp3',
|
|
|
|
'title': "The CW's 'Crazy Ex-Girlfriend'",
|
|
|
|
'description': 'md5:04f1e2f98eb3f5cbb094cea0f9e19b17',
|
|
|
|
'duration': 2235,
|
2017-01-02 13:08:07 +01:00
|
|
|
'thumbnail': r're:^https?://.*\.jpg',
|
2015-10-20 19:12:13 +02:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
2021-01-01 13:26:37 +01:00
|
|
|
'skip': 'Page Not Found',
|
2015-10-20 19:12:13 +02:00
|
|
|
}, {
|
|
|
|
# escaped title
|
|
|
|
'url': 'http://www.stitcher.com/podcast/marketplace-on-stitcher/e/40910226?autoplay=true',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'http://www.stitcher.com/podcast/panoply/getting-in/e/episode-2a-how-many-extracurriculars-should-i-have-40876278?autoplay=true',
|
|
|
|
'only_matching': True,
|
2021-01-01 13:26:37 +01:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.stitcher.com/show/threedom/episode/circles-on-a-stick-200212584',
|
|
|
|
'only_matching': True,
|
2015-10-20 19:12:13 +02:00
|
|
|
}]
|
2015-10-19 03:36:07 +02:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-01-01 13:26:37 +01:00
|
|
|
display_id, audio_id = re.match(self._VALID_URL, url).groups()
|
2015-10-19 03:36:07 +02:00
|
|
|
|
2021-01-01 13:26:37 +01:00
|
|
|
resp = self._download_json(
|
|
|
|
'https://api.prod.stitcher.com/episode/' + audio_id,
|
|
|
|
display_id or audio_id)
|
|
|
|
episode = try_get(resp, lambda x: x['data']['episodes'][0], dict)
|
|
|
|
if not episode:
|
|
|
|
raise ExtractorError(resp['errors'][0]['message'], expected=True)
|
2015-10-19 03:36:07 +02:00
|
|
|
|
2021-01-01 13:26:37 +01:00
|
|
|
title = episode['title'].strip()
|
|
|
|
audio_url = episode['audio_url']
|
2015-10-20 19:12:13 +02:00
|
|
|
|
2021-01-01 13:26:37 +01:00
|
|
|
thumbnail = None
|
|
|
|
show_id = episode.get('show_id')
|
|
|
|
if show_id and episode.get('classic_id') != -1:
|
|
|
|
thumbnail = 'https://stitcher-classic.imgix.net/feedimages/%s.jpg' % show_id
|
2015-10-19 03:36:07 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': audio_id,
|
2015-10-20 19:12:13 +02:00
|
|
|
'display_id': display_id,
|
2015-10-19 03:36:07 +02:00
|
|
|
'title': title,
|
2021-01-01 13:26:37 +01:00
|
|
|
'description': clean_html(episode.get('html_description') or episode.get('description')),
|
|
|
|
'duration': int_or_none(episode.get('duration')),
|
2015-10-20 19:12:13 +02:00
|
|
|
'thumbnail': thumbnail,
|
2021-01-01 13:26:37 +01:00
|
|
|
'url': audio_url,
|
|
|
|
'vcodec': 'none',
|
|
|
|
'timestamp': int_or_none(episode.get('date_created')),
|
|
|
|
'season_number': int_or_none(episode.get('season')),
|
|
|
|
'season_id': str_or_none(episode.get('season_id')),
|
2015-10-19 03:36:07 +02:00
|
|
|
}
|