]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/fathom.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / fathom.py
1 import json
2
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,
9 )
10 from ..utils.traversal import traverse_obj
11
12
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',
25 },
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',
36 },
37 }]
38
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'])
45
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 }),
54 }