]>
Commit | Line | Data |
---|---|---|
5bcccbfe | 1 | from .common import InfoExtractor |
90f42294 | 2 | from ..utils import clean_html, get_element_by_class |
5bcccbfe HTL |
3 | |
4 | ||
5 | class TelegramEmbedIE(InfoExtractor): | |
6 | IE_NAME = 'telegram:embed' | |
7 | _VALID_URL = r'https?://t\.me/(?P<channel_name>[^/]+)/(?P<id>\d+)' | |
8 | _TESTS = [{ | |
9 | 'url': 'https://t.me/europa_press/613', | |
10 | 'info_dict': { | |
11 | 'id': '613', | |
12 | 'ext': 'mp4', | |
13 | 'title': 'Europa Press', | |
14 | 'description': '6ce2d7e8d56eda16d80607b23db7b252', | |
15 | 'thumbnail': r're:^https?:\/\/cdn.*?telesco\.pe\/file\/\w+', | |
16 | }, | |
17 | }] | |
18 | ||
19 | def _real_extract(self, url): | |
20 | video_id = self._match_id(url) | |
90f42294 | 21 | webpage = self._download_webpage(url, video_id, query={'embed': 0}) |
22 | webpage_embed = self._download_webpage(url, video_id, query={'embed': 1}, note='Downloading ermbed page') | |
5bcccbfe HTL |
23 | |
24 | formats = [{ | |
25 | 'url': self._proto_relative_url(self._search_regex( | |
26 | '<video[^>]+src="([^"]+)"', webpage_embed, 'source')), | |
27 | 'ext': 'mp4', | |
28 | }] | |
29 | self._sort_formats(formats) | |
30 | ||
31 | return { | |
32 | 'id': video_id, | |
90f42294 | 33 | 'title': self._html_search_meta(['og:title', 'twitter:title'], webpage, default=None), |
34 | 'description': self._html_search_meta( | |
35 | ['og:description', 'twitter:description'], webpage, | |
36 | default=clean_html(get_element_by_class('tgme_widget_message_text', webpage_embed))), | |
37 | 'thumbnail': self._search_regex( | |
38 | r'tgme_widget_message_video_thumb"[^>]+background-image:url\(\'([^\']+)\'\)', | |
39 | webpage_embed, 'thumbnail'), | |
5bcccbfe HTL |
40 | 'formats': formats, |
41 | } |