mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.9 KiB
Python
82 lines
2.9 KiB
Python
9 years ago
|
from __future__ import unicode_literals
|
||
9 years ago
|
|
||
|
import re
|
||
|
|
||
9 years ago
|
from .common import InfoExtractor
|
||
9 years ago
|
from ..utils import (
|
||
|
determine_ext,
|
||
|
int_or_none,
|
||
|
js_to_json,
|
||
|
unescapeHTML,
|
||
|
)
|
||
9 years ago
|
|
||
|
|
||
|
class StitcherIE(InfoExtractor):
|
||
9 years ago
|
_VALID_URL = r'https?://(?:www\.)?stitcher\.com/podcast/(?:[^/]+/)+e/(?:(?P<display_id>[^/#?&]+?)-)?(?P<id>\d+)(?:[/#?&]|$)'
|
||
|
_TESTS = [{
|
||
9 years ago
|
'url': 'http://www.stitcher.com/podcast/the-talking-machines/e/40789481?autoplay=true',
|
||
|
'md5': '391dd4e021e6edeb7b8e68fbf2e9e940',
|
||
|
'info_dict': {
|
||
|
'id': '40789481',
|
||
|
'ext': 'mp3',
|
||
9 years ago
|
'title': 'Machine Learning Mastery and Cancer Clusters',
|
||
|
'description': 'md5:55163197a44e915a14a1ac3a1de0f2d3',
|
||
|
'duration': 1604,
|
||
8 years ago
|
'thumbnail': r're:^https?://.*\.jpg',
|
||
9 years ago
|
},
|
||
|
}, {
|
||
|
'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,
|
||
8 years ago
|
'thumbnail': r're:^https?://.*\.jpg',
|
||
9 years ago
|
},
|
||
|
'params': {
|
||
|
'skip_download': True,
|
||
|
},
|
||
|
}, {
|
||
|
# 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,
|
||
|
}]
|
||
9 years ago
|
|
||
|
def _real_extract(self, url):
|
||
9 years ago
|
mobj = re.match(self._VALID_URL, url)
|
||
|
audio_id = mobj.group('id')
|
||
|
display_id = mobj.group('display_id') or audio_id
|
||
9 years ago
|
|
||
9 years ago
|
webpage = self._download_webpage(url, display_id)
|
||
9 years ago
|
|
||
9 years ago
|
episode = self._parse_json(
|
||
|
js_to_json(self._search_regex(
|
||
9 years ago
|
r'(?s)var\s+stitcher(?:Config)?\s*=\s*({.+?});\n', webpage, 'episode config')),
|
||
9 years ago
|
display_id)['config']['episode']
|
||
|
|
||
|
title = unescapeHTML(episode['title'])
|
||
|
formats = [{
|
||
|
'url': episode[episode_key],
|
||
|
'ext': determine_ext(episode[episode_key]) or 'mp3',
|
||
|
'vcodec': 'none',
|
||
9 years ago
|
} for episode_key in ('episodeURL',) if episode.get(episode_key)]
|
||
9 years ago
|
description = self._search_regex(
|
||
|
r'Episode Info:\s*</span>([^<]+)<', webpage, 'description', fatal=False)
|
||
|
duration = int_or_none(episode.get('duration'))
|
||
|
thumbnail = episode.get('episodeImage')
|
||
9 years ago
|
|
||
|
return {
|
||
|
'id': audio_id,
|
||
9 years ago
|
'display_id': display_id,
|
||
9 years ago
|
'title': title,
|
||
9 years ago
|
'description': description,
|
||
9 years ago
|
'duration': duration,
|
||
9 years ago
|
'thumbnail': thumbnail,
|
||
|
'formats': formats,
|
||
9 years ago
|
}
|