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

Code before:
        },
        {
            # First capture is a 302 redirect intermediary page.
            'url': 'https://web.archive.org/web/20050214000000/http://www.youtube.com/watch?v=0altSZ96U4M',
            'info_dict': {
                'id': '0altSZ96U4M',
                'ext': 'mp4',
                'title': '0altSZ96U4M'
            },
            'expected_warnings': [
                'unable to extract title',
            ]
        },
        {
            # Video not archived, only capture is unavailable video page
            'url': 'https://web.archive.org/web/20210530071008/https://www.youtube.com/watch?v=lHJTf93HL1s&spfreload=10',
            'only_matching': True,
        }
    ]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        title = video_id  # if we are not able get a title

        def _extract_title(webpage):
            page_title = strip_or_none(self._html_search_regex(r'<title>([^<]*)</title>', webpage, 'title', fatal=False), default='')
            # YouTube video pages appear to always have either 'YouTube -' as suffix or '- YouTube' as prefix.
            try:
                page_title = strip_or_none(self._search_regex(r'(?:YouTube\s*-\s*(.*)$)|(?:(.*)\s*-\s*YouTube$)', page_title, 'title', default=''))
            except RegexNotFoundError:
                self.report_warning('unable to extract title')
                return
            if not page_title:
                self.report_warning('unable to extract title', video_id=video_id)
                return
            return page_title

        # If the video is no longer available, the oldest capture may be one before it was removed.
        # Setting the capture date in url to early date seems to redirect to earliest capture.
        webpage = self._download_webpage(
            'https://web.archive.org/web/20050214000000/http://www.youtube.com/watch?v=%s' % video_id,
            video_id=video_id, fatal=False, errnote='unable to download video webpage (probably not archived).')
        if webpage:
            title = _extract_title(webpage) or title

        # Use link translator mentioned in https://github.com/ytdl-org/youtube-dl/issues/13655
        internal_fake_url = 'https://web.archive.org/web/2oe_/http://wayback-fakeurl.archive.org/yt/%s' % video_id
        try:
            video_file_webpage = self._request_webpage(
                HEADRequest(internal_fake_url), video_id,
                note='Fetching video file url', expected_status=True)

Review comment (suggestion):
You may want to use `_html_search_regex` instead of `strip_or_none(self._search_regex` here

Code after:
        },
        {
            # First capture is a 302 redirect intermediary page.
            'url': 'https://web.archive.org/web/20050214000000/http://www.youtube.com/watch?v=0altSZ96U4M',
            'info_dict': {
                'id': '0altSZ96U4M',
                'ext': 'mp4',
                'title': '0altSZ96U4M'
            },
            'expected_warnings': [
                'unable to extract title',
            ]
        },
        {
            # Video not archived, only capture is unavailable video page
            'url': 'https://web.archive.org/web/20210530071008/https://www.youtube.com/watch?v=lHJTf93HL1s&spfreload=10',
            'only_matching': True,
        },
        {   # Encoded url
            'url': 'https://web.archive.org/web/20120712231619/http%3A//www.youtube.com/watch%3Fgl%3DUS%26v%3DAkhihxRKcrs%26hl%3Den',
            'only_matching': True,
        },
        {
            'url': 'https://web.archive.org/web/20120712231619/http%3A//www.youtube.com/watch%3Fv%3DAkhihxRKcrs%26gl%3DUS%26hl%3Den',
            'only_matching': True,
        }
    ]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        title = video_id  # if we are not able get a title

        def _extract_title(webpage):
            page_title = self._html_search_regex(
                r'<title>([^<]*)</title>', webpage, 'title', fatal=False) or ''
            # YouTube video pages appear to always have either 'YouTube -' as suffix or '- YouTube' as prefix.
            try:
                page_title = self._html_search_regex(
                    r'(?:YouTube\s*-\s*(.*)$)|(?:(.*)\s*-\s*YouTube$)',
                    page_title, 'title', default='')
            except RegexNotFoundError:
                page_title = None

            if not page_title:
                self.report_warning('unable to extract title', video_id=video_id)
                return
            return page_title

        # If the video is no longer available, the oldest capture may be one before it was removed.
        # Setting the capture date in url to early date seems to redirect to earliest capture.
        webpage = self._download_webpage(