|
Revision 6534, 1.0 kB
(checked in by yasuyuki, 5 years ago)
|
|
platform/pragger: initialize import.
|
| Line | |
|---|
| 1 | ## publish nicovideo mylisted avarage ranking
|
|---|
| 2 | ##
|
|---|
| 3 | ## - module Publish::nicorank_save_daily
|
|---|
| 4 | ## config:
|
|---|
| 5 | ## base_path: save html files base path
|
|---|
| 6 | ##
|
|---|
| 7 | ## Copyright (C) 2007-2008, INOUE Yasuyuki <inoue.yasuyuki0@gmail.com>
|
|---|
| 8 | ## Original version is written by TADA Tadashi <sho@spc.gr.jp>
|
|---|
| 9 | ## You can redistribute it and/or modify it under GPL3 or any later version.
|
|---|
| 10 |
|
|---|
| 11 | def nicorank_save_daily(config, data)
|
|---|
| 12 | now = Time::now
|
|---|
| 13 | begin
|
|---|
| 14 | if config['rank'] then
|
|---|
| 15 | open( "#{config['fetch_date']}" ) {|f| now = Marshal.load( f ) }
|
|---|
| 16 | end
|
|---|
| 17 | rescue Errno::ENOENT
|
|---|
| 18 | end
|
|---|
| 19 | today_root = config['root_dir'] + now.strftime("/%Y/%m/%d/")
|
|---|
| 20 |
|
|---|
| 21 | data.each_with_index do |html, index|
|
|---|
| 22 | File.open(today_root + "#{index + 1}.html", "w") do |f|
|
|---|
| 23 | f.write(html)
|
|---|
| 24 | end
|
|---|
| 25 | FileUtils.symlink(today_root + "#{index + 1}.html", "#{config['root_dir']}/#{index + 1}.html", :force => true)
|
|---|
| 26 | end
|
|---|
| 27 | FileUtils.symlink(today_root + "1.html", "#{config['root_dir']}/index.html", :force => true) if File.exist? today_root + "1.html"
|
|---|
| 28 | end
|
|---|