[pinterest] remove excess whitespace from 'description' fields (#4335)

and 'closeup_unified_description' & 'closeup_description'
This commit is contained in:
Mike Fährmann
2025-06-13 13:09:03 +02:00
parent 9afac3c51d
commit 9d3cf67f3e
2 changed files with 21 additions and 0 deletions

View File

@@ -55,6 +55,15 @@ class PinterestExtractor(Extractor):
pin.update(data)
pin["count"] = len(files)
for key in (
"description",
"closeup_description",
"closeup_unified_description",
):
value = pin.get(key)
if value:
pin[key] = value.strip()
yield Message.Directory, pin
for pin["num"], file in enumerate(files, 1):
url = file["url"]

View File

@@ -13,6 +13,7 @@ __tests__ = (
"#url" : "https://www.pinterest.com/pin/858146903966145189/",
"#category": ("", "pinterest", "pin"),
"#class" : pinterest.PinterestPinExtractor,
"#results" : "https://i.pinimg.com/originals/d4/f4/7f/d4f47fa2fce4c4c28475af5d94972904.jpg",
"#sha1_url" : "afb3c26719e3a530bb0e871c480882a801a4e8a5",
"#sha1_content": [
"4c435a66f6bb82bb681db2ecc888f76cf6c5f9ca",
@@ -79,6 +80,17 @@ __tests__ = (
"#comment" : "story pin with 'story_pin_product_sticker_block' blocks (#7563)",
"#class" : pinterest.PinterestPinExtractor,
"#results" : "https://i.pinimg.com/originals/3e/0a/2e/3e0a2e6c1173866c530c8ffe18d08b9f.jpg",
"#exception": exception.NotFoundError,
},
{
"#url" : "https://pinterest.com/pin/725220346239561090/",
"#comment" : "stripped 'description' & 'closeup_unified_description' (#4335)",
"#class" : pinterest.PinterestPinExtractor,
"#results" : "https://i.pinimg.com/originals/66/a3/9a/66a39a10c015df67b85481105fb3a81e.jpg",
"description": "",
"closeup_unified_description": "",
},
{