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

Code before:

    def _entries(self, data):
        base_url = 'https://nebula.tv'
        for episode in traverse_obj(data, ('episodes')):
            episode_id = traverse_obj(episode, ('video', 'id'))
            metadata = self._extract_video_metadata(episode)
            yield self.url_result(smuggle_url(f'{base_url}/videos/{episode_id}', {'id': episode_id}),
                                  NebulaIE, episode_id, url_transparent=True, **metadata)
        for extra in traverse_obj(data, ('extras')):
            extra_id = traverse_obj(extra, ('items', ..., 'id'))[0]
            metadata = self._extract_video_metadata(traverse_obj(extra, ('items', 0)))
            yield self.url_result(smuggle_url(f'{base_url}/videos/{extra_id}', {'id': extra_id}),
                                  NebulaIE, extra_id, url_transparent=True, **metadata)
        for trailer in traverse_obj(data, ('trailers')):
            trailer_id = trailer.get('id')
            metadata = self._extract_video_metadata(trailer)
            yield self.url_result(smuggle_url(f'{base_url}/videos/{trailer_id}', {'id': trailer_id}),
                                  NebulaIE, trailer_id, url_transparent=True, **metadata)

    def _real_extract(self, url):
        season_name, season_id = self._match_valid_url(url).group('series', 'season_number')
        playlist_id = f'{season_name}_{season_id}'
        data = self._call_api(f'https://content.api.nebula.app/content/{season_name}/season/{season_id}', playlist_id)
        if not traverse_obj(data, ('episodes'), ('extras'), ('trailers')):
            traverse_obj(data, ('episodes'), ('extras'), ('trailers'))
            raise ExtractorError('No Episodes, Outtakes, Trailes Found.')
        return self.playlist_result(self._entries(data), playlist_id, data.get('video_channel_slug'), data.get('short_description'))


Review comment (refactor):
- line too long
- `series`
- don't raise here
```suggestion
        data = self._call_api(
            f'https://content.api.nebula.app/content/{series}/season/{season_id}', playlist_id)

```

Code after:
    }]

    def _build_url_result(self, item):
        url = (
            traverse_obj(item, ('share_url', {url_or_none}))
            or urljoin('https://nebula.tv/', item.get('app_path'))
            or f'https://nebula.tv/videos/{item["slug"]}')
        return self.url_result(
            smuggle_url(url, {'id': item['id']}),
            NebulaIE, url_transparent=True,
            **self._extract_video_metadata(item))

    def _entries(self, data):
        for episode in traverse_obj(data, ('episodes', lambda _, v: v['video']['id'], 'video')):
            yield self._build_url_result(episode)
        for extra in traverse_obj(data, ('extras', ..., 'items', lambda _, v: v['id'])):
            yield self._build_url_result(extra)
        for trailer in traverse_obj(data, ('trailers', lambda _, v: v['id'])):
            yield self._build_url_result(trailer)

    def _real_extract(self, url):
        series, season_id = self._match_valid_url(url).group('series', 'season_number')
        playlist_id = f'{series}_{season_id}'
        data = self._call_api(
            f'https://content.api.nebula.app/content/{series}/season/{season_id}', playlist_id)

        return self.playlist_result(
            self._entries(data), playlist_id,
            **traverse_obj(data, {
                'title': ('title', {str}),
                'description': ('description', {str}),
            }))