Mem.ai import

Click here to install this plugin


name

Import from mem.ai

instructions

Visit https://mem.ai/settings/exports and export your notes using JSON format.

You'll receive an email titled "Your exported mems" - click the "Download exported mems" button.

This will open a new tab on a page starting with https://storage.googleapis.com/ - copy the full URL of the page. This is the value you will use in step 5.

In Amplenote, press cmd+O on mac or ctrl+O on Windows/Linux to open the quick nav dialog, then type "import from mem" and select this plugin.

In the popup window, paste the full URL from step 3.


description

Import notes from mem.ai's JSON export format. Imported notes will be tagged with imported/mem, and the DailyMem tag will be changed to daily-jots.


{
async appOption(app) {
const promptResult = await app.prompt(
"Please enter the URL of the mem JSON export file",
{
inputs: [
{ label: "URL", type: "text" },
{ label: "Import empty daily mems", type: "checkbox" },
]
}
);
if (!promptResult) return;
const [ url, importEmptyMems ] = promptResult;
if (!url) return;
 
const proxyURL = new URL("https://plugins.amplenote.com/cors-proxy");
proxyURL.searchParams.set("apiurl", url);
 
const response = await fetch(proxyURL);
const memNotes = await response.json();
 
const memNoteById = {};
for (let i = 0; i < memNotes.length; i++) {
const memNote = memNotes[i];
const { id, markdown, tags: memTags, title } = memNote;
 
const isEmptyDailyMem = memTags.includes("DailyMem") &&
markdown === `# ${ title }\n\n\nTasks\n- [ ] \n\n\nSchedule\n-\n`;
 
if (isEmptyDailyMem && !importEmptyMems) {
continue;
}
 
memNoteById[id] = memNote;
}
 
const memNotesToImport = Object.values(memNoteById);
 
const noteUUIDByMemId = {};
for (let i = 0; i < memNotesToImport.length; i++) {
const memNote = memNotesToImport[i];
const { id, tags: memTags, title } = memNote;
 
const tags = (memTags || []).map(memTag => {
if (memTag === "DailyMem") {
return "daily-jots";
} else {
return memTag;
}
});
tags.push("imported/mem");
 
noteUUIDByMemId[id] = await app.createNote(title, tags);
}
 
for (let i = 0; i < memNotesToImport.length; i++) {
const memNote = memNotesToImport[i];
let { id, markdown } = memNote;
 
markdown = markdown.replace(/\(https:\/\/mem\.ai\/m\/(\w+)\)/, function(match, referencedId) {
if (referencedId in noteUUIDByMemId) {
const referencedNoteUUID = noteUUIDByMemId[referencedId];
return `(https://www.amplenote.com/notes/${ referencedNoteUUID })`;
} else {
return match;
}
});
 
const noteUUID = noteUUIDByMemId[id];
await app.replaceNoteContent({ uuid: noteUUID }, markdown);
}
 
app.alert(`Imported ${ memNotesToImport.length } notes`);
},
}