Skip to main content

No project description provided

Project description

hatena-cli

Command line utility for Hatena Blog.

hatena-cli is designed for Hatena Blog enthusiasts who perfer to keep their files stored locally on their machines.

Here's why hatena-cli is better than the traditional copy-paste approach:

  1. No body length limits.

You know how Hatena Blog's web editor puts a cap on how much you can write? With hatena-cli, that's a thing of the past! You can upload massive Markdown files without any hassle.

  1. Say goodbye to manual image uploads.

With the --with-images option, hatena-cli automatically sniffs out the local images referenced in your Markdown file and uploads them to your Hatena Fotolife storage. It even updates the image paths in the generated HTML file!

Currently, hatena-cli only supports Markdown files. But no worries, we're thinking about adding support for other file formats soon.

To get started, make sure you have pandoc and hatena-cli installed. You can install them by running these commands:

~$ brew install pandoc
...
~$ python -m pip install hatena-cli
...
~$ pandoc --version
pandoc 3.1.3
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /Users/taichimaeda/.local/share/pandoc
Copyright (C) 2006-2023 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
~$ hatena --version
Hatena Blog CLI Version: 0.1.0

Before you can dive into the functionality of hatena-cli, you need do a bit of setup.

First, follow this tutorial to obtain your API key and secret:

https://developer.hatena.ne.jp/ja/documents/auth/apis/oauth/consumer

Then submit the details with hatena config init, after which you are ready to go!:

~$ hatena config init
hatena config init
auth:api_key: <api_key>
auth:api_secret: <api_secret>
blog:username: <user_id>
blog:domain: <user_id>.hatenablog.com

If you need more configurations, try these commands:

~$ hatena config list
List of config:
auth:api_key: <api_key>
auth:api_secret: <api_secret>
auth:access_token: 
auth:access_secret: 
auth:expires: 2023-07-02 12:00:00.000000
blog:username: <user_name>
blog:domain: <user_name>.hatenablog.com
image:pattern: src="(.+\.(?:jpg|png))"
image:replace: src="\1"
path:template: <home_dir>/Library/Application Support/hatena-cli/template.html
path:pandoc: /opt/homebrew/bin/pandoc
~$ hatena config set pandoc:path /usr/local/pandoc
path:pandoc: /usr/local/pandoc
~$ hatena config get pandoc:path
path:pandoc: /usr/local/pandoc

Now, let's see hatena-cli in action! Check out these examples:

~$ hatena upload --with-images 'My First Blog' ~/Documents/first-blog.md
...
~$ hatena update --with-images 'My First Blog 2' ~/Documents/first-blog2.md 820878482946714696
...
~$ hatena delete --with-images 820878482946714696
...

hatena upload and hatena delete require the blog ID of your entry on Hatena Blog.

To find this blog ID, take a look at the URL of Hatena Blog's web editor. It's the <blog_id> part in this format:

https://blog.hatena.ne.jp/<user>/<domain>/edit?entry=<blog_id>

On a first launch, you will be redirected to your web browser for authentication. Copy the code displayed and enter it when prompted.

Remember, when you use the --with-images option with hatena update, it deletes all previously referenced images and uploads the new ones from your local Markdown file. It can take some time, so use it wisely. It might be quicker to use the web editor if the changes are small.

Happy blogging!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hatena_cli-1.0.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hatena_cli-1.0.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file hatena_cli-1.0.1.tar.gz.

File metadata

  • Download URL: hatena_cli-1.0.1.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0

File hashes

Hashes for hatena_cli-1.0.1.tar.gz
Algorithm Hash digest
SHA256 90092dcc28cfdc5ba86d3556017f2e91dda4463ac9ef5ec18b1ecfebcf2f435e
MD5 d09fd12538952964a4b74aeb81bfa899
BLAKE2b-256 5be4e1aeebbc108517df70d59a6b687c20bfaa13db2c1239ec48ccef4b6b343a

See more details on using hashes here.

File details

Details for the file hatena_cli-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: hatena_cli-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0

File hashes

Hashes for hatena_cli-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 06a14cdbd3a7f317c21f20f4b7fbb72681ca2169e98ea843d0e2bd5cfc4646af
MD5 b0ff9af84771627353b4024b3e135f09
BLAKE2b-256 c5da3952be01a9a6d62fd5f5960472e29d777b164d3b39738f6cc4a9c0992cb0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page