Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MoritzGiessmann/5fd0b19f892cf741683811517de8298b to your computer and use it in GitHub Desktop.
Save MoritzGiessmann/5fd0b19f892cf741683811517de8298b to your computer and use it in GitHub Desktop.
ColorNote Android to Nextcloud Deck import script
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