qingting.py 1.9 KB

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