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

Code before:
            'description': 'Íþróttafréttir.',
        },
    }, {
        'url': 'https://www.ruv.is/utvarp/spila/i-ljosi-sogunnar/23795/7hqkre',
        'info_dict': {
            'id': '7hqkre',
            'ext': 'mp3',
            'thumbnail': 'https://d38kdhuogyllre.cloudfront.net/fit-in/1960x/filters:quality(65)/hd_posters/7hqkre-7uepao.jpg',
            'description': 'md5:8d7046549daff35e9a3190dc9901a120',
            'chapters': [],
            'upload_date': '20220204',
            'timestamp': 1643965500,
            'title': 'Nellie Bly II',
        },
    }, {
        'url': 'https://www.ruv.is/ungruv/spila/ungruv/28046/8beuph',
        'only_matching': True
    }, {
        'url': 'https://www.ruv.is/krakkaruv/spila/krakkafrettir/30712/9jbgb0',
        'only_matching': True
    }]

    def _real_extract(self, url):
        mobj = self._match_valid_url(url)
        display_id = mobj.group('id')
        series_id = mobj.group('series_id')
        program = self._download_json(
            'https://www.ruv.is/gql/', display_id,
            query={'query': """{
        Program(id: %s){
            title image description short_description
            episodes(id: {value: "%s"}) {
                rating title duration file image firstrun description
                clips {
                    time text
                }
                subtitles {
                    name value
                }
            }
        }}""" % (series_id, display_id)})['data']['Program']
        episode = program['episodes'][0]

        description = traverse_obj(program, ('episodes', 0, 'description'), 'description', 'short_description')
        thumbnail = episode.get('image', '').replace('$$IMAGESIZE$$', '1960') or None
        timestamp = unified_timestamp(episode.get('firstrun'))
        subs = {}
        for trk in episode.get('subtitles', []):
            subs[trk.get('name')] = {'url': trk.get('value')}

        media_url = episode['file']

Review comment (suggestion):
```suggestion
        display_id, series_id = self._match_valid_url(url).group('id', 'series_id')
```

Code after:
            'description': 'Íþróttafréttir.',
            'age_limit': 0,
        },
    }, {
        'url': 'https://www.ruv.is/utvarp/spila/i-ljosi-sogunnar/23795/7hqkre',
        'info_dict': {
            'id': '7hqkre',
            'ext': 'mp3',
            'thumbnail': 'https://d38kdhuogyllre.cloudfront.net/fit-in/1960x/filters:quality(65)/hd_posters/7hqkre-7uepao.jpg',
            'description': 'md5:8d7046549daff35e9a3190dc9901a120',
            'chapters': [],
            'upload_date': '20220204',
            'timestamp': 1643965500,
            'title': 'Nellie Bly II',
            'age_limit': 0,
        },
    }, {
        'url': 'https://www.ruv.is/ungruv/spila/ungruv/28046/8beuph',
        'only_matching': True
    }, {
        'url': 'https://www.ruv.is/krakkaruv/spila/krakkafrettir/30712/9jbgb0',
        'only_matching': True
    }]

    def _real_extract(self, url):
        display_id, series_id = self._match_valid_url(url).group('id', 'series_id')
        program = self._download_json(
            'https://www.ruv.is/gql/', display_id, query={'query': '''{
                Program(id: %s){
                    title image description short_description
                    episodes(id: {value: "%s"}) {
                        rating title duration file image firstrun description
                        clips {
                            time text
                        }
                        subtitles {
                            name value
                        }
                    }
                }
            }''' % (series_id, display_id)})['data']['Program']
        episode = program['episodes'][0]

        subs = {}
        for trk in episode.get('subtitles'):
            if trk.get('name') and trk.get('value'):
                subs.setdefault(trk['name'], []).append({'url': trk['value'], 'ext': 'vtt'})

        media_url = episode['file']
        if determine_ext(media_url) == 'm3u8':
            formats = self._extract_m3u8_formats(media_url, display_id)