habuでC78の同人誌をむにゃむにゃする

ご無沙汰ですね

大学院入試終わった、いろんな意味で。
落ちたら他の大学院受ける気力がないので、NEETになるか留年するか・・・
どちらにしても親に相談しないといけないなー

さて、

前回のhabuを使ってみる - なんというていたらくで、habuの設定は終わったので簡単なプラグインを書いてみた。
ここにアップされるC78関連のtorrentを指定したディレクトリに保存するだけ

プラグインとYAMLは以下のとおり。

habu/publisher/fetchHentai.py
# -*- coding: utf-8 -*-

import urllib, urllib2, re, os
import habu.log as log

class FetchHentai(object):
    def __init__(self, config, environ):
        self.saveDir = config["saveDir"]

    def execute(self, content):
        for entry in content["entries"]:
            title = re.sub('.zip', '.torrent', entry["title"])
            torrentUrl = entry["link"]
            log.info(title)
            try:
                f = open(self.saveDir + title, "wb")
            except IOError:
                log.error()
            else:
                f.write(urllib2.urlopen(torrentUrl).read())
            finally:
                f.close()

def create(config, environ):
    return FetchHentai(config, environ)
sample/eHentai.cfg
global:
  timezone: Asia/Tokyo
  log: stdout

pipeline:
  rss_fetcher:
    - module: subscription.config
      config:
        feed:
          - http://g.ehgt.org/rss/ehtracker.xml
    - module: filter.join
    - module: filter.grep
      config:
        exclusive: False
        str:
          title: C78
    - module: filter.sort
      config:
        reverse: True
    - module: publisher.fetchHentai
      config:
        saveDir: "ファイルを保存するディレクトリのパス"
$python runhabu.py sample/eHentai.cfg 

でhabuを走らせると、指定したディレクトリにファイルが落ちてくるはず。
あとは煮るなり焼くなり自己責任で。

頑張れば、【C78】コミケのエッチな戦利品写メうp画像まとめ - みんくちゃんねるにあるやつ全部集められるかな?

「東方しかきょーみねーよ、ばーか」

みたいな人は

global:
  timezone: Asia/Tokyo
  log: stdout

pipeline:
  rss_fetcher:
    - module: subscription.config
      config:
        feed:
          - http://g.ehgt.org/rss/ehtracker.xml
    - module: filter.join
    - module: filter.grep
      config:
        exclusive: False
        re:
          title: /(C78.*(touhou|東方).*)
    - module: filter.sort
      config:
        reverse: True
    - module: publisher.fetchHentai
      config:
        saveDir: "ファイルを保存するディレクトリのパス"

こんな感じで書けばいいんじゃね?
YAML正規表現がワカラナイorz