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

Code before:
            'upload_date': '20101020',
            'thumbnail': 'https://s1.dmcdn.net/v/SaMes1WfAm1d6maq_/x720',
            'uploader': 'Moviepilot',
            'like_count': int,
            'view_count': int,
            'tags': ['Alle Trailer', 'Movie', 'Verleih'],
            'uploader_id': 'x6nd9k',
        },
    }]

    def _get_property(self, name, webpage, fatal=True):
        return self._search_regex(f'meta itemprop="{name}" content="(.*?)"', webpage, name, fatal=fatal)

    def _real_extract(self, url):
        video_id = self._match_id(url)

        webpage = self._download_webpage(f'https://www.moviepilot.de/movies/{video_id}/trailer', video_id)

        # oriented on parse_duration()
        d = re.match(r'P(?P<hours>[0-9]+)H(?P<mins>[0-9]{2})M(?P<secs>[0-9]{2})S',
                     self._get_property("duration", webpage, fatal=False))
        if d:
            hours, mins, secs = d.groups()
            duration = float(hours) * 60 * 60 + float(mins) * 60 + float(secs)
        else:
            duration = None

        return {
            '_type': 'url_transparent',
            'ie_key': DailymotionIE.ie_key(),
            'display_id': video_id,
            'title': self._og_search_title(webpage),
            'url': self._get_property('embedURL', webpage),
            'thumbnail': self._get_property('thumbnailURL', webpage, fatal=False),
            'description': unescapeHTML(self._get_property('description', webpage, fatal=False)),
            'duration': duration,
            'timestamp': parse_iso8601(self._get_property('uploadDate', webpage, fatal=False), delimiter=' ')
        }


Review comment (suggestion):
```suggestion
        duration = try_get(
            re.match(r'P(?P<hours>\d+)H(?P<mins>\d+)M(?P<secs>\d+)S',
                     self._html_search_meta('duration', webpage, fatal=False) or ''),
            lambda mobj: sum(float(x) * y for x, y in zip(mobj.groups(), (3600, 60, 1))))
```
(can be split into 2 expressions if u think it's too complicated)

Code after:
            'upload_date': '20101020',
            'thumbnail': r're:https://\w+\.dmcdn\.net/v/SaMes1WfAm1d6maq_/x720',
            'uploader': 'Moviepilot',
            'like_count': int,
            'view_count': int,
            'tags': ['Alle Trailer', 'Movie', 'Verleih'],
            'uploader_id': 'x6nd9k',
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)

        webpage = self._download_webpage(f'https://www.moviepilot.de/movies/{video_id}/trailer', video_id)

        duration = try_get(
            re.match(r'P(?P<hours>\d+)H(?P<mins>\d+)M(?P<secs>\d+)S',
                     self._html_search_meta('duration', webpage, fatal=False) or ''),
            lambda mobj: sum(float(x) * y for x, y in zip(mobj.groups(), (3600, 60, 1))))
        # _html_search_meta is not used since we don't want name=description to match
        description = self._html_search_regex(
            '<meta[^>]+itemprop="description"[^>]+content="([^>"]+)"', webpage, 'description', fatal=False)

        return {
            '_type': 'url_transparent',
            'ie_key': DailymotionIE.ie_key(),
            'display_id': video_id,
            'title': self._og_search_title(webpage),
            'url': self._html_search_meta('embedURL', webpage),
            'thumbnail': self._html_search_meta('thumbnailURL', webpage),
            'description': description,
            'duration': duration,
            'timestamp': parse_iso8601(self._html_search_meta('uploadDate', webpage), delimiter=' ')
        }