summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/pinterest.py
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/extractor/pinterest.py')
-rw-r--r--yt_dlp/extractor/pinterest.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/yt_dlp/extractor/pinterest.py b/yt_dlp/extractor/pinterest.py
index 8361fbb..07f2494 100644
--- a/yt_dlp/extractor/pinterest.py
+++ b/yt_dlp/extractor/pinterest.py
@@ -22,9 +22,9 @@ class PinterestBaseIE(InfoExtractor):
def _call_api(self, resource, video_id, options):
return self._download_json(
- 'https://www.pinterest.com/resource/%sResource/get/' % resource,
- video_id, 'Download %s JSON metadata' % resource, query={
- 'data': json.dumps({'options': options})
+ f'https://www.pinterest.com/resource/{resource}Resource/get/',
+ video_id, f'Download {resource} JSON metadata', query={
+ 'data': json.dumps({'options': options}),
})['resource_response']
def _extract_video(self, data, extract_formats=True):
@@ -32,7 +32,7 @@ class PinterestBaseIE(InfoExtractor):
thumbnails = []
images = data.get('images')
if isinstance(images, dict):
- for thumbnail_id, thumbnail in images.items():
+ for thumbnail in images.values():
if not isinstance(thumbnail, dict):
continue
thumbnail_url = url_or_none(thumbnail.get('url'))
@@ -109,7 +109,7 @@ class PinterestBaseIE(InfoExtractor):
class PinterestIE(PinterestBaseIE):
- _VALID_URL = r'%s/pin/(?P<id>\d+)' % PinterestBaseIE._VALID_URL_BASE
+ _VALID_URL = rf'{PinterestBaseIE._VALID_URL_BASE}/pin/(?P<id>\d+)'
_TESTS = [{
# formats found in data['videos']
'url': 'https://www.pinterest.com/pin/664281013778109217/',
@@ -187,7 +187,7 @@ class PinterestIE(PinterestBaseIE):
class PinterestCollectionIE(PinterestBaseIE):
- _VALID_URL = r'%s/(?P<username>[^/]+)/(?P<id>[^/?#&]+)' % PinterestBaseIE._VALID_URL_BASE
+ _VALID_URL = rf'{PinterestBaseIE._VALID_URL_BASE}/(?P<username>[^/]+)/(?P<id>[^/?#&]+)'
_TESTS = [{
'url': 'https://www.pinterest.ca/mashal0407/cool-diys/',
'info_dict': {
@@ -207,15 +207,14 @@ class PinterestCollectionIE(PinterestBaseIE):
@classmethod
def suitable(cls, url):
- return False if PinterestIE.suitable(url) else super(
- PinterestCollectionIE, cls).suitable(url)
+ return False if PinterestIE.suitable(url) else super().suitable(url)
def _real_extract(self, url):
username, slug = self._match_valid_url(url).groups()
board = self._call_api(
'Board', slug, {
'slug': slug,
- 'username': username
+ 'username': username,
})['data']
board_id = board['id']
options = {