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

Code before:
            'title': 'Competitive Equity  - 01/21/2015',
            # 'url': 'https://cfhls.nfhsnetwork.com/121689/121689.m3u8',
            'description': 'Committee members discuss points of their research regarding a competitive equity plan',
            'uploader': 'WIAA - Wisconsin: Wisconsin Interscholastic Athletic Association',
            'location': 'Stevens Point, Wisconsin',
            'timestamp': 1421856000,
            'upload_date': '20150121'
        },
        'params': {
            # m3u8 download
            'skip_download': True,
        }
    }
    ]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        data = self._download_json(
            'https://cfunity.nfhsnetwork.com/v2/game_or_event/' + video_id,
            video_id)
        publisher = data.get('publishers')[0]  # always exists
        broadcast = (publisher.get('broadcasts') or publisher.get('vods'))[0]  # some (older) videos don't have a broadcasts object
        uploader = publisher.get('formatted_name') or publisher.get('name') or ''
        location = data.get('city') + ', ' + data.get('state_name')
        description = broadcast.get('description') or ''
        isLive = broadcast.get('on_air') or broadcast.get('status') == 'on_air' or False

        timestamp = unified_timestamp(data.get('local_start_time'))
        upload_date = unified_strdate(data.get('local_start_time'))

        title = self._og_search_title(webpage) or self._html_search_regex(r'<h1 class="sr-hidden">(.*?)</h1>', webpage, 'title')
        title = title[:title.find('|') - 1]

        if broadcast.get('status') == 'complete':
            m3u8_url = self._download_json('https://cfunity.nfhsnetwork.com/v2/vods/' + broadcast.get('key') + '/url', video_id)
        else:
            m3u8_url = self._download_json('https://cfunity.nfhsnetwork.com/v2/broadcasts/' + broadcast.get('key') + '/url', video_id)

        m3u8_url = m3u8_url.get('video_url')

        formats = []
        formats.extend(self._extract_m3u8_formats(
            m3u8_url, video_id, 'mp4',
            m3u8_id='hls', fatal=False))

        return {
            'id': video_id,
            'title': title,
            'formats': formats,
            'description': description,

Review comment (suggestion):
If key isnt found, it should give `None`, not `''`. Same for uploader

Code after:
            'uploader': 'WIAA - Wisconsin: Wisconsin Interscholastic Athletic Association',
            'uploader_id': 'a49f7d1002',
            'uploader_url': 'https://www.nfhsnetwork.com/associations/wiaa-wi',
            'location': 'Stevens Point, Wisconsin',
            'timestamp': 1421856000,
            'upload_date': '20150121'
        },
        'params': {
            # m3u8 download
            'skip_download': True,
        }
    }
    ]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        data = self._download_json(
            'https://cfunity.nfhsnetwork.com/v2/game_or_event/' + video_id,
            video_id)
        publisher = data.get('publishers')[0]  # always exists
        broadcast = (publisher.get('broadcasts') or publisher.get('vods'))[0]  # some (older) videos don't have a broadcasts object
        uploader = publisher.get('formatted_name') or publisher.get('name')
        uploaderID = publisher.get('publisher_key')
        pubType = publisher.get('type')
        uploaderPrefix = (
            "schools" if pubType == "school"
            else "associations" if "association" in pubType
            else "affiliates" if (pubType == "publisher" or pubType == "affiliate")
            else "schools")
        uploaderPage = 'https://www.nfhsnetwork.com/%s/%s' % (uploaderPrefix, publisher.get('slug'))
        location = '%s, %s' % (data.get('city'), data.get('state_name'))
        description = broadcast.get('description')
        isLive = broadcast.get('on_air') or broadcast.get('status') == 'on_air' or False

        timestamp = unified_timestamp(data.get('local_start_time'))
        upload_date = unified_strdate(data.get('local_start_time'))

        title = (
            self._og_search_title(webpage)
            or self._html_search_regex(r'<h1 class="sr-hidden">(.*?)</h1>', webpage, 'title'))
        title = title.split('|')[0].strip()

        video_type = 'broadcasts' if isLive else 'vods'
        key = broadcast.get('key') if isLive else try_get(publisher, lambda x: x['vods'][0]['key'])
        m3u8_url = self._download_json(
            'https://cfunity.nfhsnetwork.com/v2/%s/%s/url' % (video_type, key),
            video_id).get('video_url')

        formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', live=isLive)
        self._sort_formats(formats, ['res', 'tbr'])