Browse Source

Work on converting json data, posting to pinboard.

master
jowj 3 years ago
parent
commit
95389aa306
  1. 32
      pinboard.py

32
pinboard.py

@ -9,24 +9,34 @@ pinboard_base_url = "https://api.pinboard.in/v1/"
def get_all_posts():
get_post_snippet = f"posts/all?auth_token={pinboard_token}"
pinboard_url = pinboard_base_url + posts_url_snippet
pinboard_url = pinboard_base_url + get_post_snippet
return requests.get(pinboard_url)
@pysnooper.snoop()
def add_pin_url(reddit_title, reddit_url, reddit_description, subreddit):
def add_pin_url(reddit_dict):
add_post_snippet = f"posts/add?auth_token={pinboard_token}"
headers = {'Content-type': 'application/json'}
args = {
'url': reddit_url,
'description': reddit_title,
'extended': reddit_description,
'tags': subreddit,
'url': reddit_dict.url,
'description': reddit_dict.title,
'extended': reddit_dict.description,
'tags': reddit_dict.tag,
'replace': no
}
pass
post_url = pinboard_base_url + add_post_snippet
args_json = json.dumps(args)
response = requests.post(post_url, data=args_json, headers=headers)
return response
@pysnooper.snoop()
def import_reddit_url_from_file(filename):
with open(filename, 'r') as infile:
json.load(infile)
data = json.loads(infile.read())
return data
import_reddit_url_from_file("data.json")
if __name__ == "__main__":
dict = import_reddit_url_from_file("data.json")
add_pin_url(dict)

Loading…
Cancel
Save