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

Code before:
        },
    }, {
        # 2-video post with 'single' query param and --yes-playlist
        'url': 'https://t.me/vorposte/29343?single',
        'info_dict': {
            'id': 'vorposte-29343',
            'title': 'Форпост 29343',
            'description': 'md5:4d573fd641c3a21f58ad6bb5f16fe526',
        },
        'playlist_count': 2,
        'params': {
            'noplaylist': False,
            'skip_download': True,
        }
    }]

    def _real_extract(self, url):
        uploader, msg_id = self._match_valid_url(url).group('uploader', 'id')

        query = {'embed': '1'}
        if self.get_param('noplaylist'):
            query['single'] = True
        elif self.get_param('noplaylist') is False:
            pass
        elif '?single' in url:  # param 'noplaylist' is None
            query['single'] = True
        url = update_url_query(url, {'single': []})  # strip 'single' from original URL query
        embed = self._download_webpage(url, msg_id, query=query, note='Downloading embed frame')

        message = {
            'title': clean_html(get_element_by_class('tgme_widget_message_author', embed)),
            'description': clean_html(get_element_by_class('tgme_widget_message_text', embed)),
            'uploader': uploader,
            'timestamp': unified_timestamp(self._search_regex(
                r'<time[^>]*datetime="([^"]*)"', embed, 'timestamp', fatal=False)),
        }

        videos = []
        for video in re.findall(r'<a class="tgme_widget_message_video_player(?s:.+?)</time>', embed):
            video_url = self._search_regex(
                r'<video[^>]+src="([^"]+)"', video, 'video URL', fatal=False)
            webpage_url = self._search_regex(
                r'<a class="tgme_widget_message_video_player[^>]+href="([^"]+)"',
                video, 'webpage URL', fatal=False)
            if not video_url or not webpage_url:
                continue
            formats = [{
                'url': video_url,
                'ext': 'mp4',
            }]
            self._sort_formats(formats)

Review comment (suggestion):
Use utils.parse_qs and self._yes_playlist

noplaylist=None is not a thing. If `?single` is given, that should take precedence over yes/no-playlist

Code after:
            'channel_id': 'vorposte',
            'channel': 'Форпост',
            'thumbnail': r're:^https?://.+',
            'timestamp': 1666384480,
            'upload_date': '20221021',
            'duration': 33,
        },
    }]

    def _real_extract(self, url):
        channel_id, msg_id = self._match_valid_url(url).group('channel_id', 'id')
        embed = self._download_webpage(
            url, msg_id, query={'embed': '1', 'single': []}, note='Downloading embed frame')

        def clean_text(html_class, html):
            text = clean_html(get_element_by_class(html_class, html))
            return text.replace('\n', ' ') if text else None

        description = clean_text('tgme_widget_message_text', embed)
        message = {
            'title': description or '',
            'description': description,
            'channel': clean_text('tgme_widget_message_author', embed),
            'channel_id': channel_id,
            'timestamp': unified_timestamp(self._search_regex(
                r'<time[^>]*datetime="([^"]*)"', embed, 'timestamp', fatal=False)),
        }

        videos = []
        for video in re.findall(r'<a class="tgme_widget_message_video_player(?s:.+?)</time>', embed):
            video_url = self._search_regex(
                r'<video[^>]+src="([^"]+)"', video, 'video URL', fatal=False)
            webpage_url = self._search_regex(
                r'<a class="tgme_widget_message_video_player[^>]+href="([^"]+)"',
                video, 'webpage URL', fatal=False)
            if not video_url or not webpage_url:
                continue
            formats = [{
                'url': video_url,
                'ext': 'mp4',
            }]
            self._sort_formats(formats)
            videos.append({
                'id': url_basename(webpage_url),
                'webpage_url': update_url_query(webpage_url, {'single': True}),
                'duration': parse_duration(self._search_regex(
                    r'<time[^>]+duration[^>]*>([\d:]+)</time>', video, 'duration', fatal=False)),
                'thumbnail': self._search_regex(
                    r'tgme_widget_message_video_thumb"[^>]+background-image:url\(\'([^\']+)\'\)',
                    video, 'thumbnail', fatal=False),
                'formats': formats,