Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

fix: add support for instapaper archived status and folders

Mohamed Bassem52f9ce0a00c6
diff --git a/packages/shared/import-export/parsers.test.ts b/packages/shared/import-export/parsers.test.ts
index c3d57e2b..a5c61b23 100644
--- a/packages/shared/import-export/parsers.test.ts
+++ b/packages/shared/import-export/parsers.test.ts
@@ -527,6 +527,45 @@ describe("parseKarakeepBookmarkFile", () => {
});
});
+describe("parseInstapaperBookmarkFile", () => {
+ it("maps Archive folder to archived flag, Unread to no paths, and custom folders to paths", () => {
+ const csv = [
+ "URL,Title,Selection,Folder,Timestamp,Tags",
+ "https://archived.example,Archived Article,,Archive,1700000000,[]",
+ "https://unread.example,Unread Article,,Unread,1700000001,[]",
+ "https://custom.example,Custom Article,,Reading List,1700000002,[]",
+ ].join("\n");
+
+ const result = parseImportFile("instapaper", csv);
+
+ expect(result.bookmarks).toHaveLength(3);
+
+ // Archive folder -> archived: true, no paths
+ expect(result.bookmarks[0]).toMatchObject({
+ title: "Archived Article",
+ content: { type: "link", url: "https://archived.example" },
+ archived: true,
+ paths: [],
+ });
+
+ // Unread folder -> not archived, no paths
+ expect(result.bookmarks[1]).toMatchObject({
+ title: "Unread Article",
+ content: { type: "link", url: "https://unread.example" },
+ archived: false,
+ paths: [],
+ });
+
+ // Custom folder -> not archived, folder as single-element path
+ expect(result.bookmarks[2]).toMatchObject({
+ title: "Custom Article",
+ content: { type: "link", url: "https://custom.example" },
+ archived: false,
+ paths: [["Reading List"]],
+ });
+ });
+});
+
describe("parsePocketBookmarkFile", () => {
it("sets archived true for items with status archive", () => {
const csv = `title,url,time_added,tags,status\nTest,https://example.com,1234567890,,archive`;
diff --git a/packages/shared/import-export/parsers.ts b/packages/shared/import-export/parsers.ts
index 6ea70cf2..dc8d4a7c 100644
--- a/packages/shared/import-export/parsers.ts
+++ b/packages/shared/import-export/parsers.ts
@@ -446,7 +446,7 @@ function parseInstapaperBookmarkFile(textContent: string): ParsedBookmark[] {
);
}
- return parsed.data.map((record) => {
+ return parsed.data.map((record): ParsedBookmark => {
let content: ParsedBookmark["content"];
if (record.URL && record.URL.trim().length > 0) {
content = { type: BookmarkTypes.LINK as const, url: record.URL.trim() };
@@ -469,12 +469,26 @@ function parseInstapaperBookmarkFile(textContent: string): ParsedBookmark[] {
tags = [];
}
+ let archived = false;
+ const paths = [];
+ if (record.Folder === "Archive") {
+ archived = true;
+ } else if (record.Folder === "Unread") {
+ // This maps to home feed in instapaper, do nothing.
+ } else {
+ // Instapaper "Starred" should map to favorites in karakeep, but
+ // apparently instapaper export only includes on folder per bookmark
+ // so for now, we'll treat the "Starred" as a normal folder.
+ paths.push([record.Folder]);
+ }
+
return {
title: record.Title || "",
content,
addDate,
tags,
- paths: [], // TODO
+ paths,
+ archived,
};
});
}