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

Code before:
                            elif mrr_title == 'Song':
                                info['track'] = mrr_contents_text

        fallbacks = {
            'channel': 'uploader',
            'channel_id': 'uploader_id',
            'channel_url': 'uploader_url',
        }
        for to, frm in fallbacks.items():
            if not info.get(to):
                info[to] = info.get(frm)

        for s_k, d_k in [('artist', 'creator'), ('track', 'alt_title')]:
            v = info.get(s_k)
            if v:
                info[d_k] = v

        is_private = bool_or_none(video_details.get('isPrivate'))
        is_unlisted = bool_or_none(microformat.get('isUnlisted'))
        is_membersonly = None
        is_premium = None
        if initial_data and is_private is not None:
            is_membersonly = False
            is_premium = False
            contents = try_get(initial_data, lambda x: x['contents']['twoColumnWatchNextResults']['results']['results']['contents'], list) or []
            badge_lbls = set()
            for content in contents:
                if not isinstance(content, dict):
                    continue
                badge_lbls.update(self._extract_badges(content.get('videoPrimaryInfoRenderer')))
            for badge_lbl in badge_lbls:
                if badge_lbl.lower() == 'members only':
                    is_membersonly = True
                elif badge_lbl.lower() == 'premium':
                    is_premium = True
                elif badge_lbl.lower() == 'unlisted':
                    is_unlisted = True

        info['availability'] = self._availability(
            is_private=is_private,
            needs_premium=is_premium,
            needs_subscription=is_membersonly,
            needs_auth=info['age_limit'] >= 18,
            is_unlisted=None if is_private is None else is_unlisted)

        # get xsrf for annotations or comments
        get_annotations = self.get_param('writeannotations', False)
        get_comments = self.get_param('getcomments', False)
        if get_annotations or get_comments:
            xsrf_token = None
            ytcfg = self._extract_ytcfg(video_id, webpage)

Review comment (refactor):
Took me way too long to realize what `badge_lbls` means. might wanna consider `badge_labels`

Code after:
                            elif mrr_title == 'Song':
                                info['track'] = mrr_contents_text

        fallbacks = {
            'channel': 'uploader',
            'channel_id': 'uploader_id',
            'channel_url': 'uploader_url',
        }
        for to, frm in fallbacks.items():
            if not info.get(to):
                info[to] = info.get(frm)

        for s_k, d_k in [('artist', 'creator'), ('track', 'alt_title')]:
            v = info.get(s_k)
            if v:
                info[d_k] = v

        is_private = bool_or_none(video_details.get('isPrivate'))
        is_unlisted = bool_or_none(microformat.get('isUnlisted'))
        is_membersonly = None
        is_premium = None
        if initial_data and is_private is not None:
            is_membersonly = False
            is_premium = False
            contents = try_get(initial_data, lambda x: x['contents']['twoColumnWatchNextResults']['results']['results']['contents'], list) or []
            badge_labels = set()
            for content in contents:
                if not isinstance(content, dict):
                    continue
                badge_labels.update(self._extract_badges(content.get('videoPrimaryInfoRenderer')))
            for badge_label in badge_labels:
                if badge_label.lower() == 'members only':
                    is_membersonly = True
                elif badge_label.lower() == 'premium':
                    is_premium = True
                elif badge_label.lower() == 'unlisted':
                    is_unlisted = True

        info['availability'] = self._availability(
            is_private=is_private,
            needs_premium=is_premium,
            needs_subscription=is_membersonly,
            needs_auth=info['age_limit'] >= 18,
            is_unlisted=None if is_private is None else is_unlisted)

        # get xsrf for annotations or comments
        get_annotations = self.get_param('writeannotations', False)
        get_comments = self.get_param('getcomments', False)
        if get_annotations or get_comments:
            xsrf_token = None
            ytcfg = self._extract_ytcfg(video_id, webpage)