ZMediumToMarkdown
ZMediumToMarkdown is a powerful tool that allows you to effortlessly download and convert your Medium posts to Markdown format.
This project can help you create an auto-sync or auto-backup service from Medium, such as automatically syncing Medium posts to Jekyll or other static markdown blog engines, or backing up Medium posts to Github pages.
Features
- Supports downloading posts and converting them to markdown format
- Supports downloading all posts and converting them to markdown format from any user without requiring login access
- Supports downloading paid content
- Supports downloading all of a post's images to the local drive and converting them to local paths
- Supports parsing Twitter tweet content to blockquotes
- Supports a command line interface
- Converts Gist source code to markdown code blocks
- Converts YouTube links embedded in a post to preview images
- Adjusts a post's last modification date from Medium to the locally downloaded markdown file
- Auto-skips posts that have already been downloaded and whose last modification date from Medium hasn't changed (convenient for auto-sync or auto-backup services, to save server bandwidth and execution time)
- Supports using Github Action as an auto-sync/backup service
- Highly optimized markdown format for Medium
- Native Markdown-style Render Engine (Feel free to contribute if you have any optimization ideas! MarkupStyleRender.rb)
- Supports paywall posts. (Requires providing valid Medium Member cookies)
- Jekyll and social share (og: tag) friendly
- 100% Ruby @ RubyGem
Buy me coffee ❤️❤️❤️
If this project has helped you, feel free to sponsor me a cup of coffee, thank you.
Result
and I use this tool to convert from Meidum to jekyllrb
Setup
2023/07/17 Update 🎉
I have just created a brand new GitHub repository template that allows you to move your Medium blog to your own Jekyll blog with just one click. Check it out: ZMediumToJekyll.
I'M NOT GEEK, PLEASE SHOW ME HOW TO USE WITHOUT CODING
- Please follow this post, step by step to creat your auto backup service without any coding:
How to use Github Action as your free & no code Medium Posts backup service
2024/01/27 Update: Docker 🎉
- make sure has Docker on your system.
- git clone this repo
git clone https://github.com/ZhgChgLi/ZMediumToMarkdown
cd /ZMediumToMarkdown
- build docker image
docker build -t zmediumtomarkdown:latest --build-arg CRON_SETTING="0 8 * * *" --build-arg ZMEDIUMTOMARKDOWN_COMMAND="-u [YOUR_MEDIUM_USERNAME]" .
- ZMEDIUMTOMARKDOWN_COMMAND = ZMediumToMarkdown Command (Refer to the configuration block down below.)
- Refer to the configuration block down below and finish the configuration.
- run docker
docker run -v ./:/usr/src/app zmediumtomarkdown
- have fun!
Using Gem
If you are familiar with ruby:
- make sure you have Ruby in your environment (I use
2.7.5
) - make sure you have Bundle in your environment (I use
2.3.13
) - type
gem install ZMediumToMarkdown
in terminal
If you are NOT familiar with ruby:
- MacOS comes with a System Ruby pre-installed, but we are NOT Recommend to use that, using rvm/rbenv's Ruby instead.
- install rbenv or rvm to manage Ruby environment
- install Ruby through rbenv/rym (you can install ruby version
2.6.X
) - change the systme ruby to rbenv/rvm's Ruby
- type
which ruby
in terminal to make sure current Ruby is NOT/usr/bin/ruby
- type
gem install ZMediumToMarkdown
in terminal
Usage
Command: ZMediumToMarkdown
Downloading all posts from any user
ZMediumToMarkdown -u [USEERNAME]
Downloading single post
ZMediumToMarkdown -p [MEDIUM POST URL]
Update to latest version
ZMediumToMarkdown -n
Remove all downloaded posts data
ZMediumToMarkdown -c
Print current ZMediumToMarkdown Version & Output Path
ZMediumToMarkdown -v
Provide valid Medium Member cookies to access paywall posts ZMediumToMarkdown requires uid and sid cookies to access paywalled posts on Medium.
If you don’t provide valid Medium Member cookies, you will receive this warning message while downloading a Medium post if the post is behind a paywall:
This post is behind Medium's paywall. You must provide valid Medium Member login cookies to download the full post.
ZMediumToMarkdown --cookie_uid uid --cookie_sid sid
You can obtain cookie_uid
and cookie_sid
from Medium by following these steps:
- Log in to a valid Medium Member account.
- Right-click anywhere on the Medium webpage.
- Select "Inspect" to open the Developer Tools.
- Navigate to the "Application" tab and locate the
sid
anduid
values under "Cookies."
For Jeklly Dir Friendly
Downloading all posts from user with Jekyll friendly
ZMediumToMarkdown -j [USEERNAME]
Downloading single post with Jekyll friendly
ZMediumToMarkdown -k [MEDIUM POST URL]
Manually
- MacOS comes with a System Ruby pre-installed, but we are NOT Recommend to use that, using rvm/rbenv's Ruby instead.
- install rbenv or rvm to manage Ruby environment
- install Ruby through rbenv/rym (you can install ruby version
2.6.X
) - change the systme ruby to rbenv/rvm's Ruby
- type
which ruby
in terminal to make sure current Ruby is NOT/usr/bin/ruby
- type
gem install bundler
install RubyGem dependency manager (you can install Bundle version2.3.x
) - git clone or download this project
- type
cd ./ZMediumToMarkdown
go into project - type
bundle install
in terminal to install project dependencies - use
bundle exec ruby [USAGE Command]
in the furture (USAGE Command write down below)
Usage
Execute File: bin/ZMediumToMarkdown
Downloading all posts from any user
bundle exec ruby bin/ZMediumToMarkdown -u [USEERNAME]
Downloading single post
bundle exec ruby bin/ZMediumToMarkdown -p [MEDIUM POST URL]
Update to latest version
bundle exec ruby bin/ZMediumToMarkdown -n
Remove all downloaded posts data
bundle exec ruby bin/ZMediumToMarkdown -c
Print current ZMediumToMarkdown Version & Output Path
bundle exec ruby bin/ZMediumToMarkdown -v
Output
Where can I find the results of the downloaded post?
The default path of the downloaded post will be in the ./Output
directory.
- Downloading all posts from user:
./Ouput/users/[USERNAME]/posts/[POST_PATH_NAME]
- Downloading single post:
./Ouput/posts/[POST_PATH_NAME]
- Post's images:
[POST_PATH_NAME]/images/[POST_ID]/[IMAGE_PATH_NAME]
Disclaimer
All content downloaded using ZMediumToMarkdown, including but not limited to articles, images, and videos, are subject to copyright laws and belong to their respective owners. ZMediumToMarkdown does not claim ownership of any content downloaded using this tool.
Downloading and using copyrighted content without the owner's permission may be illegal and may result in legal action. ZMediumToMarkdown does not condone or support copyright infringement and will not be held responsible for any misuse of this tool.
Users of ZMediumToMarkdown are solely responsible for ensuring that they have the necessary permissions and rights to download and use any content obtained using this tool. ZMediumToMarkdown is not responsible for any legal issues that may arise from the misuse of this tool.
By using ZMediumToMarkdown, users acknowledge and agree to comply with all applicable copyright laws and regulations.
Using Github Action as your free auto sync/backup service
name: ZMediumToMarkdown
on:
workflow_dispatch:
schedule:
- cron: "10 1 15 * *" # At 01:10 on day-of-month 15.
jobs:
ZMediumToMarkdown:
runs-on: ubuntu-latest
steps:
- name: ZMediumToMarkdown Automatic Bot
uses: ZhgChgLi/ZMediumToMarkdown@main
with:
command: '[USAGE Command]' # e.g. -u zhgchgli
Things to know
- If you would like to remove the ZMediumToMarkdown watermark located at the bottom of the page, you may do so. I don't mind.
- Since ZMediumToMarkdown is not an official tool and Medium does not provide a public API for it, I cannot guarantee that the parser target will not change in the future. However, I have tried to test it for as many cases as possible. If you encounter any rendering errors, please feel free to create an issue and I will fix them as soon as possible.
About
Other works
Swift Libraries
- ZMarkupParser is a pure-Swift library that helps you to convert HTML strings to NSAttributedString with customized style and tags.
- ZPlayerCacher is a lightweight implementation of the AVAssetResourceLoaderDelegate protocol that enables AVPlayerItem to support caching streaming files.
- ZNSTextAttachment enables NSTextAttachment to download images from remote URLs, support both UITextView and UILabel.
Integration Tools
- ZReviewTender is a tool for fetching app reviews from the App Store and Google Play Console and integrating them into your workflow.
- ZMediumToMarkdown is a powerful tool that allows you to effortlessly download and convert your Medium posts to Markdown format.
- linkyee is a fully customized, open-source LinkTree alternative deployed directly on GitHub Pages.
Donate
If you find this library helpful, please consider starring the repo or recommending it to your friends.
Feel free to open an issue or submit a fix/contribution via pull request. :)