Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HuaweiMemoBackup(华为备忘录备份导出)

Language: English | 简体中文

Back up your own notes from Huawei Cloud (cloud.huawei.com) and export them to TXT / Markdown / HTML / JSON / PDF (pick any formats you like).

Pure Python, minimal dependencies, works out of the box. Ideal for switching phones, migrating notes, or archiving your memos locally.


Features

  • 📥 Fetch all notes + to-dos from Huawei Cloud (title, body, created/modified time, category, favorite)
  • 🖼️ Auto-downloads original images and preserves the original text/image order inside each note
  • 🧩 Export to multiple formats, freely selectable at export time:
    • json — structured data (notes + to-dos + categories, including raw fields) for further processing
    • txt / md — one file per note, organized into folders by category; each file's created/modified timestamps are set to the note's original times, so you can sort by time directly in your file manager
    • html — the notes page has sort buttons (by created / modified time, ascending or descending), the to-do page can toggle the original order; images inlined
    • pdf — mixed text/images, Times-Roman for English + a built-in CJK font for Chinese; notes.pdf builds a bookmark outline from titles and is ordered by modified time (newest first)
  • 🔐 Authenticated via your browser login cookie; all data is processed locally and never uploaded to any third party

Installation

Requires Python 3.9+.

git clone https://github.com/<your-name>/HuaweiMemoBackup.git
cd HuaweiMemoBackup
pip install -r requirements.txt

If PyPI is slow in your region, use a mirror, e.g.: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt


Getting your Cookie (the key step)

Huawei Cloud has no public export API, so this tool reuses your existing browser login. Follow these steps to grab the cookie:

  1. On your phone, enable Notes cloud sync: Settings → Huawei ID → Cloud → turn on the "Notepad" sync switch, and wait for it to finish.
  2. Open https://cloud.huawei.com in a desktop browser, log in, open Notepad, and confirm you can see your notes.
  3. Press F12 to open DevTools and switch to the Network tab.
  4. Click any note on the page to trigger a request; in the request list find one like simplenote/query or note/query.
  5. Click that request → Headers → find the Cookie: field under Request Headers and copy its entire long value.
  6. Save it into a text file (e.g. cookie.txt, a single line), then run with --cookie-file cookie.txt.

💡 The cookie is long, so reading it from a file with --cookie-file cookie.txt is usually more reliable than pasting it directly in a terminal (some terminals wrap/truncate very long strings). Both ways work though — the tool automatically trims stray whitespace introduced when pasting.

⚠️ A cookie is equivalent to your login credentials. Do not share it or commit it to a repo (cookie.txt is already in .gitignore). Cookies expire; just copy a fresh one when it stops working.


Usage

Option 1: Interactive (simplest)

Just run it, then follow the prompts to choose formats and paste the cookie:

python -m huawei_memo_backup

Option 2: Command-line arguments

# Export Markdown, HTML and PDF into the output directory
python -m huawei_memo_backup --cookie "PASTE_YOUR_COOKIE" -f md html pdf

# Read the cookie from a file and export all formats
python -m huawei_memo_backup --cookie-file cookie.txt

Option 3: Config file

Copy config.example.json to config.json and fill in your cookie:

{
  "cookie": "YOUR_COOKIE",
  "output_dir": "output",
  "formats": ["json", "md", "html", "txt", "pdf"],
  "download_attachments": true,
  "request_interval": 0.5,
  "pdf_font": ""
}

Then run:

python -m huawei_memo_backup --config config.json -y

Common options

Option Description
--cookie Pass the cookie string directly
--cookie-file Read the cookie from a file
--config Path to a JSON config file
-f, --format Formats to export (multiple allowed): json txt md html pdf
-o, --output Output directory (default: output)
--no-attachments Do not download image attachments
--no-todos Do not export to-dos
--interval Seconds between detail requests (default 0.5) to avoid hammering the server
--pdf-font Custom CJK font for PDF (path to a TTF); uses the built-in font if omitted
-y, --yes Non-interactive mode, no prompts
-v, --verbose Verbose debug logging

You can also provide the cookie via the HUAWEI_CLOUD_COOKIE environment variable.


Output structure

output/
├── attachments/            # Downloaded original images/attachments (shared by all formats)
│   └── some-note_1.jpg
├── json/
│   └── notes.json          # Structured data: notes + to-dos + categories (all together)
├── html/
│   ├── notes.html          # Notes, single page (index + inline images)
│   └── 待办清单.html         # To-dos on their own page
├── pdf/
│   ├── notes.pdf           # Notes PDF (mixed text/images)
│   └── 待办清单.pdf          # To-dos as a separate PDF
├── md/
│   ├── <category>/some-note.md   # One md per note, foldered by category ("未分类" if none)
│   └── 待办清单.md          # To-dos live at the md/ root
└── txt/
    ├── <category>/some-note.txt
    └── 待办清单.txt
  • json: notes and to-dos are kept together in one file.
  • html / pdf: notes and to-dos are split into two separate files.
  • md / txt: each note is filed under md/<category>/ or txt/<category>/ based on its Huawei Notepad category; the to-do list sits at the root of md/ and txt/.

How it works

The tool calls Huawei Cloud's internal APIs (a login cookie is required):

Purpose Endpoint
List (notes + to-dos) POST /notepad/simplenote/querynoteList / taskList / startCursor
Categories POST /notepad/notetag/query
Note detail POST /notepad/note/query (needs guid + the note's kind + startCursor)
Image download GET /proxy/v1/download/<encoded-path> (built from the assetId/versionId in the detail)
  1. The list endpoint returns all notes and to-dos at once; each note carries a kind (note = legacy, newnote = new format).
  2. The detail endpoint returns the body html_content (an <element type="Text"/Attachment"> structure where Chinese appears as &#xxxxx; numeric entities) plus attachment metadata.
  3. The parser rebuilds text/image order from the elements; images are downloaded via /proxy/v1/download.

These are Huawei's undocumented private APIs and may change at any time. If fetching fails, it's most likely an expired cookie or an API change. Try -f json -v first and inspect the raw fields (raw_summary / raw_detail) in notes.json.


FAQ

  • "Response is not JSON / cookie invalid": log in again on the web and copy a fresh cookie.
  • No notes at all: make sure Notepad cloud sync is enabled and finished on your phone, and you can see the notes on the web.
  • Chinese not showing in PDF: a built-in reportlab CJK font is used; if issues persist, pass --pdf-font with a local CJK TTF (e.g. C:\Windows\Fonts\msyh.ttc on Windows).
  • Image download returns 403: the login session has expired (image download goes through the stricter /proxy token service). Log in again on cloud.huawei.com and copy a fresh cookie.
  • Some images didn't download: handwritten/graffiti notes download their rendered graffiti.jpg; attachments missing assetId/versionId are skipped but their filenames are kept — check the raw attachment info in notes.json.

Disclaimer

This tool is intended only for backing up data under your own Huawei account. Do not use it in any way that violates others' privacy or Huawei's terms of service. You assume all risk arising from its use.

License

MIT

Acknowledgements

The API structure was independently verified against a real account by this project; early ideas were informed by the community projects formero009/huawei_note_downloader and thsrite/huawei_note_to_xiaomi_note.

About

Back up your Huawei Cloud notes & to-dos and export them to TXT / Markdown / HTML / JSON / PDF — pure Python, images included.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages