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

Code before:
        video_info_jsonp = self._download_webpage(
            f'https://{publisher}.eq.webcdn.stream.ne.jp/{host}/{publisher}/jmc_pub/eq_meta/v1/{mid}.jsonp',
            video_id, 'Requesting video info')
        video_info = self._parse_jsonp('metaDataResult', video_info_jsonp, video_id)['movie']
        subtitles = {}
        formats = list(self._find_formats(video_id, video_info.get('movie_list_hls'), host, publisher, subtitles))
        self._remove_duplicate_formats(formats)
        return {
            'id': video_id,
            'title': video_info.get('title'),
            'duration': float_or_none(video_info.get('duration')),
            'thumbnail': video_info.get('thumbnail_url'),
            'formats': formats,
            'subtitles': subtitles,
        }

    @classmethod
    def _extract_embed_urls(cls, url, webpage):
        # check for eligiblity of webpage
        # https://support.eq.stream.co.jp/hc/ja/articles/115008388147-%E3%83%97%E3%83%AC%E3%82%A4%E3%83%A4%E3%83%BCAPI%E3%81%AE%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E3%82%B3%E3%83%BC%E3%83%89
        script_tag = re.search(r'<script\s*.+?src="https://ssl-cache\.stream\.ne\.jp/(?P<host>www\d+)/(?P<publisher>[a-z0-9]+)/[^"]+?/if\.js"', webpage)
        if not script_tag:
            return
        host, publisher = script_tag.groups()
        for m in re.finditer(r'(?s)PlayerFactoryIF\.create\(\s*({.+?})\s*\)\s*;', webpage):
            # using json.loads here as InfoExtractor._parse_json is not classmethod
            info = json.loads(js_to_json(m.group(1)))
            mid = base64.b64decode(info.get('m')).decode()
            yield f'jstream:{host}:{publisher}:{mid}'


Review comment (refactor):
```suggestion
            # TODO: using json.loads here as InfoExtractor._parse_json is not classmethod
```

Code after:
        video_info_jsonp = self._download_webpage(
            f'https://{publisher}.eq.webcdn.stream.ne.jp/{host}/{publisher}/jmc_pub/eq_meta/v1/{mid}.jsonp',
            video_id, 'Requesting video info')
        video_info = self._parse_jsonp('metaDataResult', video_info_jsonp, video_id)['movie']
        subtitles = {}
        formats = list(self._find_formats(video_id, video_info.get('movie_list_hls'), host, publisher, subtitles))
        self._remove_duplicate_formats(formats)
        return {
            'id': video_id,
            'title': video_info.get('title'),
            'duration': float_or_none(video_info.get('duration')),
            'thumbnail': video_info.get('thumbnail_url'),
            'formats': formats,
            'subtitles': subtitles,
        }

    @classmethod
    def _extract_embed_urls(cls, url, webpage):
        # check for eligiblity of webpage
        # https://support.eq.stream.co.jp/hc/ja/articles/115008388147-%E3%83%97%E3%83%AC%E3%82%A4%E3%83%A4%E3%83%BCAPI%E3%81%AE%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E3%82%B3%E3%83%BC%E3%83%89
        script_tag = re.search(r'<script\s*[^>]+?src="https://ssl-cache\.stream\.ne\.jp/(?P<host>www\d+)/(?P<publisher>[a-z0-9]+)/[^"]+?/if\.js"', webpage)
        if not script_tag:
            return
        host, publisher = script_tag.groups()
        for m in re.finditer(r'(?s)PlayerFactoryIF\.create\(\s*({[^\}]+?})\s*\)\s*;', webpage):
            # TODO: using json.loads here as InfoExtractor._parse_json is not classmethod
            info = json.loads(js_to_json(m.group(1)))
            mid = base64.b64decode(info.get('m')).decode()
            yield f'jstream:{host}:{publisher}:{mid}'