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

Code before:
            'description': '<p>Ryan is joined by Joe and Taylor to answer the age old question (in your best Jerry Seinfeld impression), "What\'s the deal with kickoff?!" How does a game get underway, how have the rules regarding kickoff evolved since the mid-1800s, what are the different approaches to getting your tactics right from kickoff, how could we improve upon the current system, and much much more!</p><p>The Soccer 101 theme, and plenty of other excellent music, can be found right here: <a href="https://aerialist.bandcamp.com/">https://aerialist.bandcamp.com</a>.</p>',
            'duration': 1765,
            'ext': 'mp3',
        },
    }]

    def _real_extract(self, url):
        # podcast url is always after last backlash
        video_id = self._match_id(url)
        data = self._download_json(url + '.json', None)

        title = data.get('title')
        description = data.get('description')
        duration = data.get('duration')
        thumbnail = traverse_obj(data, ('image', 'url'), ('series', 'image', 'url'))
        creators = [traverse_obj(data, ('series', 'author'))]

        video_url = join_nonempty('https', self._search_regex(r'redirect.mp3/(.*)', data['url'], 'redirect'), delim='://')
        if not video_url:
            raise ExtractorError('URL to podcast not found', expected=True)
        formats = [{
            'url': video_url,
            'ext': determine_ext(video_url, default_ext=''),
        }]
        return {
            'id': video_id,
            'thumbnail': thumbnail,
            'title': title,
            'creators': creators,
            'description': description,
            'duration': duration,
            'formats': formats,
        }


Review comment (refactor):
- We want to error if anything is empty, so `join_nonempty` isn't needed here
- Returning a single format can be done with the `url` field instead of a single-element `formats` list
- Core code already calls `determine_ext` on the format `url` if you don't return an `ext`, and we wouldn't want to return an empty string as `ext`
- ExtractorError isn't needed since the regex search is already fatal
- If we are returning an audio-only format, we need to return `'vcodec': 'none'`
```suggestion
        return {
            'id': video_id,
            'url': 'https://' + self._search_regex(r'redirect\.mp3/(.+)', data['url'], 'video url'),
            'vcodec': 'none',
```

Code after:
        'info_dict': {
            'ext': 'mp3',
            'id': '481418710',
            'thumbnail': r're:^https://.*\.(jpg|png)',
            'title': r're:#109 It\'s kicking off! How have the rules for kickoff changed, .+ the present system\?',
            'creators': ['TSS'],
            'duration': 1510,
            'display_id': 'md5:b52ecacaefab891b59db69721bfd9b13',
            'description': 'md5:52a39e36d08d8919527454f152ad3c25',
            'timestamp': 1659102055,
            'upload_date': '20220729',
        },
    }]

    def _real_extract(self, url):
        display_id, url = self._match_valid_url(url).group('id', 'url')
        data = self._download_json(f'{url}.json', display_id)

        return {
            'display_id': display_id,
            'vcodec': 'none',
            **traverse_obj(data, {
                'id': ('id', {int}, {str_or_none}),
                'url': ('url', {clean_podcast_url}),
                'title': ('title', {str}),
                'description': ('description', {clean_html}),
                'duration': ('duration', {int_or_none}),
                'thumbnail': (('image', ('series', 'image')), 'url', {url_or_none}, any),
                'filesize': ('size', {int_or_none}),
                'timestamp': ('publishedAt', {int_or_none}),
                'creators': ('series', 'author', {str}, filter, all, filter),
            }),
        }