Skip to content

Instantly share code, notes, and snippets.

@horimislime
Last active December 15, 2015 08:39
Show Gist options
  • Select an option

  • Save horimislime/5232445 to your computer and use it in GitHub Desktop.

Select an option

Save horimislime/5232445 to your computer and use it in GitHub Desktop.
pixivのお気に入り新着をRSSで取得する
module Automatic::Plugin
class PublishFile
require 'pp'
def initialize(config, pipeline=[])
@config = config
@pipeline = pipeline
end
def run
@pipeline.each { |feeds|
unless feeds.nil?
open(@config["output_file"], "w") {|f|
f.write(feeds.pretty_inspect)
Automatic::Log.puts("info", "Published feed:\n#{feeds.pretty_inspect}")
}
end
}
@pipeline
end
end
end
# -*- coding: utf-8 -*-
# Name:: Automatic::Plugin::CustomFeedPixiv
# Author:: horimislime
require 'rss/maker'
module Automatic::Plugin
class CustomFeedPixiv
# https://github.com/uasi/pixiv
require 'pixiv'
def initialize(config, pipeline=[])
@config = config
@pipeline = pipeline
end
def run
pixiv = Pixiv.client(@config["pixiv_id"], @config["pixiv_password"]) {|agent|
agent.user_agent_alias = "Mac Safari"
}
@pipeline << RSS::Maker.make("1.0") { |maker|
maker.channel.about = ""
maker.channel.title = "#{@config['pixiv_id']}'s Pixiv feed"
maker.channel.description = "Pixiv feed"
maker.channel.link = "http://pixiv.net"
pixiv.member.bookmark_arrivals.each { |illust|
i= maker.items.new_item
i.title = "#{illust.title}"
i.link = "http://pixiv.net/member_illust.php?mode=medium&illust_id=#{illust.id}"
i.description = "<img src=\"#{illust.original_image_url}\">"
if maker.items.size > limit then
break
end
}
}
return @pipeline
end
private
def limit
return @config['fetch_items'] || 20
end
end
end
global:
timezone: Asia/Tokyo
cache:
base: /tmp
log:
level: info
plugins:
- module: CustomFeedPixiv
config:
pixiv_id: user_id
pixiv_password: password
fetch_items: 10
- module: PublishFile
config:
output_file: /path/to/pixiv_feed.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment