Code Monkey home page Code Monkey logo

haiku-archiver's Introduction

Haiku Archiver
~~~~~~~~~~~~~~

はてなハイク <http://h.hatena.ne.jp> の投稿を手元に保存するための
ツールです。

GitHub: <https://github.com/wakaba/haiku-archiver>
Docker Hub: <https://hub.docker.com/r/wakaba/haiku-archiver>

* 使い方

以下、 {har} は Haiku Archiver コマンドを表します。 Docker を使う場合、
{har} は

  docker run -it -v {data}:/app/data wakaba/haiku-archiver har

... となります。 {data} は取得データを保存するディレクトリーを表します。
絶対パスで指定してください。

{har} は次のようにオプションと共に実行してください。

  {har} user {user}

    {user} は投稿者の名前。はてなIDを指定してください。指定された
    投稿者の投稿を取得します。

  {har} keyword {word}

    {word} はキーワード名。指定されたキーワードへの投稿を取得します。
    {word} に id:{user} と指定するとユーザー {user} のIDキーワード
    への投稿を取得できます。

  {har} antenna {user}

    {user} は投稿者の名前。はてなIDを指定してください。指定された
    投稿者のアンテナに表示される投稿 (本人、お気に入りユーザー、
    お気に入りキーワードの投稿) を取得します。

  {har} public

    トップページに表示される投稿を取得します。

  {har} auto

    いろいろな投稿をできるだけ取得します。

Ctrl + C で中断できます。進行中の処理が済み次第、できるだけ早く
終了します。

2回目以降の実行では、できるだけ取得済みのデータを再取得せず、
続きから再開します。

本ソフトウェアは同時起動に対応していません。複数同時に実行すると
データを破損するおそれがあります。

例:

  $ docker run -it -v /path/to/har/data:/app/data wakaba/haiku-archiver har user hatenahaiku

... で id:hatenahaiku の投稿を取得して /path/to/har/data に保存します。

最新版に更新するときは:

  docker pull wakaba/haiku-archiver

* データ

{data} は取得データを保存するディレクトリーを表します。

  {data}/entries/{user}/{eid}.{n|h}.json

    個別の投稿。 {user} は投稿者の名前 (API ドキュメントで url_name と
    呼ばれているもの)。 {eid} は投稿のID。

    内容はサーバーが返す JSON から個別の投稿オブジェクトを取り出した
    ものです。サーバーが返す形式が n 形式と h 形式の2種類あり、
    ファイル名の {n|h} の部分で表しています。ただし h 形式の場合、
    "tld": "jp" または "tld": "com" を追加しています。意味は n 形式の
    "tld" と同じです。 n 形式と h 形式の内容は本質的に同じなので、
    可能ならどちらかだけ取得しますが、両方取得している場合もあります。

  {data}/graphs/users/{user}.json

    お気に入り情報。次のような内容の JSON ですが、空の項目は省略されます。

      {
        "favorite_user": {"{user}":1, "{user}":1, ...},
        "fan_user": {"{user}":1, "{user}":1, ...},
        "favorite_keyword": {"{word}":1, "{word}":2, ...}
      }

    favorite_user はお気に入りユーザー、 fan_user はファン (お気に入られ
    ユーザー)、favorite_keyword はお気に入りキーワードを表しています。
    {user} は相手のユーザー名、 {word} は相手のキーワード名 (asin: や
    http: のこともあります。) です。

  {data}/indexes/entries.txt

    取得した投稿の一覧です。次のような1行が1投稿を表します。

      {timestamp} {tld}/{user}/{eid} {target} {parentuser}/{parenteid}

    各項目の意味は次の通りです。

      {timestamp}   投稿日時 (Unix time、0埋めあり10桁)
      {tld}         "tld" の値
      {user}        投稿者名
      {eid}         投稿のID
      {target}      投稿先 (JSON の target の url_name の値、
                    なしの場合「@」 で表す)
      {parentuser}  返信の場合、親投稿の投稿者名 (返信でないなら空文字列)
      {parentuser}  返信の場合、親投稿のID (返信でないなら空文字列)

    {timestamp} で整列されています。

  {data}/indexes/users.txt

    取得した、または参照されていた投稿者の名前の一覧です。一度も投稿して
    いない人や、退会等既に投稿を取得できない状態の投稿者が含まれる可能性も
    あります。1行ごとに1人の投稿者名を表します。 ASCII 順で整列されています。

  {data}/indexes/keywords.txt

    キーワードの一覧です。ただし asin: や http: は含みません。次のような
    1行が1キーワードを表します。

      {target} {escapedword}
      
    {target} は先述の通り。 {escapedword} はキーワード名ですが、 U+005C,
    U+000D, U+000A を含むいくつかの符号位置はすべて \x{005C} のような形式
    でエスケープしたものです。

    投稿を取得するなど {target} と {escapedword} の組み合わせが判明して
    いるもののみ含みます。

    {target} で整列されています。

  {data}/indexes/https.txt

    http: キーワードの一覧です。形式は data/indexes/keywords.txt と同じです。

* ご注意

- 取得するデータ次第で、かなり時間がかかります。
- 取得するデータ次第で、かなりのファイルサイズとファイル数になります。
- サーバー側の制約のため、すべての投稿を取得できない可能性があります。
  (例えば har keyword {word} を実行しても、投稿数が多いキーワードの
  古い投稿を取得できません。)
- サーバー側で既に削除されているデータは取得できません。
- はてなフォトライフの画像やはてなスターの情報は取得しません。
- 本ソフトウェアで取得したデータは、著作権法その他の法令に従い適切に
  ご利用ください。
- 本ソフトウェアが生成したデータについて、本ソフトウェアの開発者および
  貢献者は著作権その他の権利を主張しません。
- サーバーに過剰な負荷を与える使い方はお控えください。
- 本ソフトウェアには株式会社はてなは一切関与していません。

* トラブルシューティング

Entries: 0 Thu Jan  1 00:00:00 1970

と表示されたまま長時間変化しない場合、メモリー不足などの要因で処理が
進まなくなっている可能性があります。 Ctrl + C を何度か押して停止させ、
再度実行することで回復します。

* License

Copyright 2019 Wakaba <[email protected]>.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public
License along with this program.  If not, see
<https://www.gnu.org/licenses/>.

haiku-archiver's People

Contributors

wakaba avatar

Stargazers

 avatar ARAI Takashi avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.