Created
January 9, 2021 23:59
-
-
Save MoritzGiessmann/5fd0b19f892cf741683811517de8298b to your computer and use it in GitHub Desktop.
ColorNote Android to Nextcloud Deck import script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
urlFrom = 'https://nextcloud.server.url' | |
authFrom = ('username', 'password') | |
headers={'OCS-APIRequest': 'true', 'Content-Type': 'application/json'} | |
boardId = 1 #integer | |
stackId = 1 #integer | |
def createCards(title): | |
description = '' | |
if len(title) > 253 : | |
description = title | |
title = title[:253] + '…' | |
response = requests.post( | |
f'{urlFrom}/index.php/apps/deck/api/v1.0/boards/{boardId}/stacks/{stackId}/cards', | |
auth=authFrom, | |
json={ | |
'title': title, | |
'type': 'plain', | |
'order': 2, | |
'description': description | |
}, | |
headers=headers) | |
response.raise_for_status() | |
return response.json() | |
def getStacks(boardId): | |
response = requests.get( | |
f'{urlFrom}/index.php/apps/deck/api/v1.0/boards/{boardId}/stacks', | |
auth=authFrom, | |
headers=headers) | |
response.raise_for_status() | |
print (response.json()) | |
return response.json() | |
def loadFile(): | |
# Open file | |
f = open("../Nextcloud/Notes/content.md", "r") | |
while(True): | |
line = f.readline() | |
if not line: | |
break | |
line = line.strip(); | |
lineArr = line.split('] ', 1) | |
if 'x' in lineArr[0]: | |
lineArr.append('done') | |
print(lineArr) | |
createCards(lineArr[1]) | |
f.close | |
loadFile() | |
#getStacks(1) #param: board id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment