Sha256: a6590bbe2af1e9890d3f74169950de1ff809c689063b9a03474d5f409b15a53b

Contents?: true

Size: 827 Bytes

Versions: 6

Compression:

Stored size: 827 Bytes

Contents

## load lirs file plugin -- takatoh
##
## see http://d.hatena.ne.jp/takatoh/20070308/loadlirs
##
## example
## - module: Feed::load_lirs
##   config: 
##     url: http://example.com/hoge.lirs.gz
##


require 'open-uri'
require 'rss/maker'
require 'zlib'
require 'kconv'

def parse_lirs(record)
  fields = record.chomp.split(",")
  item = RSS::RDF::Item.new
  item.title = fields[6]                                 # Title
  item.link  = fields[5]                                 # URL
item.date  = Time.at(fields[1].to_i + fields[3].to_i)  # Last-Modified (local time)
  return item
end


def lirs(config, data)
  f = open(config["url"])
  lirs = Zlib::GzipReader.wrap(f) {|gz| gz.read }.toutf8
  items = lirs.map {|record| parse_lirs(record) }
  return items
rescue
  puts "LoadError File = #{config["url"]}"
  return []
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
yapra-0.2.2 legacy_plugins/Feed/lirs.rb
yapra-0.2.0 legacy_plugins/Feed/lirs.rb
yapra-0.1.3 legacy_plugins/Feed/lirs.rb
yapra-0.1.0 legacy_plugins/Feed/lirs.rb
yapra-0.1.1 legacy_plugins/Feed/lirs.rb
yapra-0.1.2 legacy_plugins/Feed/lirs.rb