«前の日記(2009-10-13(Tue)) 最新 次の日記(2009-10-24(Sat))» 編集

ぽっぺん日記@karashi.org


2009-10-14(Wed) [長年日記]

_ 図書館の返却期限を取得し Plagger で iCal フォーマットに変換、 Google Calendar に登録する

読み終えた本は読書メーターで管理しているのですが、元来メンドくさがりなので、ぽろぽろと登録忘れをしてしまいます。 特に図書館で借りた本は、手元にない分だけ、その傾向が強いです。

図書館の返却期限を取得し Plagger で iCal フォーマットに変換 - greenplastic.netを読んで、「返却期限をGoogle Calendarに登録しておけば、読書記録にもなるんじゃね?」と思いついたので、自宅近くの図書館の返却期限をPlaggerで取得できるCustomFeed::Scriptを書いてみました。

assets/plugins/CustomFeed-Script/hidaka_city_library_lend_books.pl at master from poppen's plagger_plugin - GitHub

次のようなYAMLを書いて、

plagger -c  hidaka_library2ical.yaml

でicalの生成までは問題なくできました。

hidaka_library2ical.yaml

global:
  plugin_path:
    - lib/Plagger/Plugin
  assets_path: assets
  timezone: Asia/Tokyo
  log:
    level: error

plugins:
  - module: Subscription::Config
    config:
      feed:
        - script:/path/to/hidaka_city_library_lend_books.pl
  - module: CustomFeed::Script
  - module: Aggregator::Simple
  - module: Publish::iCal
    config:
      dir: /path/to/ical/
      filename: hidaka_lib.ics

しかし、Google Calendarに「URLで指定」で登録すると豪快に文字化けが発生しました。 ググってみたところと、UTF-8の日本語を数値文字参照形式に変換すればいいとのこと。

emasakaさんがUTF-8の日本語を数値文字参照形式に変換するプラグイン、Filter::NCRを本を読む Google Calendarがまた日本語iCalendar非対応に?で公開されていたので、そちらを使用して見事にGoogle Calendarで登録できました。

Filter::NCRを使用するYAMLは次の通りです。

hidaka_library2ical.yaml

global:
  plugin_path:
    - lib/Plagger/Plugin
  assets_path: assets
  timezone: Asia/Tokyo
  log:
    level: error

plugins:
  - module: Subscription::Config
    config:
      feed:
        - script:/path/to/hidaka_city_library_lend_books.pl
  - module: CustomFeed::Script
  - module: Aggregator::Simple
  - module: Filter::NCR
  - module: Publish::iCal
    config:
      dir: /path/to/ical/
      filename: hidaka_lib.ics

Filter::NCRは、私のforkしたPlaggerのgithubレポジトリにも取り込まさせていただきました。

lib/Plagger/Plugin/Filter/NCR.pm at master from poppen's plagger - GitHub

これで読書メーターの登録を忘れることは少なくなりそうです。

[]
本日のPingbacks(全0件)

«前の日記(2009-10-13(Tue)) 最新 次の日記(2009-10-24(Sat))» 編集