]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/libsyn.py
testcases for libsyn and The Daily Show Podcast extractors
[yt-dlp.git] / youtube_dl / extractor / libsyn.py
CommitLineData
2e90dff2 1# encoding: utf-8
2from .common import InfoExtractor
3from ..utils import (
4 unified_strdate,
5)
6
7class LibsynIE(InfoExtractor):
8 _VALID_URL = r'(?:https?:)?//html5-player\.libsyn\.com/embed/episode/id/(?P<id>[0-9]+)(?:/.*)?'
9ef4f12b 9 _TESTS = [{
10 'url': "http://html5-player.libsyn.com/embed/episode/id/3377616/",
11 'info_dict': {
12 'id': "3377616",
13 'ext': "mp3",
14 'title': "Episode 12: Bassem Youssef: Egypt's Jon Stewart",
15 'description': "<p>Bassem Youssef joins executive producer Steve Bodow and senior producer Sara Taksler for a conversation about how&nbsp;<em style=\"font-family: Tahoma, Geneva, sans-serif; font-size: 12.8000001907349px;\">The Daily Show</em>&nbsp;inspired Bassem to create&nbsp;<em style=\"font-family: Tahoma, Geneva, sans-serif; font-size: 12.8000001907349px;\">Al-Bernameg</em>, his massively popular (and now banned) Egyptian news satire program. Sara discusses her soon-to-be-released documentary,&nbsp;<em style=\"font-family: Tahoma, Geneva, sans-serif; font-size: 12.8000001907349px;\">Tickling Giants</em>, which chronicles how Bassem and his staff risked their safety every day to tell jokes.</p>",
16 },
17 }]
2e90dff2 18
19 def _real_extract(self, url):
20 if url.startswith('//'):
21 url = 'https:' + url
22 display_id = self._match_id(url)
23 webpage = self._download_webpage(url, display_id)
24
25 podcast_title = self._search_regex(r'<h2>(.*?)</h2>', webpage, 'show title')
26 podcast_episode_title = self._search_regex(r'<h3>(.*?)</h3>', webpage, 'episode title')
27 podcast_date = unified_strdate(self._search_regex(r'<div class="release_date">Released: (.*?)</div>', webpage, 'release date'))
28 podcast_description = self._search_regex(r'<div id="info_text_body">(.*?)</div>', webpage, 'description')
29
30 url0 = self._search_regex(r'var mediaURLLibsyn = "(?P<url0>https?://.*)";', webpage, 'first media URL')
31 url1 = self._search_regex(r'var mediaURL = "(?P<url1>https?://.*)";', webpage, 'second media URL')
32
33 if url0 != url1:
34 formats = [{
35 'url': url0
36 }, {
37 'url': url1
38 }]
39 else:
40 formats = [{
41 'url': url0
42 }]
43
44 return {
45 'id': display_id,
46 'title': podcast_episode_title,
47 'description': podcast_description,
48 'upload_date': podcast_date,
49 'formats': formats,
50 }