ZMediumToMarkdown

ZMediumToMarkdown

ZMediumToMarkdown is a powerful tool that allows you to effortlessly download and convert your Medium posts to Markdown format.

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 ❤️❤️❤️

bmc-button

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 🎉

  1. make sure has Docker on your system.
  2. git clone this repo git clone https://github.com/ZhgChgLi/ZMediumToMarkdown
  3. cd /ZMediumToMarkdown
  4. 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.)
  5. Refer to the configuration block down below and finish the configuration.
  6. run docker docker run -v ./:/usr/src/app zmediumtomarkdown
  7. have fun!

Using Gem

If you are familiar with ruby:

  1. make sure you have Ruby in your environment (I use 2.7.5)
  2. make sure you have Bundle in your environment (I use 2.3.13)
  3. type gem install ZMediumToMarkdown in terminal

If you are NOT familiar with ruby:

  1. MacOS comes with a System Ruby pre-installed, but we are NOT Recommend to use that, using rvm/rbenv's Ruby instead.
  2. install rbenv or rvm to manage Ruby environment
  3. install Ruby through rbenv/rym (you can install ruby version 2.6.X)
  4. change the systme ruby to rbenv/rvm's Ruby
  5. type which ruby in terminal to make sure current Ruby is NOT /usr/bin/ruby
  6. 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:

  1. Log in to a valid Medium Member account.
  2. Right-click anywhere on the Medium webpage.
  3. Select "Inspect" to open the Developer Tools.
  4. Navigate to the "Application" tab and locate the sid and uid 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

  1. MacOS comes with a System Ruby pre-installed, but we are NOT Recommend to use that, using rvm/rbenv's Ruby instead.
  2. install rbenv or rvm to manage Ruby environment
  3. install Ruby through rbenv/rym (you can install ruby version 2.6.X)
  4. change the systme ruby to rbenv/rvm's Ruby
  5. type which ruby in terminal to make sure current Ruby is NOT /usr/bin/ruby
  6. type gem install bundler install RubyGem dependency manager (you can install Bundle version 2.3.x)
  7. git clone or download this project
  8. type cd ./ZMediumToMarkdown go into project
  9. type bundle install in terminal to install project dependencies
  10. 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

exmaple repo

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. :)