Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
bstoilov committed Dec 16, 2020
1 parent 82f1e82 commit bf8a6ac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,13 @@ Current pinterest scopes are: pins, buyable_pins, my_pins, videos, boards
```pinterest.get_comments(pin_id='pin_id')```


### Send perosnal message
### Send personal message
```pinterest.send_message(conversation_id=conversation_id, pin_id="(pin_id)", message="hey")```


### Access to type suggestions you see in the search input
```pinterest.type_ahead(term='apple')```




18 changes: 11 additions & 7 deletions examples.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from py3pin.Pinterest import Pinterest

pinterest = Pinterest(email='email',
password='password',
username='username',
password='pass',
username='username from settings',
cred_root='cred_root')

# proxies example:
Expand Down Expand Up @@ -200,12 +200,12 @@ def load_pin_by_id(pin_id=''):

# Careful with category names. They have different names than as shown on Pinterest
def create_board(name='',
description='',
category='other',
privacy='public',
layout='default'):
description='',
category='other',
privacy='public',
layout='default'):
return pinterest.create_board(name=name, description=description, category=category,
privacy=privacy, layout=layout)
privacy=privacy, layout=layout)


def create_board_section(board_id='', section_name=''):
Expand All @@ -222,3 +222,7 @@ def get_board_sections(board_id=''):

def get_board_section_feed(section_id=''):
return pinterest.get_section_pins(section_id=section_id)


def type_ahead(term="apple"):
return pinterest.type_ahead(term=term)
12 changes: 6 additions & 6 deletions py3pin/Pinterest.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def get_user_followers(self, username=None, page_size=250):

next_bookmark = self.bookmark_manager.get_bookmark(primary='followers', secondary=username)

if next_bookmark is '-end-':
if next_bookmark == '-end-':
return []

options = {
Expand Down Expand Up @@ -1029,7 +1029,7 @@ def delete_board_section(self, section_id=''):
data = self.req_builder.buildPost(options=options)
return self.post(url=BOARD_SECTION_EDIT_RESOURCE, data=data)

def type_ahead(self,scope="pins",count=5,term=""):
def type_ahead(self, scope="pins", count=5, term=""):
"""
returns Pinterest predictions for given term.
Response may include user profiles.
Expand All @@ -1039,10 +1039,10 @@ def type_ahead(self,scope="pins",count=5,term=""):
:param term: word to be typed ahead
:return: response items
"""
source_url= "/"
options = {"pin_scope":scope,"count":count,"term":term,"no_fetch_context_on_resource":False}
url = self.req_builder.buildGet(TYPE_AHEAD_RESOURCE,options,source_url)

source_url = "/"
options = {"pin_scope": scope, "count": count, "term": term, "no_fetch_context_on_resource": False}
url = self.req_builder.buildGet(TYPE_AHEAD_RESOURCE, options, source_url)

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

0 comments on commit bf8a6ac

Please sign in to comment.