Is it possible to force joplin to accept externally generated IDs (respecting Joplin standard for note’s ids) when creating notes?
something like:
joplin_api.create_note(my_generated_id, note_title, note_content, notebook_id)
the above would allow me to import wiki pages from an external program and precalculate inter-wiki links by precalculating Joplin ids for each note and replacing the wiki markup links with the newly calculated ids.
My current import procedure works as follows:
I have a series of wiki pages in a database (or notes that’s just up to naming convention), let’s say I have page_1 with id pageid_1, page2 with id pageid_2 etc etc.
Each wiki page just like a Joplin note has an id, a title and a body.
The body of page_1 is made up of wiki markup possibly containing internal links to other pages.
My export/import script scans all wiki pages for links and creates a python dict of wiki links -> joplin links:
links_dict = {"page_1": "3a3445e6446cd2ba1f6b165533acab20", "pageid_2":"9964695d78136d6f0b42e93db0574f03"}
the joplin ids are calculated with the function:
def get_random_joplin_id(self)
random_uuid = uuid.uuid4()
uuid_dehyphenated = random_uuid.hex
return hashlib.sha256(uuid_dehyphenated.encode('utf-8')).hexdigest()[0:32]
it then replaces all links from the body of all pages from the format accepted by the wiki to the format accepted by Joplin, that is
[[page2|pageid_2]]
is replaced with
[page2](:/9964695d78136d6f0b42e93db0574f03)
it then creates a Joplin note for each page in the wiki, calling:
joplin_api.create_note(page.title, page.content, notebook_id)
for the page1 I would for instance call something like:
joplin_api.create_note("page1", "Hello this is a link to [page2](:/9964695d78136d6f0b42e93db0574f03) hope it works", notebook_id)
from the example above I hope it’s clear that when I’m creating the note for page1 I have not created the note for page2 yet so I must know in advance note2 id in order to create the correct content for note1!
The solution for me would be to have some method like:
joplin_api.create_note("3a3445e6446cd2ba1f6b165533acab20", "page1", "Hello this is a link to [page2](:/9964695d78136d6f0b42e93db0574f03) which has not been created yet", notebook_id)
the above creates a note for page1 with id “3a3445e6446cd2ba1f6b165533acab20”, which creates a link to a page2 which has not been created yet.
then I would call:
joplin_api.create_note("9964695d78136d6f0b42e93db0574f03", "page2", "Finally this is page2 !!!!", notebook_id)