Edge 团队连集锦功能善后都懒得做|让 AI 写 Python 把集锦数据无损迁移出来
Edge 149 之后集锦功能停了,基本是悄无声息的,个人认为也是区分 Chrome 浏览器很有特色的一个功能,而且这个功能推出时间也不短。
其实很多书签大部分不点击,书签的 2 次整理成本非常高。但集锦有个优势就可以备注,你知道这个链接是做什么的。
老用户的数据还可以通过:https://www.bing.com/saves访问,但数据没法直接导出。 Edge 团队连功能下线的善后处理都很潦草。
1. 数据在哪
Edge 集锦存在本地的一个 SQLite 数据库文件,文件名是 collectionsSQLite,没有后缀:
- Windows:
%LocalAppData%\Microsoft\Edge\User Data\Default\Collections\ - Mac:
~/Library/Application Support/Microsoft Edge/Default/Collections
2. 第三方工具 mienaiyami.xyz 的问题
把 collectionsSQLite 放到 https://edge-exporter.mienaiyami.xyz/ 可以导出 JSON 格式的文件,但是这个工具的问题是不会导出备注(原来集锦中的 Notes)功能。
如果你只是为了导出 URL 那就无所谓,只能说作者活干的还是有点糙,
3. 用 Python 直接读 SQLite
把 collectionsSQLite 复制到工作目录,运行下面的脚本,会生成一个 collections_plus_import.json:
import sqlite3, json, time
conn = sqlite3.connect('collectionsSQLite')
conn.row_factory = sqlite3.Row
cur = conn.cursor()
collections_raw = cur.execute("""
SELECT id, title, date_created, date_modified, position
FROM collections
WHERE is_marked_for_deletion IS NULL OR is_marked_for_deletion = 0
ORDER BY position
""").fetchall()
collections = []
for order_idx, col in enumerate(collections_raw):
items_in_col = cur.execute("""
SELECT i.id, i.type, i.title, i.text_content, i.color,
i.canonical_image_url, i.favicon_url, i.date_created, i.date_modified,
r.position
FROM collections_items_relationship r
JOIN items i ON r.item_id = i.id
WHERE r.parent_id = ?
AND (i.is_marked_for_deletion IS NULL OR i.is_marked_for_deletion = 0)
ORDER BY r.position
""", (col['id'],)).fetchall()
items = []
for item_order, row in enumerate(items_in_col):
if row['type'] == 'website':
source = cur.execute("SELECT source FROM items WHERE id=?", (row['id'],)).fetchone()
url = ''
if source and source['source']:
try:
src = json.loads(source['source'])
url = src.get('url', '') or src.get('URL', '')
except:
pass
items.append({
"id": row['id'],
"type": "page",
"addedAt": row['date_created'],
"done": False,
"order": item_order,
"url": url,
"title": row['title'] or '',
"favIconUrl": row['favicon_url'] or '',
"thumbnail": row['canonical_image_url'] or '',
"note": "",
"unread": False,
"fields": {}
})
elif row['type'] == 'annotation':
text = (row['text_content'] or '').strip('')
items.append({
"id": row['id'],
"type": "note",
"addedAt": row['date_created'],
"done": False,
"order": item_order,
"text": text
})
collections.append({
"id": col['id'],
"title": col['title'],
"createdAt": col['date_created'],
"updatedAt": col['date_modified'] or col['date_created'],
"cover": None,
"pinned": False,
"tags": [],
"parentId": None,
"order": order_idx,
"items": items
})
export = {
"version": 3,
"activeCollectionId": None,
"collections": collections,
"folders": [],
"archive": [],
"trash": [],
"rules": [],
"exportedAt": int(time.time() * 1000),
"app": "Collections Plus"
}
with open('collections_plus_import.json', 'w', encoding='utf-8') as f:
json.dump(export, f, ensure_ascii=False, indent=2)
print(f"Collections: {len(collections)}")
print(f"Page items: {sum(1 for c in collections for i in c['items'] if i['type'] == 'page')}")
print(f"Note items: {sum(1 for c in collections for i in c['items'] if i['type'] == 'note')}")
print("Output: collections_plus_import.json")脚本要和 collectionsSQLite 放在同一目录下运行:python3 export.py。这个脚本处理后的格式会保留集锦里的备注。
有几个地方值得注意:
URL 的位置:网页条目的 URL 不在 items 表的常规字段里,而是藏在 source 字段(BLOB 类型,实际是 JSON),需要单独解析出来。
格式要求:直接用 mienaiyami 导出的 JSON 格式往 Collections Plus 里导,是导不进去的。Collections Plus 的备份格式要求顶层有 version: 3,item 类型必须是 page 和 note,不能用 Edge 原始的 website 和 annotation。上面的脚本已经做了这个映射转换。
4. 导入到 Collections Plus
Collections Plus 是一个 Chrome 扩展(Chrome Web Store 可以装,Edge 也可以直接点击安装),功能上是 Edge 集锦的替代品,本身就支持备注,导入后备注会原样显示。
当然 Collections Plus 你在 Edge Add-ons 商店是找不到的,连类似功能的 Colletions 都停止更新了,提示 no longer supported。
导入步骤:
- 从 Chrome Web Store 安装 Collections Plus
- 面板右上角
⋯→ Import backup → 选择生成的collections_plus_import.json - 选择 Replace 模式,不要选 Merge——Merge 模式会重新分配 ID,如果之前有脏数据会导致重复
这样基本就解决了 Edge 集锦的数据&产品迁移。