Skip to content

Instantly share code, notes, and snippets.

@t510599
Last active June 1, 2023 09:44
Show Gist options
  • Save t510599/069d459f928bb4b1622a428a8bbfa66e to your computer and use it in GitHub Desktop.
Save t510599/069d459f928bb4b1622a428a8bbfa66e to your computer and use it in GitHub Desktop.
hackmd image backup

hackmd 用的圖床 imgur 要清掉舊圖了
怕 hackmd 文件裡面的圖全都被清光 所以來備份一下

Steps

  1. 設定 > 筆記設定 > 備份 > 下載所有筆記
  2. 解壓縮
  3. 把 image.py 搬進去同個資料夾
  4. 執行 image.py
  5. wget -i url.txt 來下載所有圖片
import glob
import re
f = []
for fn in glob.glob("*.md"):
with open(fn, encoding="utf-8") as md:
content = md.read()
urls = re.findall("(https\://i\.imgur\.com/\w+\.(?:png|jpg|gif))", content)
if urls:
f += urls
with open("url.txt", "w") as wf:
wf.writelines(l + "\n" for l in f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment