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

Code before:
    _FEED_URL = 'http://www.mtv.it/feeds/triforce/manifest/v8'

    def _get_entries(self, title, url):
        while True:
            pg = re.search(r'/(\d+)$', url)
            pg = pg.group(1) if pg else '1'
            entries = self._download_json(url, title, 'page %s' % pg)
            url = try_get(
                entries, lambda x: x['result']['nextPageURL'], compat_str)
            entries = try_get(
                entries, (
                    lambda x: x['result']['data']['items'],
                    lambda x: x['result']['data']['seasons']),
                list)
            for entry in entries or []:
                if entry.get('canonicalURL'):
                    yield self.url_result(entry['canonicalURL'])
            if not url:
                break

    def _real_extract(self, url):
        query = {'url': url}
        info_url = update_url_query(self._FEED_URL, query)
        video_id = self._match_id(url)
        info = self._download_json(info_url, video_id)
        info = info.get('manifest')

        redirect = try_get(
            info, lambda x: x['newLocation']['url'], compat_str)
        if redirect:
            return self.url_result(redirect)

        title = info.get('title')
        video_id = try_get(
            info, lambda x: x['reporting']['itemId'], compat_str)
        parent_id = try_get(
            info, lambda x: x['reporting']['parentId'], compat_str)

        playlist_url = current_url = None
        zones = info.get('zones') or []
        for z in zones:
            if zones[z].get('moduleName') in {'INTL_M304', 'INTL_M209'}:
                info_url = zones[z].get('feed')
            if zones[z].get('moduleName') in {'INTL_M308', 'INTL_M317'}:
                playlist_url = playlist_url or zones[z].get('feed')
            if zones[z].get('moduleName') in {'INTL_M300'}:
                current_url = current_url or zones[z].get('feed')

        if not info_url:
            raise ExtractorError('No info found')


Review comment (suggestion):
```suggestion
        info = self._download_json(info_url, video_id).get('manifest')
```

Code after:
    _FEED_URL = 'http://www.mtv.it/feeds/triforce/manifest/v8'

    def _get_entries(self, title, url):
        while True:
            pg = self._search_regex(r'/(\d+)$', url, 'entries', '1')
            entries = self._download_json(url, title, 'page %s' % pg)
            url = try_get(
                entries, lambda x: x['result']['nextPageURL'], compat_str)
            entries = try_get(
                entries, (
                    lambda x: x['result']['data']['items'],
                    lambda x: x['result']['data']['seasons']),
                list)
            for entry in entries or []:
                if entry.get('canonicalURL'):
                    yield self.url_result(entry['canonicalURL'])
            if not url:
                break

    def _real_extract(self, url):
        query = {'url': url}
        info_url = update_url_query(self._FEED_URL, query)
        video_id = self._match_id(url)
        info = self._download_json(info_url, video_id).get('manifest')

        redirect = try_get(
            info, lambda x: x['newLocation']['url'], compat_str)
        if redirect:
            return self.url_result(redirect)

        title = info.get('title')
        video_id = try_get(
            info, lambda x: x['reporting']['itemId'], compat_str)
        parent_id = try_get(
            info, lambda x: x['reporting']['parentId'], compat_str)

        playlist_url = current_url = None
        for z in (info.get('zones') or {}).values():
            if z.get('moduleName') in ('INTL_M304', 'INTL_M209'):
                info_url = z.get('feed')
            if z.get('moduleName') in ('INTL_M308', 'INTL_M317'):
                playlist_url = playlist_url or z.get('feed')
            if z.get('moduleName') in ('INTL_M300',):
                current_url = current_url or z.get('feed')

        if not info_url:
            raise ExtractorError('No info found')

        if video_id == parent_id:
            video_id = self._search_regex(
                r'([^\/]+)/[^\/]+$', info_url, 'video_id')