py3-pinterest icon indicating copy to clipboard operation
py3-pinterest copied to clipboard

KeyError: 'resources'

Open drzraf opened this issue 3 years ago • 1 comments

Using py3-pinterest==1.2.2

pinterest = Pinterest(cred_root='.session')
x = pinterest.load_pin(pin_id='415668240589074484')
Traceback (most recent call last):
  File "./script.py", line 10, in <module>
    x = pinterest.load_pin(pin_id='415668240589074484')
  File "/home/xxx/local/lib/python3.8/site-packages/py3pin/Pinterest.py", line 527, in load_pin
    pinJsonData = json.loads(s.contents[0])['resources']['data']['PinResource']
KeyError: 'resources'

s.contents[0] actually looks like:

{
  "rebuildStoreOnClient": true,
  "resourceResponses": [
    {
      "name": "PinResource",
      "options": {
        "bookmarks": [
          "-end-"
        ],
        "id": "415668240589074484",
        "field_set_key": "unauth_react_main_pin",
        "get_page_metadata": "seo"
      },
      "response": {
        "status": "success",
        "code": 0,
        "data": {
          "is_eligible_for_aggregated_comments": true,
          "type": "pin",
          "buyable_product_availability": null,
          "is_promotable": true,
          "title": "",
          "description": " ",
          "comments_disabled": false,
          "url_with_text": "/pin/415668240589074484/",
          "click_through_link_quality": null,
          "image_signature": "d87a2449bb7411a1fb008b2bdf148ec2",
          "closeup_description": "via",
          "price_currency": "USD",
          "board": {
            "image_cover_url": "https://i.pinimg.com/200x150/1b/1e/c7/1b1ec7f9fc41793bfa077821d255d41e.jpg",
            "description": "",
            "type": "board",
            "layout": "default",
            "map_id": "pinterest.ijz1714i",
[...]
            "product_pin_data": null,
            "native_creator": null,
            "video_status_message": null,
            "shopping_flags": [],
            "tracking_params": "CwABAAAAEDYxNTU5NDU2NDgyMTI5MzgGAAMABwA",
            "repin_count": 9,
            "created_at": "Fri, 01 Aug 2014 17:05:23 +0000",
            "domain": "flickr.com",
            "closeup_unified_description": "peacocksgarden.blogspot.com/ Evan Wilson"
          }
        ],
        "message": "ok",
        "endpoint_name": "v3_related_pins_for_pin_seo",
        "bookmark": "Pz9DZ0FCQUFBQmQvQzVTYzBJQUFJQUFBQU1BZ0FFQUFBPXw3MzQ1NTU1MTQ3YjhiNGJkZGE0NzRhODdhOTRjOTg5ZTYxODE1MTFmYWQwOTJkM2ViMDZlMTdmMGFkMTY5NTg2fE5FV3w=",
        "http_status": 200
      },
      "nextBookmark": "Pz9DZ0FCQUFBQmQvQzVTYzBJQUFJQUFBQU1BZ0FFQUFBPXw3MzQ1NTU1MTQ3YjhiNGJkZGE0NzRhODdhOTRjOTg5ZTYxODE1MTFmYWQwOTJkM2ViMDZlMTdmMGFkMTY5NTg2fE5FV3w="
    },
    {
      "name": "TrendingQueriesResource",
      "options": {
        "bookmarks": []
      },
      "response": {
        "status": "success",
        "code": 0,
        "data": [],
        "message": "ok",
        "endpoint_name": "v3_search_trending_queries_handler",
        "http_status": 200
      }
    }
  ],
  "routeData": {
    "name": "UnauthPinPage",
    "upwtActionName": 113
  }
}

Am I doing something wrong or is has JSON format changed?

drzraf avatar Mar 02 '21 02:03 drzraf

try using the latest version of the py3pin

bstoilov avatar May 03 '22 16:05 bstoilov