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

Code before:
                info = merge_dicts(info, only_video)
        else:
            # Otherwise, we have a playlist.
            info['_type'] = 'playlist'
            info['entries'] = list(entries.values())

        if metadata.get('reviews'):
            info['comments'] = []
            for review in metadata['reviews']:
                info['comments'].append({
                    'id': review.get('review_id'),
                    'author': review.get('reviewer'),
                    'text': str_or_none(review.get('reviewtitle'), '') + '\n\n' + review.get('reviewbody'),
                    'timestamp': unified_timestamp(review.get('createdate')),
                    'parent': 'root'})

        return info


class YoutubeWebArchiveIE(InfoExtractor):
    IE_NAME = 'youtube:web.archive.org'
    IE_DESC = 'web.archive.org saved youtube videos'
    _VALID_URL = r"""(?x)^
                (?:https?://|//)?web\.archive\.org\/
                    (?:web/)?
                    (?:[0-9A-Za-z_*]+/)? # /web and the version index is optional
                (?:https?:\/\/)?
                (?:
                    (?:\w+\.)?youtube\.com\/watch\?v= # Youtube URL
                    |(wayback-fakeurl\.archive\.org\/yt\/) # Or optionally, also support the internal fake url
                )
                (?P<id>[0-9A-Za-z_-]{11})(?(1).+)?(?:\#|&|$)
                """

    _INTERNAL_URL_TEMPLATE = "https://web.archive.org/web/2oe_/http://wayback-fakeurl.archive.org/yt/%s"

    _TESTS = [
        {
            'url': 'https://web.archive.org/web/20150415002341/https://www.youtube.com/watch?v=aYAGB11YrSs',
            'info_dict': {
                'id': 'aYAGB11YrSs',
                'ext': 'webm',
                'title': 'Unknown Video'
            }
        },
        {
            # Internal link
            'url': 'https://web.archive.org/web/2oe/http://wayback-fakeurl.archive.org/yt/97t7Xj_iBv0',
            'info_dict': {
                'id': '97t7Xj_iBv0',
                'ext': 'mp4',

Review comment (suggestion):
```suggestion
                    (?:[0-9A-Za-z_*]+/)?  # /web and the version index is optional
```
Flake8 doesnt detect this since it is inside the regex, but use 2 spaces before comments. Similar below

Code after:
            only_video = entries[list(entries.keys())[0]]
            if entry_id:
                info = merge_dicts(only_video, info)
            else:
                info = merge_dicts(info, only_video)
        else:
            # Otherwise, we have a playlist.
            info['_type'] = 'playlist'
            info['entries'] = list(entries.values())

        if metadata.get('reviews'):
            info['comments'] = []
            for review in metadata['reviews']:
                info['comments'].append({
                    'id': review.get('review_id'),
                    'author': review.get('reviewer'),
                    'text': str_or_none(review.get('reviewtitle'), '') + '\n\n' + review.get('reviewbody'),
                    'timestamp': unified_timestamp(review.get('createdate')),
                    'parent': 'root'})

        return info


class YoutubeWebArchiveIE(InfoExtractor):
    IE_NAME = 'web.archive:youtube'
    IE_DESC = 'web.archive.org saved youtube videos'
    _VALID_URL = r"""(?x)^
                (?:https?://)?web\.archive\.org/
                    (?:web/)?
                    (?:[0-9A-Za-z_*]+/)?  # /web and the version index is optional

                (?:https?(?::|%3[Aa])//)?
                (?:
                    (?:\w+\.)?youtube\.com/watch(?:\?|%3[fF])(?:[^\#]+(?:&|%26))?v(?:=|%3[dD])  # Youtube URL
                    |(wayback-fakeurl\.archive\.org/yt/)  # Or the internal fake url
                )
                (?P<id>[0-9A-Za-z_-]{11})(?:%26|\#|&|$)
                """

    _TESTS = [
        {
            'url': 'https://web.archive.org/web/20150415002341/https://www.youtube.com/watch?v=aYAGB11YrSs',
            'info_dict': {
                'id': 'aYAGB11YrSs',
                'ext': 'webm',
                'title': 'Team Fortress 2 - Sandviches!'
            }
        },
        {
            # Internal link
            'url': 'https://web.archive.org/web/2oe/http://wayback-fakeurl.archive.org/yt/97t7Xj_iBv0',