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

Code before:
            'uploader_id': 'MS4wLjABAAAAeateBb9Su8I3MJOZozmvyzWktmba5LMlliRDz1KffnM',
            'view_count': int,
        },
    }, {
        'url': 'https://www.toutiao.com/video/7479446610359878153/',
        'info_dict': {
            'id': '7479446610359878153',
            'ext': 'mp4',
            'title': '小伙竟然利用两块磁铁制作成磁力减震器，简直太有创意了！',
            'comment_count': int,
            'duration': 118.374,
            'like_count': int,
            'release_date': '20250308',
            'release_timestamp': 1741444368,
            'thumbnail': r're:https?://p\d+-sign\.toutiaoimg\.com/.+$',
            'uploader': '小莉创意发明',
            'uploader_id': 'MS4wLjABAAAA4f7d4mwtApALtHIiq-QM20dwXqe32NUz0DeWF7wbHKw',
            'view_count': int,
        },
    }]

    def _real_initialize(self):
        if self._get_cookies('https://www.toutiao.com').get('ttwid'):
            return

        _, urlh = self._download_json_handle(
            'https://ttwid.bytedance.com/ttwid/union/register/', None,
            'Fetching ttwid', 'Unable to fetch ttwid', headers={
                'Content-Type': 'application/json',
            }, data=json.dumps({
                'aid': 24,
                'needFid': False,
                'region': 'cn',
                'service': 'www.toutiao.com',
                'union': True,
            }).encode(),
        )

        if ttwid := self._get_cookies(urlh.url)['ttwid'].value:
            self._set_cookie('.toutiao.com', 'ttwid', ttwid)
            return

        self.raise_login_required(method='cookies')

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        video_data = traverse_obj(webpage, (
            {find_element(tag='script', id='RENDER_DATA')},
            {urllib.parse.unquote}, {json.loads}, 'data', 'initialVideo',
        ))

Review comment (suggestion):
use `_request_webpage` if you don't want/need to read the content
```suggestion
        urlh = self._request_webpage(
```

Code after:
            'uploader': '极目新闻',
            'uploader_id': 'MS4wLjABAAAAeateBb9Su8I3MJOZozmvyzWktmba5LMlliRDz1KffnM',
            'view_count': int,
        },
    }, {
        'url': 'https://www.toutiao.com/video/7479446610359878153/',
        'info_dict': {
            'id': '7479446610359878153',
            'ext': 'mp4',
            'title': '小伙竟然利用两块磁铁制作成磁力减震器，简直太有创意了！',
            'comment_count': int,
            'duration': 118.374,
            'like_count': int,
            'release_date': '20250308',
            'release_timestamp': 1741444368,
            'thumbnail': r're:https?://p\d+-sign\.toutiaoimg\.com/.+$',
            'uploader': '小莉创意发明',
            'uploader_id': 'MS4wLjABAAAA4f7d4mwtApALtHIiq-QM20dwXqe32NUz0DeWF7wbHKw',
            'view_count': int,
        },
    }]

    def _real_initialize(self):
        if self._get_cookies('https://www.toutiao.com').get('ttwid'):
            return

        urlh = self._request_webpage(
            'https://ttwid.bytedance.com/ttwid/union/register/', None,
            'Fetching ttwid', 'Unable to fetch ttwid', headers={
                'Content-Type': 'application/json',
            }, data=json.dumps({
                'aid': 24,
                'needFid': False,
                'region': 'cn',
                'service': 'www.toutiao.com',
                'union': True,
            }).encode(),
        )

        if ttwid := try_call(lambda: self._get_cookies(urlh.url)['ttwid'].value):
            self._set_cookie('.toutiao.com', 'ttwid', ttwid)
            return

        self.raise_login_required()

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        video_data = traverse_obj(webpage, (
            {find_element(tag='script', id='RENDER_DATA')},
            {urllib.parse.unquote}, {json.loads}, 'data', 'initialVideo',