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

Code before:
        'only_matching': True,
    }, {
        'url': 'https://chaturbate.eu/fullvideo/?b=caylin',
        'only_matching': True,
    }, {
        'url': 'https://chaturbate.global/siswet19/',
        'only_matching': True,
    }]

    _ERROR_MAP = {
        'offline': 'Room is currently offline',
        'private': 'Room is currently in a private show',
        'away': 'Performer is currently away',
        'password protected': 'Room is password protected',
        'hidden': 'Hidden session in progress',
    }

    def _extract_from_api(self, video_id, tld):
        response = self._download_json(
            f'https://chaturbate.{tld}/get_edge_hls_url_ajax/', video_id,
            data=urlencode_postdata({'room_slug': video_id}),
            headers={
                **self.geo_verification_headers(),
                'X-Requested-With': 'XMLHttpRequest',
                'Accept': 'application/json',
            }, fatal=False) or {}

        status = response.get('room_status')
        if status != 'public':
            if error := self._ERROR_MAP.get(status):
                raise ExtractorError(error, expected=True)
            self.report_warning('Falling back to webpage extraction')
            return None

        m3u8_url = response.get('url')
        if not m3u8_url:
            self.raise_geo_restricted()

        return {
            'id': video_id,
            'title': video_id,
            'thumbnail': f'https://roomimg.stream.highwebmedia.com/ri/{video_id}.jpg',
            'is_live': True,
            'formats': self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4', live=True),
        }

    def _extract_from_webpage(self, video_id, tld):
        webpage = self._download_webpage(
            f'https://chaturbate.{tld}/{video_id}/', video_id,
            headers=self.geo_verification_headers(), impersonate=True)


Review comment (suggestion):
```suggestion
            }, fatal=False, impersonate=True) or {}
```

Code after:
        'only_matching': True,
    }, {
        'url': 'https://chaturbate.eu/fullvideo/?b=caylin',
        'only_matching': True,
    }, {
        'url': 'https://chaturbate.global/siswet19/',
        'only_matching': True,
    }]

    _ERROR_MAP = {
        'offline': 'Room is currently offline',
        'private': 'Room is currently in a private show',
        'away': 'Performer is currently away',
        'password protected': 'Room is password protected',
        'hidden': 'Hidden session in progress',
    }

    def _extract_from_api(self, video_id, tld):
        response = self._download_json(
            f'https://chaturbate.{tld}/get_edge_hls_url_ajax/', video_id,
            data=urlencode_postdata({'room_slug': video_id}),
            headers={
                **self.geo_verification_headers(),
                'X-Requested-With': 'XMLHttpRequest',
                'Accept': 'application/json',
            }, fatal=False, impersonate=True) or {}

        status = response.get('room_status')
        if status != 'public':
            if error := self._ERROR_MAP.get(status):
                raise ExtractorError(error, expected=True)
            self.report_warning('Falling back to webpage extraction')
            return None

        m3u8_url = response.get('url')
        if not m3u8_url:
            self.raise_geo_restricted()

        return {
            'id': video_id,
            'title': video_id,
            'thumbnail': f'https://roomimg.stream.highwebmedia.com/ri/{video_id}.jpg',
            'is_live': True,
            'age_limit': 18,
            'formats': self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4', live=True),
        }

    def _extract_from_webpage(self, video_id, tld):
        webpage = self._download_webpage(
            f'https://chaturbate.{tld}/{video_id}/', video_id,
            headers=self.geo_verification_headers(), impersonate=True)