Skip to content

Commit

Permalink
[pinterest] detect video/audio by block content (#6421)
Browse files Browse the repository at this point in the history
story blocks from search/board results do not always contain a 'type'
  • Loading branch information
mikf committed Nov 5, 2024
1 parent a9a9f3a commit ce90566
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions gallery_dl/extractor/pinterest.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ def _extract_story(self, pin, story):
else:
media = self._extract_image(page, block)

elif type == "story_pin_video_block":
elif type == "story_pin_video_block" or "video" in block:
video = block["video"]
media = self._extract_video(video)
media["media_id"] = video.get("id") or ""

elif type == "story_pin_music_block":
elif type == "story_pin_music_block" or "audio" in block:
media = block["audio"]
media["url"] = media["audio_url"]
media["media_id"] = media.get("id") or ""
Expand All @@ -135,7 +135,10 @@ def _extract_story(self, pin, story):
else:
self.log.warning("%s: Unsupported story block '%s'",
pin.get("id"), type)
continue
try:
media = self._extract_image(page, block)
except Exception:
continue

media["story_id"] = story_id
media["page_id"] = page_id
Expand Down

0 comments on commit ce90566

Please sign in to comment.