Skip to content

Commit

Permalink
Bug fixes and add pin note
Browse files Browse the repository at this point in the history
  • Loading branch information
b.stoilov committed May 3, 2022
1 parent 1544406 commit 8932e62
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
10 changes: 7 additions & 3 deletions examples.py
Expand Up @@ -14,7 +14,7 @@

# login will obtain and store cookies for further use, they last around 15 days.
# NOTE: Since login will store the cookies in local file you don't need to call it more then 3-4 times a month.
# pinterest.login()
# pinterest.login(headless=True)

def get_user_profile():
return pinterest.get_user_overview(username='username')
Expand Down Expand Up @@ -127,9 +127,10 @@ def pin(board_id='',
image_url='https://i.pinimg.com/170x/32/78/bd/3278bd27073e1ec9c8a708409279768b.jpg',
description='this is auto pin',
title='a bot did this',
alt_text='alt text',
link='https://www.google.com/'):
return pinterest.pin(board_id=board_id, section_id=section_id, image_url=image_url, description=description,
title=title, link=link)
return pinterest.pin(board_id=board_id, section_id=section_id, image_url=image_url,
alt_text=alt_text, description=description, title=title, link=link)


def upload_pin(board_id='',
Expand Down Expand Up @@ -228,3 +229,6 @@ def get_board_section_feed(section_id=''):

def type_ahead(term="apple"):
return pinterest.type_ahead(term=term)

def add_pin_note(pin_id, note='test note'):
pinterest.add_pin_note(pin_id=pin_id, note=note)
21 changes: 19 additions & 2 deletions py3pin/Pinterest.py
Expand Up @@ -109,6 +109,7 @@
)
UPLOAD_IMAGE = "https://www.pinterest.com/upload-image/"
BOARD_FOLLOWERS = "https://pinterest.com/resource/BoardFollowersResource/get/"
ADD_PIN_NOTE = "https://www.pinterest.com/resource/ApiResource/create/"


class Pinterest:
Expand Down Expand Up @@ -562,7 +563,7 @@ def get_user_followers_all(self, username=None):
return followers

def pin(
self, board_id, image_url, description="", link="", title="", section_id=None
self, board_id, image_url, description="", link="", title="", alt_text="", section_id=None
):
"""
Perfoms a pin operation. If you want to upload local image use 'upload_pin'
Expand All @@ -580,8 +581,9 @@ def pin(
"description": description,
"link": link if link else image_url,
"scrape_metric": {"source": "www_url_scrape"},
"method": "scraped",
"method": "uploaded",
"title": title,
"alt_text": alt_text,
"section": section_id,
}
source_url = "/pin/find/?url={}".format(self.req_builder.url_encode(image_url))
Expand Down Expand Up @@ -1252,3 +1254,18 @@ def type_ahead(self, scope="pins", count=5, term=""):

resp = self.get(url=url).json()
return resp["resource_response"]["data"]["items"]

def add_pin_note(self, pin_id, note):
"""
Adds a note to pin
"""
options = {
"url": "/v3/pins/{}/notes/".format(pin_id),
"data": {
"pin_note_content": note
}
}

data = self.req_builder.buildPost(options=options, source_url="/pin/{}/".format(pin_id))
return self.post(url=ADD_PIN_NOTE, data=data)

2 changes: 1 addition & 1 deletion py3pin/__version__.py
@@ -1 +1 @@
__version__ = '1.2.2'
__version__ = '1.3.0'
1 change: 0 additions & 1 deletion requirements.txt
@@ -1,4 +1,3 @@
PyQt5
beautifulsoup4
requests-toolbelt
selenium
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -18,7 +18,7 @@
EMAIL = 'boriostoilov@gmail.com'
AUTHOR = 'Borislav Stoilov'
REQUIRES_PYTHON = '>=3.5.0'
REQUIRED = ['requests', 'beautifulsoup4', 'requests-toolbelt', 'PyQt5', 'selenium', 'webdriver-manager']
REQUIRED = ['requests', 'beautifulsoup4', 'requests-toolbelt', 'selenium', 'webdriver-manager']

here = os.path.abspath(os.path.dirname(__file__))

Expand Down

0 comments on commit 8932e62

Please sign in to comment.