]>
Commit | Line | Data |
---|---|---|
be7db1a5 | 1 | from .common import InfoExtractor |
2 | from ..utils import parse_iso8601, url_or_none | |
3 | from ..utils.traversal import traverse_obj | |
4 | ||
5 | ||
6 | class NTSLiveIE(InfoExtractor): | |
7 | IE_NAME = 'nts.live' | |
8 | _VALID_URL = r'https?://(?:www\.)?nts\.live/shows/[^/?#]+/episodes/(?P<id>[^/?#]+)' | |
9 | _TESTS = [ | |
10 | { | |
11 | # embedded soundcloud | |
12 | 'url': 'https://www.nts.live/shows/yu-su/episodes/yu-su-2nd-april-2024', | |
13 | 'md5': 'b5444c04888c869d68758982de1a27d8', | |
14 | 'info_dict': { | |
15 | 'id': '1791563518', | |
16 | 'ext': 'opus', | |
17 | 'uploader_id': '995579326', | |
18 | 'title': 'Pender Street Steppers & YU SU', | |
19 | 'timestamp': 1712073600, | |
20 | 'upload_date': '20240402', | |
21 | 'thumbnail': 'https://i1.sndcdn.com/artworks-qKcNO0z0AQGGbv9s-GljJCw-original.jpg', | |
22 | 'license': 'all-rights-reserved', | |
23 | 'repost_count': int, | |
24 | 'uploader_url': 'https://soundcloud.com/user-643553014', | |
25 | 'uploader': 'NTS Latest', | |
26 | 'description': 'md5:cd00ac535a63caaad722483ae3ff802a', | |
27 | 'duration': 10784.157, | |
28 | 'genres': ['Deep House', 'House', 'Leftfield Disco', 'Jazz Fusion', 'Dream Pop'], | |
29 | 'modified_timestamp': 1712564687, | |
30 | 'modified_date': '20240408', | |
31 | }, | |
32 | }, | |
33 | { | |
34 | # embedded mixcloud | |
35 | 'url': 'https://www.nts.live/shows/absolute-fiction/episodes/absolute-fiction-23rd-july-2022', | |
36 | 'info_dict': { | |
37 | 'id': 'NTSRadio_absolute-fiction-23rd-july-2022', | |
38 | 'ext': 'webm', | |
39 | 'like_count': int, | |
40 | 'title': 'Absolute Fiction', | |
41 | 'comment_count': int, | |
42 | 'uploader_url': 'https://www.mixcloud.com/NTSRadio/', | |
43 | 'description': 'md5:ba49da971ae8d71ee45813c52c5e2a04', | |
44 | 'tags': [], | |
45 | 'duration': 3529, | |
46 | 'timestamp': 1658588400, | |
47 | 'repost_count': int, | |
48 | 'upload_date': '20220723', | |
49 | 'uploader_id': 'NTSRadio', | |
50 | 'thumbnail': 'https://thumbnailer.mixcloud.com/unsafe/1024x1024/extaudio/5/1/a/d/ae3e-1be9-4fd4-983e-9c3294226eac', | |
51 | 'uploader': 'Mixcloud NTS Radio', | |
52 | 'genres': ['Minimal Synth', 'Post Punk', 'Industrial '], | |
53 | 'modified_timestamp': 1658842165, | |
54 | 'modified_date': '20220726', | |
55 | }, | |
56 | 'params': {'skip_download': 'm3u8'}, | |
57 | }, | |
58 | ] | |
59 | ||
60 | def _real_extract(self, url): | |
61 | video_id = self._match_id(url) | |
62 | webpage = self._download_webpage(url, video_id) | |
63 | ||
64 | data = self._search_json(r'window\._REACT_STATE_\s*=', webpage, 'react state', video_id) | |
65 | ||
66 | return { | |
67 | '_type': 'url_transparent', | |
68 | **traverse_obj(data, ('episode', { | |
69 | 'url': ('audio_sources', ..., 'url', {url_or_none}, any), | |
70 | 'title': ('name', {str}), | |
71 | 'description': ('description', {str}), | |
72 | 'genres': ('genres', ..., 'value', {str}), | |
73 | 'timestamp': ('broadcast', {parse_iso8601}), | |
74 | 'modified_timestamp': ('updated', {parse_iso8601}), | |
75 | })), | |
76 | } |