]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/callin.py
1 from .common
import InfoExtractor
9 class CallinIE(InfoExtractor
):
10 _VALID_URL
= r
'https?://(?:www\.)?callin\.com/(episode)/(?P<id>[-a-zA-Z]+)'
12 'url': 'https://www.callin.com/episode/the-title-ix-regime-and-the-long-march-through-EBfXYSrsjc',
14 'id': '218b979630a35ead12c6fd096f2996c56c37e4d0dc1f6dc0feada32dcf7b31cd',
15 'title': 'The Title IX Regime and the Long March Through and Beyond the Institutions',
17 'display_id': 'the-title-ix-regime-and-the-long-march-through-EBfXYSrsjc',
18 'thumbnail': 're:https://.+\\.png',
19 'description': 'First episode',
20 'uploader': 'Wesley Yang',
21 'timestamp': 1639404128.65,
22 'upload_date': '20211213',
23 'uploader_id': 'wesyang',
24 'uploader_url': 'http://wesleyyang.substack.com',
25 'channel': 'Conversations in Year Zero',
26 'channel_id': '436d1f82ddeb30cd2306ea9156044d8d2cfdc3f1f1552d245117a42173e78553',
27 'channel_url': 'https://callin.com/show/conversations-in-year-zero-oJNllRFSfx',
30 'categories': ['News & Politics', 'History', 'Technology'],
31 'cast': ['Wesley Yang', 'KC Johnson', 'Gabi Abramovich'],
32 'series': 'Conversations in Year Zero',
33 'series_id': '436d1f82ddeb30cd2306ea9156044d8d2cfdc3f1f1552d245117a42173e78553',
34 'episode': 'The Title IX Regime and the Long March Through and Beyond the Institutions',
36 'episode_id': '218b979630a35ead12c6fd096f2996c56c37e4d0dc1f6dc0feada32dcf7b31cd'
40 def try_get_user_name(self
, d
):
41 names
= [d
.get(n
) for n
in ('first', 'last')]
43 return next((n
for n
in names
if n
), default
=None)
44 return ' '.join(names
)
46 def _real_extract(self
, url
):
47 display_id
= self
._match
_id
(url
)
48 webpage
= self
._download
_webpage
(url
, display_id
)
50 next_data
= self
._search
_nextjs
_data
(webpage
, display_id
)
51 episode
= next_data
['props']['pageProps']['episode']
54 title
= (episode
.get('title')
55 or self
._og
_search
_title
(webpage
, fatal
=False)
56 or self
._html
_extract
_title
(webpage
))
58 formats
= self
._extract
_m
3u8_formats
(url
, display_id
, ext
='ts')
59 self
._sort
_formats
(formats
)
61 show
= traverse_obj(episode
, ('show', 'title'))
62 show_id
= traverse_obj(episode
, ('show', 'id'))
65 app_slug
= (self
._html
_search
_regex
(
66 '<script\\s+src=["\']/_next/static/([-_a-zA-Z0-9]+)/_',
67 webpage
, 'app slug', fatal
=False) or next_data
.get('buildId'))
68 show_slug
= traverse_obj(episode
, ('show', 'linkObj', 'resourceUrl'))
69 if app_slug
and show_slug
and '/' in show_slug
:
70 show_slug
= show_slug
.rsplit('/', 1)[1]
71 show_json_url
= f
'https://www.callin.com/_next/data/{app_slug}/show/{show_slug}.json'
72 show_json
= self
._download
_json
(show_json_url
, display_id
, fatal
=False)
74 host
= (traverse_obj(show_json
, ('pageProps', 'show', 'hosts', 0))
75 or traverse_obj(episode
, ('speakers', 0)))
77 host_nick
= traverse_obj(host
, ('linkObj', 'resourceUrl'))
78 host_nick
= host_nick
.rsplit('/', 1)[1] if (host_nick
and '/' in host_nick
) else None
80 cast
= list(filter(None, [
81 self
.try_get_user_name(u
) for u
in
82 traverse_obj(episode
, (('speakers', 'callerTags'), ...)) or []
85 episode_list
= traverse_obj(show_json
, ('pageProps', 'show', 'episodes')) or []
86 episode_number
= next(
87 (len(episode_list
) - i
for (i
, e
) in enumerate(episode_list
) if e
.get('id') == id),
92 'display_id': display_id
,
95 'thumbnail': traverse_obj(episode
, ('show', 'photo')),
96 'description': episode
.get('description'),
97 'uploader': self
.try_get_user_name(host
) if host
else None,
98 'timestamp': episode
.get('publishedAt'),
99 'uploader_id': host_nick
,
100 'uploader_url': traverse_obj(show_json
, ('pageProps', 'show', 'url')),
102 'channel_id': show_id
,
103 'channel_url': traverse_obj(episode
, ('show', 'linkObj', 'resourceUrl')),
104 'duration': float_or_none(episode
.get('runtime')),
105 'view_count': int_or_none(episode
.get('plays')),
106 'categories': traverse_obj(episode
, ('show', 'categorizations', ..., 'name')),
107 'cast': cast
if cast
else None,
109 'series_id': show_id
,
111 'episode_number': episode_number
,