]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/echomsk.py
[ie/box] Fix formats extraction (#8649)
[yt-dlp.git] / yt_dlp / extractor / echomsk.py
CommitLineData
1931a73f
S
1import re
2
3from .common import InfoExtractor
4
5
6class EchoMskIE(InfoExtractor):
5886b38d 7 _VALID_URL = r'https?://(?:www\.)?echo\.msk\.ru/sounds/(?P<id>\d+)'
1931a73f
S
8 _TEST = {
9 'url': 'http://www.echo.msk.ru/sounds/1464134.html',
10 'md5': '2e44b3b78daff5b458e4dbc37f191f7c',
11 'info_dict': {
12 'id': '1464134',
13 'ext': 'mp3',
14 'title': 'Особое мнение - 29 декабря 2014, 19:08',
15 },
16 }
17
18 def _real_extract(self, url):
19 video_id = self._match_id(url)
20
21 webpage = self._download_webpage(url, video_id)
22
23 audio_url = self._search_regex(
24 r'<a rel="mp3" href="([^"]+)">', webpage, 'audio URL')
25
26 title = self._html_search_regex(
27 r'<a href="/programs/[^"]+" target="_blank">([^<]+)</a>',
28 webpage, 'title')
29
30 air_date = self._html_search_regex(
31 r'(?s)<div class="date">(.+?)</div>',
32 webpage, 'date', fatal=False, default=None)
33
34 if air_date:
35 air_date = re.sub(r'(\s)\1+', r'\1', air_date)
36 if air_date:
37 title = '%s - %s' % (title, air_date)
38
39 return {
40 'id': video_id,
41 'url': audio_url,
42 'title': title,
43 }