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

Code before:
        }
    }, {
        'url': 'https://2m.ma/fr/replay/single/635c0aeab4eec832622356da',
        'info_dict': {
            'id': '635c0aeab4eec832622356da',
            'ext': 'mp4',
            'title': 'Journal  Amazigh : Vendredi 28 Octobre 2022',
            'thumbnail': 'https://2msoread-ww.amagi.tv/mediasfiles/videos/images/2022/10/28/16669764903.png'
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        info = self._download_json(
            'https://2m.ma/api/watchDetail/%s' % (video_id),
            video_id, "Downloading media JSON") or {}
        video = traverse_obj(info, ('response', 'News'))
        title = video.get('titre')
        thumbnail = url_or_none(video.get('image'))
        return {
            'id': video_id,
            'title': title,
            'url': video.get('url'),
            'description': video.get('description'),
            'thumbnail': thumbnail
        }


class DeuxMNewsIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?2m\.ma/[^/]+/news/(?P<id>(?:.)+)'

    _TESTS = [{
        'url': 'https://2m.ma/fr/news/Sahara-la-r%C3%A9solution-2654-de-l-ONU-une-confirmation-de-l-appui-%C3%A0-l-initiative-d-autonomie-Vid%C3%A9o--20221028',
        'info_dict': {
            'id': '635c4aad346a31673b1aaec3',
            'ext': 'mp4',
            'title': 'Sahara : la r\u00e9solution 2654 de l\u0027ONU, une confirmation de l\u0027appui \u00e0 l\u0027initiative d\u0027autonomie (Vid\u00e9o)',
            'description': 'md5:a240fb360871e6ffd37e1fadd813e42c',
            'thumbnail': 'https://2msoread-ww.amagi.tv/mediasfiles/videos/images/2022/10/28/16669845857-1.png'
        }
    }, {
        'url': 'https://2m.ma/fr/news/La-3%C3%A8me-conf%C3%A9rence-des-MD-Talks-Des-Ambassadeurs-et-des-Consuls-louent-le-potentiel-%C3%A9nerg%C3%A9tique-de-la-r%C3%A9gion-de-Guelmim-Oued-Noun--20221022',
        'info_dict': {
            'id': '635405760ed0533c940e7e82',
            'ext': 'mp4',
            'title': 'MD Talks: Des diplomates louent le potentiel \u00e9nerg\u00e9tique de la r\u00e9gion de Guelmim-Oued Noun ',
            'thumbnail': 'https://2msoread-ww.amagi.tv/mediasfiles/videos/images/2022/10/22/16664504981-Reportage---MD-TALKS.png'
        }
    }]

    def _real_extract(self, url):

Review comment (suggestion):
```suggestion
        video = self._download_json(
            f'https://2m.ma/api/watchDetail/{video_id}', video_id)['response']['News']
        return {
            'id': video_id,
            'title': video.get('titre'),
            'url': video['url'],
            'description': video.get('description'),
            'thumbnail': url_or_none(video.get('image')),
        }
```

Code after:
        'url': 'https://2m.ma/fr/replay/single/635c0aeab4eec832622356da',
        'md5': 'ad6af2f5e4d5b2ad2194a84b6e890b4c',
        'info_dict': {
            'id': '635c0aeab4eec832622356da',
            'ext': 'mp4',
            'title': 'Journal  Amazigh : Vendredi 28 Octobre 2022',
            'thumbnail': r're:^https?://2msoread-ww.amagi.tv/mediasfiles/videos/images/.*\.png$'
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        video = self._download_json(
            f'https://2m.ma/api/watchDetail/{video_id}', video_id)['response']['News']
        return {
            'id': video_id,
            'title': video.get('titre'),
            'url': video['url'],
            'description': video.get('description'),
            'thumbnail': url_or_none(video.get('image')),
        }


class DeuxMNewsIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?2m\.ma/(?P<lang>\w+)/news/(?P<id>[^/#?]+)'

    _TESTS = [{
        'url': 'https://2m.ma/fr/news/Kan-Ya-Mkan-d%C3%A9poussi%C3%A8re-l-histoire-du-phare-du-Cap-Beddouza-20221028',
        'md5': '43d5e693a53fa0b71e8a5204c7d4542a',
        'info_dict': {
            'id': '635c5d1233b83834e35b282e',
            'ext': 'mp4',
            'title': 'Kan Ya Mkan d\u00e9poussi\u00e8re l\u2019histoire du phare du Cap Beddouza',
            'description': 'md5:99dcf29b82f1d7f2a4acafed1d487527',
            'thumbnail': r're:^https?://2msoread-ww.amagi.tv/mediasfiles/videos/images/.*\.png$'
        }
    }, {
        'url': 'https://2m.ma/fr/news/Interview-Casablanca-hors-des-sentiers-battus-avec-Abderrahim-KASSOU-Replay--20221017',
        'md5': '7aca29f02230945ef635eb8290283c0c',
        'info_dict': {
            'id': '634d9e108b70d40bc51a844b',
            'ext': 'mp4',
            'title': 'Interview: Casablanca hors des sentiers battus avec Abderrahim KASSOU (Replay) ',
            'description': 'md5:3b8e78111de9fcc6ef7f7dd6cff2430c',
            'thumbnail': r're:^https?://2msoread-ww.amagi.tv/mediasfiles/videos/images/.*\.png$'
        }
    }]

    def _real_extract(self, url):
        article_name, lang = self._match_valid_url(url).group('id', 'lang')
        video = self._download_json(