Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/qingting.py (Python)

Code before:
            'ext': 'mp3',
            'title': '用了十年才修改，谁在乎教科书？-睡前消息-蜻蜓FM听头条',
        }
    }

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        title = self._html_search_regex(r'(?s)<title\b[^>]*>(.*)</title>', webpage, 'title',
                                        default=None) or self._og_search_title(webpage)
        urlType = self._search_regex(
            self._VALID_URL,
            url, 'audio URL', group="m")
        if urlType == 'm.':
            url = self._search_regex(
                r'''("|')audioUrl\1\s*:\s*("|')(?P<url>(?:(?!\2).)*)\2''',
                webpage, 'audio URL', group="url")
            test_url = utils.url_or_none(url)
            if not test_url:
                raise utils.ExtractorError('Invalid audio URL %s' % (url,))
            return {
                'id': video_id,
                'title': title,
                'ext': 'mp3',
                'url': test_url,
            }
        else:
            url = self._search_regex(
                r'''("|')alternate\1\s*:\s*("|')(?P<url>(?:(?!\2).)*)\2''',
                webpage, 'alternate URL', group="url")
            test_url = utils.url_or_none(url)
            if not test_url:
                raise utils.ExtractorError('Invalid audio URL %s' % (url,))
            return self.url_result(url=test_url, video_id=video_id, video_title=title)


Review comment (refactor):
```suggestion
        return {
            'id': pid,
            'title': traverse_obj(info, ('ProgramStore', 'programInfo', 'title')),
            'channel_id': channel_id,
            'url': traverse_obj(info, ('ProgramStore', 'programInfo', 'audioUrl')),
            'ext': 'm4a',
        }
```
use `traverse_obj` to extract values from the page's parsed JSON.

in my testing, I found the site uses `m4a` instead of `mp3`.

there's more metadata that can be found in `info` if you want to add more

Code after:
        'url': 'https://m.qtfm.cn/vchannels/378005/programs/23023573/',
        'md5': '2703120b6abe63b5fa90b975a58f4c0e',
        'info_dict': {
            'id': '23023573',
            'title': '【睡前消息488】重庆山火之后，有图≠真相',
            'channel_id': '378005',
            'channel': '睡前消息',
            'uploader': '马督工',
            'ext': 'm4a',
        }
    }]

    def _real_extract(self, url):
        channel_id, pid = self._match_valid_url(url).group('channel', 'id')
        webpage = self._download_webpage(
            f'https://m.qtfm.cn/vchannels/{channel_id}/programs/{pid}/', pid)
        info = self._search_json(r'window\.__initStores\s*=', webpage, 'program info', pid)
        return {
            'id': pid,
            'title': traverse_obj(info, ('ProgramStore', 'programInfo', 'title')),
            'channel_id': channel_id,
            'channel': traverse_obj(info, ('ProgramStore', 'channelInfo', 'title')),
            'uploader': traverse_obj(info, ('ProgramStore', 'podcasterInfo', 'podcaster', 'nickname')),
            'url': traverse_obj(info, ('ProgramStore', 'programInfo', 'audioUrl')),
            'vcodec': 'none',
            'acodec': 'm4a',
            'ext': 'm4a',
        }