|
|
|
@ -13,8 +13,20 @@ from markdownify import markdownify
|
|
|
|
|
|
|
|
|
|
#%%
|
|
|
|
|
now= datetime.datetime.now()
|
|
|
|
|
arena_queue = []
|
|
|
|
|
timestamp = now.strftime('%Y.%m.%d-%H:%M')
|
|
|
|
|
timestamp = now.strftime('%Y.%m.%d %H:%M')
|
|
|
|
|
|
|
|
|
|
# %%
|
|
|
|
|
|
|
|
|
|
def import_metadata(pin):
|
|
|
|
|
date = pin.time
|
|
|
|
|
link = pin.url
|
|
|
|
|
tags = str(pin.tags)
|
|
|
|
|
import_info = f'\n------------\n' \
|
|
|
|
|
f'Imported from Pinboard on: {timestamp} \n' \
|
|
|
|
|
f'Originally saved on {date} \n' \
|
|
|
|
|
f'Tags: {tags} \n' \
|
|
|
|
|
f'{link}'
|
|
|
|
|
return import_info
|
|
|
|
|
|
|
|
|
|
# %%
|
|
|
|
|
pins = pinboard.Pinboard(os.environ['PINBOARD_TOKEN'])
|
|
|
|
@ -25,35 +37,31 @@ tagged_pins = pins.posts.all(tag=["book"])
|
|
|
|
|
|
|
|
|
|
# %%
|
|
|
|
|
|
|
|
|
|
arena_queue = []
|
|
|
|
|
|
|
|
|
|
for pin in tagged_pins:
|
|
|
|
|
print(pin.url)
|
|
|
|
|
arena_post = {
|
|
|
|
|
'source': pin.url,
|
|
|
|
|
'description': pin.description + '\n' + pin.extended,
|
|
|
|
|
'title': pin.description
|
|
|
|
|
}
|
|
|
|
|
arena_post['description'] += import_metadata(pin)
|
|
|
|
|
arena_queue.append(arena_post)
|
|
|
|
|
|
|
|
|
|
# pin.description, pin.extended, pin.time
|
|
|
|
|
|
|
|
|
|
# %%
|
|
|
|
|
|
|
|
|
|
# def import_metadata(post):
|
|
|
|
|
# date = post['date']
|
|
|
|
|
# link = post['post_url']
|
|
|
|
|
# t = post['type']
|
|
|
|
|
# import_info = f'\n------------\n' \
|
|
|
|
|
# f'Imported from Tumblr on: {timestamp} \n' \
|
|
|
|
|
# f'Originally posted as a {t} on {date} \n' \
|
|
|
|
|
# f'{link}'
|
|
|
|
|
# return import_info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#%%
|
|
|
|
|
# Are.na posting
|
|
|
|
|
#%% Are.na posting
|
|
|
|
|
|
|
|
|
|
# url = "https://api.are.na/v2/channels/automation_inbox/blocks"
|
|
|
|
|
url = "https://api.are.na/v2/channels/book-inbox/blocks"
|
|
|
|
|
|
|
|
|
|
# arena_queue.reverse()
|
|
|
|
|
arena_queue.reverse()
|
|
|
|
|
|
|
|
|
|
# print('Posting ' + str(len(arena_queue)) + ' blocks')
|
|
|
|
|
print('Posting ' + str(len(arena_queue)) + ' blocks')
|
|
|
|
|
|
|
|
|
|
# for block in arena_queue:
|
|
|
|
|
# block['access_token'] = os.environ['ARENA_TOKEN']
|
|
|
|
|
# x = requests.post(url, data=block)
|
|
|
|
|
for block in arena_queue:
|
|
|
|
|
block['access_token'] = os.environ['ARENA_TOKEN']
|
|
|
|
|
x = requests.post(url, data=block)
|
|
|
|
|
|
|
|
|
|
# print('Done')
|
|
|
|
|
print('Done')
|
|
|
|
|