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

Code before:
            'duration': 8559.0,
            'tags': list,
            'thumbnail': 're:^https?://media.livr.jp/vod/img/.*$',
        },
        'skip': 'Premium channel subscribers only',
    }, {
        # Accessible only in the VR SQUARE app
        'url': 'https://livr.jp/contents/P126481458',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        status = self._download_json(
            f'{self._BASE_URL}/webApi/contentsStatus/{video_id}',
            video_id, 'Checking contents status', fatal=False)
        if traverse_obj(status, 'result_code') == '40407':
            self.raise_login_required('Unable to access this video')

        try:
            web_api = self._download_json(
                f'{self._BASE_URL}/webApi/play/url/{video_id}', video_id)
        except ExtractorError as e:
            if isinstance(e.cause, HTTPError) and e.cause.status == 500:
                raise ExtractorError('VR SQUARE app-only videos are not supported', expected=True)

        return {
            'id': video_id,
            'title': self._html_search_meta(['og:title', 'twitter:title'], webpage),
            'description': self._html_search_meta('description', webpage),
            'formats': self._extract_m3u8_formats(traverse_obj(web_api, (
                'urls', ..., 'url', any)), video_id, 'mp4', fatal=False),
            'thumbnail': self._html_search_meta('og:image', webpage),
            **traverse_obj(webpage, {
                'duration': ({find_element(cls='layout-product-data-time')}, {parse_duration}),
                'tags': ({find_elements(cls='search-tag')}, ..., {clean_html}),
            }),
        }


class VrSquarePlaylistBaseIE(InfoExtractor):
    _BASE_URL = 'https://livr.jp'

    def _fetch_vids(self, source, keys=()):
        return [self.url_result(
            f'{self._BASE_URL}/contents/{x.removeprefix("/contents/")}', VrSquareIE)
            for x in traverse_obj(source, (
                *keys, {find_elements(cls='video', html=True)},
                ..., {extract_attributes}, 'data-url', {str}, filter))
        ]

Review comment (refactor):
```suggestion
        except ExtractorError as e:
            if isinstance(e.cause, HTTPError) and e.cause.status == 500:
                raise ExtractorError('VR SQUARE app-only videos are not supported', expected=True)
            raise
```

Code after:
            'duration': 8559.0,
            'tags': list,
            'thumbnail': r're:https?://media\.livr\.jp/vod/img/.+\.jpg',
        },
        'skip': 'Premium channel subscribers only',
    }, {
        # Accessible only in the VR SQUARE app
        'url': 'https://livr.jp/contents/P126481458',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        status = self._download_json(
            f'{self._BASE_URL}/webApi/contentsStatus/{video_id}',
            video_id, 'Checking contents status', fatal=False)
        if traverse_obj(status, 'result_code') == '40407':
            self.raise_login_required('Unable to access this video')

        try:
            web_api = self._download_json(
                f'{self._BASE_URL}/webApi/play/url/{video_id}', video_id)
        except ExtractorError as e:
            if isinstance(e.cause, HTTPError) and e.cause.status == 500:
                raise ExtractorError('VR SQUARE app-only videos are not supported', expected=True)
            raise

        return {
            'id': video_id,
            'title': self._html_search_meta(['og:title', 'twitter:title'], webpage),
            'description': self._html_search_meta('description', webpage),
            'formats': self._extract_m3u8_formats(traverse_obj(web_api, (
                'urls', ..., 'url', any)), video_id, 'mp4', fatal=False),
            'thumbnail': self._html_search_meta('og:image', webpage),
            **traverse_obj(webpage, {
                'duration': ({find_element(cls='layout-product-data-time')}, {parse_duration}),
                'tags': ({find_elements(cls='search-tag')}, ..., {clean_html}),
            }),
        }


class VrSquarePlaylistBaseIE(InfoExtractor):
    _BASE_URL = 'https://livr.jp'

    def _fetch_vids(self, source, keys=()):
        for url_path in traverse_obj(source, (
            *keys, {find_elements(cls='video', html=True)}, ...,
            {extract_attributes}, 'data-url', {str}, filter),
        ):
            yield self.url_result(