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

Code before:
    }, {
        'url': 'https://gopro.com/v/kVrK9wlJvBMwn',
        'info_dict': {
            'id': 'kVrK9wlJvBMwn',
            'title': 'DARKNESS',
            'thumbnail': r're:https?://.+',
            'ext': 'mp4',
            'timestamp': 1594183735,
            'upload_date': '20200708',
            'uploader_id': '闇夜乃皇帝',
            'duration': 313075,
            'track': 'Battery (Live)',
            'artist': 'Metallica',
        }
    }]

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

        metadata = self._parse_json(
            self._html_search_regex(r'window\.__reflectData\s*=\s*([^;]+)', webpage, 'metadata'), video_id)

        video_info = try_get(metadata, lambda x: x['collectionMedia'][0]) or {}
        media_data = self._download_json(
            'https://api.gopro.com/media/%s/download' % video_info.get('id'), video_id)

        formats = []
        for fmt in try_get(media_data, lambda x: x['_embedded']['variations']) or []:
            format_url = url_or_none(fmt.get('url'))
            if not format_url:
                continue
            formats.append({
                'url': format_url,
                'format_id': str_or_none(fmt.get('quality')),
                'format_note': str_or_none(fmt.get('label')),
                'ext': str_or_none(fmt.get('type')),
                'width': int_or_none(fmt.get('width')),
                'height': int_or_none(fmt.get('height')),
            })

        self._sort_formats(formats)

        title = str_or_none(
            try_get(metadata, lambda x: x['collection']['title'])
            or self._html_search_meta(['og:title', 'twitter:title'], webpage)
            or remove_end(self._html_search_regex(
                r'<title[^>]*>([^<]+)</title>', webpage, 'title'), ' | GoPro'))
        if title:
            title = title.replace('\n', ' ')


Review comment (suggestion):
```suggestion
        video_info = metadata['collectionMedia'][0]
        media_data = self._download_json(
            'https://api.gopro.com/media/%s/download' % video_info['id'], video_id)
```
If you are trying to make this non-fatal (to work with --ignore-no-formats-error), you need to make sure the download_json is also non-fatal. Otherwise, no reason to use try_get/.get here

Code after:
    }, {
        'url': 'https://gopro.com/v/kVrK9wlJvBMwn',
        'info_dict': {
            'id': 'kVrK9wlJvBMwn',
            'title': 'DARKNESS',
            'thumbnail': r're:https?://.+',
            'ext': 'mp4',
            'timestamp': 1594183735,
            'upload_date': '20200708',
            'uploader_id': '闇夜乃皇帝',
            'duration': 313075,
            'track': 'Battery (Live)',
            'artist': 'Metallica',
        }
    }]

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

        metadata = self._parse_json(
            self._html_search_regex(r'window\.__reflectData\s*=\s*([^;]+)', webpage, 'metadata'), video_id)

        video_info = metadata['collectionMedia'][0]
        media_data = self._download_json(
            'https://api.gopro.com/media/%s/download' % video_info['id'], video_id)

        formats = []
        for fmt in try_get(media_data, lambda x: x['_embedded']['variations']) or []:
            format_url = url_or_none(fmt.get('url'))
            if not format_url:
                continue
            formats.append({
                'url': format_url,
                'format_id': str_or_none(fmt.get('quality')),
                'format_note': str_or_none(fmt.get('label')),
                'ext': str_or_none(fmt.get('type')),
                'width': int_or_none(fmt.get('width')),
                'height': int_or_none(fmt.get('height')),
            })

        self._sort_formats(formats)

        title = str_or_none(
            try_get(metadata, lambda x: x['collection']['title'])
            or self._html_search_meta(['og:title', 'twitter:title'], webpage)
            or remove_end(self._html_search_regex(
                r'<title[^>]*>([^<]+)</title>', webpage, 'title', fatal=False), ' | GoPro'))
        if title:
            title = title.replace('\n', ' ')