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

Code before:
# coding: utf-8
from __future__ import unicode_literals

from .common import InfoExtractor


class ManotoTVIE(InfoExtractor):
    IE_NAME = 'Manoto TV (Episode)'
    _VALID_URL = r'https?://(?:www\.)?manototv\.com/episode/(?P<id>[0-9]+)'
    _TEST = {
        'url': 'https://www.manototv.com/episode/12576',
        'info_dict': {
            'id': '12576',
            'title': 'Seh Mah Taatili',
            'description': 'مجموعه ای از فیلم های سینمای کلاسیک ایران',
            'thumbnail': r're:^https?://.*\.jpeg$',
            'ext': 'm3u8',
        }
    }

    def _real_extract(self, url):
        video_id = self._match_id(url)
        episode_json = self._download_json('https://dak1vd5vmi7x6.cloudfront.net/api/v1/publicrole/showmodule/episodedetails?id=' + video_id, video_id)
        details = episode_json.get('details', {})
        title = details.get('analyticsEpisodeTitle')
        video_url = details.get('videoM3u8Url')
        description = details.get('showSynopsis')
        thumbnail = details.get('episodelandscapeImgIxUrl')
        ext = 'm3u8'
        formats = self._extract_m3u8_formats(video_url, video_id, ext)
        return {
            'id': video_id,
            'title': title,
            'description': description,
            'thumbnail': thumbnail,
            'ext': ext,
            'formats': formats,
        }


class ManotoTVShowIE(InfoExtractor):
    IE_NAME = 'Manoto TV (Show)'
    _VALID_URL = r'https?://(?:www\.)?manototv\.com/show/(?P<id>[0-9]+)'
    _TESTS = [{
        'url': 'https://www.manototv.com/show/2526',
        'playlist_mincount': 68,
        'info_dict': {
            'id': '2526',

Review comment (refactor):
I see the same api url being repeated. do this isnstead
```py
_API_URL = 'https://dak1vd5vmi7x6.cloudfront.net/api/v1/publicrole/showmodule/{}?id={}'
def _real_extract(self, url):
    ...
    self._download_json(self._API_URL.format('episodedetails', video_id), video_id)
```

Code after:
# coding: utf-8
from __future__ import unicode_literals

from .common import InfoExtractor
from ..utils import (
    clean_html,
    int_or_none,
    traverse_obj
)


_API_URL = 'https://dak1vd5vmi7x6.cloudfront.net/api/v1/publicrole/{}/{}?id={}'


class ManotoTVIE(InfoExtractor):
    IE_DESC = 'Manoto TV (Episode)'
    _VALID_URL = r'https?://(?:www\.)?manototv\.com/episode/(?P<id>[0-9]+)'
    _TESTS = [{
        'url': 'https://www.manototv.com/episode/8475',
        'info_dict': {
            'id': '8475',
            'series': 'خانه های رویایی با برادران اسکات',
            'season_number': 7,
            'episode_number': 25,
            'episode_id': 'My Dream Home S7: Carol & John',
            'duration': 3600,
            'categories': ['سرگرمی'],
            'title': 'کارول و جان',
            'description': 'md5:d0fff1f8ba5c6775d312a00165d1a97e',
            'thumbnail': r're:^https?://.*\.(jpeg|png|jpg)$',
            'ext': 'mp4'
        },
        'params': {
            'skip_download': 'm3u8',
        }
    }, {
        'url': 'https://www.manototv.com/episode/12576',
        'info_dict': {
            'id': '12576',
            'series': 'فیلم های ایرانی',
            'episode_id': 'Seh Mah Taatili',
            'duration': 5400,
            'view_count': int,
            'categories': ['سرگرمی'],
            'title': 'سه ماه تعطیلی',
            'description': 'سه ماه تعطیلی فیلمی به کارگردانی و نویسندگی شاپور قریب ساختهٔ سال ۱۳۵۶ است.',
            'thumbnail': r're:^https?://.*\.(jpeg|png|jpg)$',
            'ext': 'mp4'