Release 2024.12.06
[yt-dlp3.git] / yt_dlp / extractor / fathom.py
blob1df7d96fe894b6dd34e489314c932ffe2d3e8969
1 import json
3 from .common import InfoExtractor
4 from ..utils import (
5 extract_attributes,
6 float_or_none,
7 get_element_html_by_id,
8 parse_iso8601,
10 from ..utils.traversal import traverse_obj
13 class FathomIE(InfoExtractor):
14 _VALID_URL = r'https?://(?:www\.)?fathom\.video/share/(?P<id>[^/?#&]+)'
15 _TESTS = [{
16 'url': 'https://fathom.video/share/G9mkjkspnohVVZ_L5nrsoPycyWcB8y7s',
17 'md5': '0decd5343b8f30ae268625e79a02b60f',
18 'info_dict': {
19 'id': '47200596',
20 'ext': 'mp4',
21 'title': 'eCom Inucbator - Coaching Session',
22 'duration': 8125.380507,
23 'timestamp': 1699048914,
24 'upload_date': '20231103',
26 }, {
27 'url': 'https://fathom.video/share/mEws3bybftHL2QLymxYEDeE21vtLxGVm',
28 'md5': '4f5cb382126c22d1aba8a939f9c49690',
29 'info_dict': {
30 'id': '46812957',
31 'ext': 'mp4',
32 'title': 'Jon, Lawrence, Neman chat about practice',
33 'duration': 3571.517847,
34 'timestamp': 1698933600,
35 'upload_date': '20231102',
39 def _real_extract(self, url):
40 display_id = self._match_id(url)
41 webpage = self._download_webpage(url, display_id)
42 props = traverse_obj(
43 get_element_html_by_id('app', webpage), ({extract_attributes}, 'data-page', {json.loads}, 'props'))
44 video_id = str(props['call']['id'])
46 return {
47 'id': video_id,
48 'formats': self._extract_m3u8_formats(props['call']['video_url'], video_id, 'mp4'),
49 **traverse_obj(props, {
50 'title': ('head', 'title', {str}),
51 'duration': ('duration', {float_or_none}),
52 'timestamp': ('call', 'started_at', {parse_iso8601}),
53 }),