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

Code before:
            'duration': 344,
            'upload_date': '20200827',
            'channel_id': 'UCsooa4yRKGN_zEE8iknghZA',
            'playable_in_embed': True,
            'description': 'md5:c0959524f08cb60f96fd010f3dfb17f3',
            'categories': ['Education'],
            'like_count': int,
            'channel': 'TED-Ed',
            'chapters': [{'start_time': 0.0, 'title': 'Intro', 'end_time': 60.0}, {'start_time': 60.0, 'title': 'The Prisoners Dilemma', 'end_time': 120.0}, {'start_time': 120.0, 'title': 'The Nash Equilibrium', 'end_time': 166.0}, {'start_time': 166.0, 'title': 'The Infinite Prisoners Dilemma', 'end_time': 199.0}, {'start_time': 199.0, 'title': 'Delta', 'end_time': 246.0}, {'start_time': 246.0, 'title': 'Spare', 'end_time': 284.0}, {'start_time': 284.0, 'title': 'Conclusion', 'end_time': 344}],
            'channel_url': 'https://www.youtube.com/channel/UCsooa4yRKGN_zEE8iknghZA',
            'tags': 'count:26',
            'availability': 'public',
            'channel_follower_count': int,
            'view_count': int,
            'age_limit': 0,
            'live_status': 'not_live',
            'comment_count': int,
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        embed_url = self._search_regex(r'"embedUrl": *"([^"]+)"', webpage, 'url')
        if get_domain(embed_url) == 'vimeo.com':
            embed_url = VimeoIE._smuggle_referrer(embed_url, 'https://aeon.co')
        return self.url_result(embed_url)


Review comment (suggestion):
`get_domain` won't work with `player.vimeo.com` embed URLs
```py
def get_domain(url):
    """
    This implementation is inconsistent, but is kept for compatibility.
    Use this only for "webpage_url_domain"
    """
    return remove_start(urllib.parse.urlparse(url).netloc, 'www.') or None
```
instead we could do this:
```suggestion
        if 'player.vimeo.com' in embed_url:
            embed_url = VimeoIE._smuggle_referrer(embed_url, 'https://aeon.co/')
```
(remove `get_domain` from imports)

Code after:
            'duration': 344,
            'upload_date': '20200827',
            'channel_id': 'UCsooa4yRKGN_zEE8iknghZA',
            'playable_in_embed': True,
            'description': 'md5:c0959524f08cb60f96fd010f3dfb17f3',
            'categories': ['Education'],
            'like_count': int,
            'channel': 'TED-Ed',
            'chapters': 'count:7',
            'channel_url': 'https://www.youtube.com/channel/UCsooa4yRKGN_zEE8iknghZA',
            'tags': 'count:26',
            'availability': 'public',
            'channel_follower_count': int,
            'view_count': int,
            'age_limit': 0,
            'live_status': 'not_live',
            'comment_count': int,
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        embed_url = traverse_obj(self._yield_json_ld(webpage, video_id), (
            lambda _, v: v['@type'] == 'VideoObject', 'embedUrl', {url_or_none}), get_all=False)
        if not embed_url:
            raise ExtractorError('No embed URL found in webpage')
        if 'player.vimeo.com' in embed_url:
            embed_url = VimeoIE._smuggle_referrer(embed_url, 'https://aeon.co/')
        return self.url_result(embed_url)