]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | ||
3 | from ..utils import traverse_obj | |
4 | ||
5 | ||
6 | class QingTingIE(InfoExtractor): | |
7 | _VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)' | |
8 | _TESTS = [{ | |
9 | 'url': 'https://www.qingting.fm/channels/378005/programs/22257411/', | |
10 | 'md5': '47e6a94f4e621ed832c316fd1888fb3c', | |
11 | 'info_dict': { | |
12 | 'id': '22257411', | |
13 | 'title': '用了十年才修改,谁在乎教科书?', | |
14 | 'channel_id': '378005', | |
15 | 'channel': '睡前消息', | |
16 | 'uploader': '马督工', | |
17 | 'ext': 'm4a', | |
18 | } | |
19 | }, { | |
20 | 'url': 'https://m.qtfm.cn/vchannels/378005/programs/23023573/', | |
21 | 'md5': '2703120b6abe63b5fa90b975a58f4c0e', | |
22 | 'info_dict': { | |
23 | 'id': '23023573', | |
24 | 'title': '【睡前消息488】重庆山火之后,有图≠真相', | |
25 | 'channel_id': '378005', | |
26 | 'channel': '睡前消息', | |
27 | 'uploader': '马督工', | |
28 | 'ext': 'm4a', | |
29 | } | |
30 | }] | |
31 | ||
32 | def _real_extract(self, url): | |
33 | channel_id, pid = self._match_valid_url(url).group('channel', 'id') | |
34 | webpage = self._download_webpage( | |
35 | f'https://m.qtfm.cn/vchannels/{channel_id}/programs/{pid}/', pid) | |
36 | info = self._search_json(r'window\.__initStores\s*=', webpage, 'program info', pid) | |
37 | return { | |
38 | 'id': pid, | |
39 | 'title': traverse_obj(info, ('ProgramStore', 'programInfo', 'title')), | |
40 | 'channel_id': channel_id, | |
41 | 'channel': traverse_obj(info, ('ProgramStore', 'channelInfo', 'title')), | |
42 | 'uploader': traverse_obj(info, ('ProgramStore', 'podcasterInfo', 'podcaster', 'nickname')), | |
43 | 'url': traverse_obj(info, ('ProgramStore', 'programInfo', 'audioUrl')), | |
44 | 'vcodec': 'none', | |
45 | 'acodec': 'm4a', | |
46 | 'ext': 'm4a', | |
47 | } |