]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/cinchcast.py
[extractors] Use new framework for existing embeds (#4307)
[yt-dlp.git] / yt_dlp / extractor / cinchcast.py
CommitLineData
42bdd9d0
PH
1from .common import InfoExtractor
2from ..utils import (
42bdd9d0
PH
3 unified_strdate,
4 xpath_text,
5)
6
7
8class CinchcastIE(InfoExtractor):
c983cc3b 9 _VALID_URL = r'https?://player\.cinchcast\.com/.*?(?:assetId|show_id)=(?P<id>[0-9]+)'
bfd973ec 10 _EMBED_REGEX = [r'<iframe[^>]+?src=(["\'])(?P<url>https?://player\.cinchcast\.com/.+?)\1']
11
c983cc3b
S
12 _TESTS = [{
13 'url': 'http://player.cinchcast.com/?show_id=5258197&platformId=1&assetType=single',
14 'info_dict': {
15 'id': '5258197',
16 'ext': 'mp3',
17 'title': 'Train Your Brain to Up Your Game with Coach Mandy',
18 'upload_date': '20130816',
19 },
20 }, {
42bdd9d0
PH
21 # Actual test is run in generic, look for undergroundwellness
22 'url': 'http://player.cinchcast.com/?platformId=1&#038;assetType=single&#038;assetId=7141703',
23 'only_matching': True,
c983cc3b 24 }]
42bdd9d0
PH
25
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28 doc = self._download_xml(
29 'http://www.blogtalkradio.com/playerasset/mrss?assetType=single&assetId=%s' % video_id,
30 video_id)
31
32 item = doc.find('.//item')
33 title = xpath_text(item, './title', fatal=True)
34 date_str = xpath_text(
35 item, './{http://developer.longtailvideo.com/trac/}date')
36 upload_date = unified_strdate(date_str, day_first=False)
37 # duration is present but wrong
a52c6335
PH
38 formats = [{
39 'format_id': 'main',
40 'url': item.find('./{http://search.yahoo.com/mrss/}content').attrib['url'],
41 }]
42bdd9d0
PH
42 backup_url = xpath_text(
43 item, './{http://developer.longtailvideo.com/trac/}backupContent')
44 if backup_url:
45 formats.append({
46 'preference': 2, # seems to be more reliable
47 'format_id': 'backup',
48 'url': backup_url,
49 })
50 self._sort_formats(formats)
51
52 return {
53 'id': video_id,
54 'title': title,
55 'upload_date': upload_date,
56 'formats': formats,
57 }