This is an automation script I implemented in the Hexo blog update to automatically fetch blog updates, compare them with previous update statuses, and allow users to manually determine the update status of unfinished and newly added blogs, thus obtaining the new blog update status.
All Blogs are classified into three major categories:
⏸️(Still working)
✅(Mostly finished)
❌(Barely completed)
Preliminaries
ℹ️ For the latest version, we strongly recommend you to run `main.py` (or `run.sh` directly)! The old version of `main.sh` will no longer be maintained.
For the latest version, you need to get the Absolute address of your hexo directories which stores all your Markdown files and replace it with the variable of BLOG_DIR.
For example, in main.py:
1 2 3 4 5 6 7 8 9
#!/home/xiyuanyang/anaconda3/bin/python # ! ATTENTION: change it to your own python interpreter. import os import sys from datetime import datetime
# Configuration # ! ATTENTION: replace the BLOG_DIR with your own. BLOG_DIR = "/mnt/d/Blog/source/_posts"
Usage
For the new version
You can run the original python scripts:
1
python main.py
And you will see the answers and the output! Go to Demo for more details.
Or you can run the bash scripts run.sh to achieve more refined output control!
1
bash run.sh
For the old version (not recommended)
In main.sh, change the directory into your own directory:
1 2 3
DIR="/mnt/d/Blog/source/_posts"
# Change this line into your own directory!
Then create a new dir containing logs.
1
touchlog
You need to initialize prev.txt for your own blog!
For this document, please maintain the following format: Each line should include a prefix status emoji and the title name. The prefix status emojis include ✅ and ❌, indicating the completion status of the blog.
grep -v ".*\.sh" is because I add several .sh files into it. You can modify it with your own needs.
Then, the file will compare the new status with the previous status stored in the prev.txt. Then the file will ask users to manually determine the update status of unfinished and newly added blogs.
Finally, the scripts will update prev.txt and generate a new blog status named 20250330_200559.txt and you can see the updated status there!