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

Code before:
            'release_date': '20231001',
            'series': 'Breakup Probation, A Week',
            'series_id': 22912,
            'episode_number': 8,
            'episode': 'E08',
        },
    }, {
        'url': 'https://www.ondemandkorea.com/player/vod/the-outlaws?contentId=369531',
        'md5': 'fa5523b87aa1f6d74fc622a97f2b47cd',
        'info_dict': {
            'id': '369531',
            'ext': 'mp4',
            'release_date': '20220519',
            'duration': 7267.0,
            'title': 'The Outlaws: Main Movie',
            'thumbnail': r're:^https?://.*\.(jpg|jpeg|png)',
            'age_limit': 18,
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)

        data = self._download_json(f'https://odkmedia.io/odx/api/v3/playback/{video_id}/', video_id,
                                   fatal=False, headers={'service-name': 'odk'},
                                   query={'did': random_uuidv4()}, expected_status=(403, 404))
        if not data.get('result'):
            raise ExtractorError(traverse_obj(data, ('messages', '__default'), 'title'), expected=True)

        potential_urls = traverse_obj(data, ('result', ('sources', 'manifest'), ..., 'url'))
        # Try to bypass geo-restricted ad proxy
        potential_urls = [
            alt_url if (alt_url := traverse_obj(url, ({parse_qs}, 'stream_url', 0, {url_or_none}))) else url
            for url in potential_urls
        ]
        # Try to upgrade quality
        potential_urls = [
            mod_url if self._request_webpage(
                HEADRequest(mod_url := re.sub(r'_720(p?)\.m3u8', r'_1080\1.m3u8', url)), video_id,
                note='Checking if higher quality format is available', fatal=False) else url
            for url in potential_urls
        ]

        formats = []
        for url in potential_urls:
            formats.extend(self._extract_m3u8_formats(url, video_id, fatal=False))

        subtitles = {}
        for track in traverse_obj(data, ('result', 'text_tracks', lambda _, v: url_or_none(v['url']))):
            subtitles.setdefault(track.get('language', 'und'), []).append({
                'url': track['url'],

Review comment (suggestion):
I would just use `str(uuid.uuid4())`
```suggestion
        data = self._download_json(
            f'https://odkmedia.io/odx/api/v3/playback/{video_id}/', video_id, fatal=False,
            headers={'service-name': 'odk'}, query={'did': str(uuid.uuid4())}, expected_status=(403, 404))
```

Code after:
            'release_date': '20231001',
            'series': 'Breakup Probation, A Week',
            'series_id': 22912,
            'episode_number': 8,
            'episode': 'E08',
        },
    }, {
        'url': 'https://www.ondemandkorea.com/player/vod/the-outlaws?contentId=369531',
        'md5': 'fa5523b87aa1f6d74fc622a97f2b47cd',
        'info_dict': {
            'id': '369531',
            'ext': 'mp4',
            'release_date': '20220519',
            'duration': 7267.0,
            'title': 'The Outlaws: Main Movie',
            'thumbnail': r're:^https?://.*\.(jpg|jpeg|png)',
            'age_limit': 18,
        },
    }, {
        'url': 'https://www.ondemandkorea.com/en/player/vod/capture-the-moment-how-is-that-possible?contentId=1605006',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)

        data = self._download_json(
            f'https://odkmedia.io/odx/api/v3/playback/{video_id}/', video_id, fatal=False,
            headers={'service-name': 'odk'}, query={'did': str(uuid.uuid4())}, expected_status=(403, 404))
        if not traverse_obj(data, ('result', {dict})):
            msg = traverse_obj(data, ('messages', '__default'), 'title', expected_type=str)
            raise ExtractorError(msg or 'Got empty response from playback API', expected=True)

        data = data['result']

        def try_geo_bypass(url):
            return traverse_obj(url, ({parse_qs}, 'stream_url', 0, {url_or_none})) or url

        def try_upgrade_quality(url):
            mod_url = re.sub(r'_720(p?)\.m3u8', r'_1080\1.m3u8', url)
            return mod_url if mod_url != url and self._request_webpage(
                HEADRequest(mod_url), video_id, note='Checking for higher quality format',
                errnote='No higher quality format found', fatal=False) else url

        formats = []
        for m3u8_url in traverse_obj(data, (('sources', 'manifest'), ..., 'url', {url_or_none}, {try_geo_bypass})):
            formats.extend(self._extract_m3u8_formats(try_upgrade_quality(m3u8_url), video_id, fatal=False))

        subtitles = {}
        for track in traverse_obj(data, ('text_tracks', lambda _, v: url_or_none(v['url']))):
            subtitles.setdefault(track.get('language', 'und'), []).append({