X-Git-Url: https://jfr.im/git/yt-dlp.git/blobdiff_plain/7a5c1cfe93924351387b44919b3c0b2f66c4b883..9f14daf22b4080ae1531a772ee7574959af4e2fa:/yt_dlp/extractor/pinterest.py diff --git a/yt_dlp/extractor/pinterest.py b/yt_dlp/extractor/pinterest.py index 15c11a755..2c6cd6d4b 100644 --- a/yt_dlp/extractor/pinterest.py +++ b/yt_dlp/extractor/pinterest.py @@ -1,8 +1,4 @@ -# coding: utf-8 -from __future__ import unicode_literals - import json -import re from .common import InfoExtractor from ..compat import compat_str @@ -31,6 +27,7 @@ def _extract_video(self, data, extract_formats=True): title = (data.get('title') or data.get('grid_title') or video_id).strip() + urls = [] formats = [] duration = None if extract_formats: @@ -38,8 +35,9 @@ def _extract_video(self, data, extract_formats=True): if not isinstance(format_dict, dict): continue format_url = url_or_none(format_dict.get('url')) - if not format_url: + if not format_url or format_url in urls: continue + urls.append(format_url) duration = float_or_none(format_dict.get('duration'), scale=1000) ext = determine_ext(format_url) if 'hls' in format_id.lower() or ext == 'm3u8': @@ -54,7 +52,6 @@ def _extract_video(self, data, extract_formats=True): 'height': int_or_none(format_dict.get('height')), 'duration': duration, }) - self._sort_formats(formats) description = data.get('description') or data.get('description_html') or data.get('seo_description') timestamp = unified_timestamp(data.get('created_at')) @@ -163,7 +160,7 @@ def suitable(cls, url): PinterestCollectionIE, cls).suitable(url) def _real_extract(self, url): - username, slug = re.match(self._VALID_URL, url).groups() + username, slug = self._match_valid_url(url).groups() board = self._call_api( 'Board', slug, { 'slug': slug,