' #-----ISBN確認-----
isbn1 = $1
checkbook = CacheBib.new()
newisbn = checkbook.isbn_check(isbn1)
if newisbn != isbn1
mes_str << "Warrning; ISBN-error; #{isbn1} -> #{newisbn}\n"
$stderr.puts "WAR; ISBN-error; #{isbn1} -> #{newisbn}"
end
isbn1 = newisbn
isbn2 = isbn1.delete('-')
@bookstore_list = @shop_list.split(/\s+/)
@bookstore_list = @shop_list0.split(/\s+/) if isbn2 =~ /^0/
@bookstore_list = @shop_list1.split(/\s+/) if isbn2 =~ /^1/
reviewlink = CacheBib_reviewlink.new() #-----書評リンク用-----
reviewlink.isbn = isbn1
# reviewlink.affiliate_code = @reviewer_code unless @reviewer_code.empty?
# reviewlink.url_head = @reviewlink_url unless @reviewlink_url.nil?
# anchor = ''
# if @diary.paragraphAnchor
# if @diary.anchorEachTopic
# anchor = "_t#{@diary.instance_eval{@cntTopic}}_#{@diary.instance_eval{@cntParagraph + 1}}"
# else
# anchor = "_#{@diary.instance_eval{@cntParagraph + 1}}"
# end
# end
# reviewlink.url = "#{@diary.date2monthlyfilelink(@diary.date, true)}#{anchor}"
# $stderr.puts 'CHK; reviewlink; ' + reviewlink.tag_info
# rl_str = reviewlink.tag
rl_str = ''
infolist = [] #-----書店にネット接続/キャッシュ読-----
@bookstore_list.each{ |bookstore| infolist << nil }
=begin
if flag_ippodb
book = CacheBib_ippodb.new()
book.expire = @expire
flag_net = @flag_net
book.cache_dir = @cache_dir[bookstore]
book.bookstore_list = @bookstore_list
infolist = book.get_data(isbn1, flag_net)
# info["url_bibinfo"] = book.url_bibinfo
# info['word_delivery'] = book.word_delivery
end
=end
@bookstore_list.each_index{ |i|
bookstore = @bookstore_list[i]
book, info = nil, infolist[i]
# next if flag_overload || (info['expire'] < @expire)
begin
case bookstore
when 'amazon'
book = CacheBib_amazon.new()
book.affiliate_code = @amazon_id unless @amazon_id.empty?
flag_image = true
when 'bk1'
book = CacheBib_bk1.new()
book.affiliate_code = @bk1_id unless @bk1_id.empty?
when 'yahoo'
book = CacheBib_yahoo.new()
when 'asahiya'
book = CacheBib_asahiya.new()
when 'jbook'
book = CacheBib_jbook.new()
when 'kinokuniya'
book = CacheBib_kinokuniya.new()
when 'rakuten'
book = CacheBib_rakuten.new()
book.affiliate_code = @rakuten_id unless @rakuten_id.empty?
when 'skysoft'
book = CacheBib_skysoft.new()
when 'amazon_com'
book = CacheBib_amazon_com.new()
when 'a1books'
book = CacheBib_a1books.new()
when 'powells'
book = CacheBib_powells.new()
when 'maruzen'
book = CacheBib_maruzen.new()
when 'amazon_uk'
book = CacheBib_amazon_uk.new()
when 'bookshop'
book = CacheBib_bookshop.new()
when 'esbooks'
book = CacheBib_esbooks.new()
when 'boople'
book = CacheBib_boople.new()
when 'rcom'
book = CacheBib_rcom.new()
when 'reviewlink'
book = reviewlink
else
$stderr.puts "WAR; unknown-bookstore; code:#{bookstore}"
next
end
rescue Exception
$stderr.puts "WAR; access-error; #{isbn1} - #{@bookstore_name[bookstore]}"
next
end
book.expire = @expire
flag_net = @flag_net
#ネットへの接続を制限するなら例えば以下の様に。
#flag_net = true if bookstore == 'amazon'
book.cache_dir = @cache_dir[bookstore]
info = book.get_data(isbn1, flag_net)
info["url_bibinfo"] = book.url_bibinfo
begin #-----word delivery-----
info['word_delivery'] = book.word_delivery
rescue Exception #-----for no-define-word_delivery = rcom-----
$stderr.puts "WAR; delivery-decode-error; #{isbn1} - #{@bookstore_name[bookstore]}" if bookstore != 'rcom'
info['word_delivery'] = [nil, nil]
end
infolist[i] = info
}
storelist = [] #-----書店情報リスト作成-----
@bookstore_list.each_index{ |i|
bookstore = @bookstore_list[i]
info = infolist[i]
next if info.nil?
flag_image = (bookstore == 'amazon') ? true : false
new_str = ''
if !info['image'].nil? #-----image-----
if flag_image
height = info['image_height'].to_i != 0 ? info['image_height'].to_s : '140'
width = info['image_width'].to_i != 0 ? info['image_width'].to_s : '100'
# mes_str << '
'
mes_str << '
'
else
new_str << ' 絵'
end
end
delivery, flag = info['word_delivery']
if flag
new_str << '
'+ delivery + ''
end
if !info['reviews'].nil?
new_str << ' ' + info['reviews'].size.to_s + "評"
end
if new_str.size > 0 #-----bookstore name-----
if bookstore != 'rcom'
new_str = @bookstore_name[bookstore] + new_str
else #-----rcom custom-----
new_str = '
' + @bookstore_name[bookstore]+ '' + new_str
end
if flag == 'over'
new_str = '
' + @bookstore_name[bookstore]+ ''
end
end
storelist << new_str if new_str.size > 0
}
infolist.delete(nil)
info = checkbook.merge_info( infolist )
info["isbn"] = isbn1
mes_str << rl_str #-----表示文字列作成-----
mes_str << "【 " + storelist.join(" / ") + " 】\n" if storelist.size > 0
# mes_str << "題:" + info['title'] + "\n" if !info['title'].nil?
# mes_str << "著:" + info['author'] + "\n" if !info['author'].nil?
# mes_str << "訳:" + info['translator'] + "\n" if !info['translator'].nil?
# mes_str << "符:ISBN" + info['isbn'] + "\n" if !info['isbn'].nil?
# mes_str << "刊:" + info['publisher'] + "\n" if !info['publisher'].nil?
# mes_str << "年:" + info['pubdate'] + "\n" if !info['pubdate'].nil?
# mes_str << "型:" + info['size'] + "\n" if !info['size'].nil?
# mes_str << "標:" + info['series'] + "\n" if !info['series'].nil?
# mes_str << "値:" + info['price'] + "\n" if !info['price'].nil?
# mes_str << "文:" + info['desc'] + "\n" if !info['desc'].nil?
# mes_str = mes_str.strip + '
'
mes_str = mes_str.strip
mes_str << '
'
}
end
end
end
class CacheBib_reviewlink
attr_accessor :isbn, :affiliate_code, :url, :url_head
attr_accessor :expire, :cache_dir
def get_data ( isbn, flag_net = false )
@isbn = isbn
return {'isbn'=>@isbn, 'reviewer'=>@affiliate_code, 'url'=>@url}
end
def url_bibinfo
url = 'http://ippo.s5.xrea.com/x/rl/index.cgi?cmd=book&code=ISBN' + isbn.delete('-').upcase
# url << "&reviewer=#{@affiliate_code}" unless @affiliate_code.nil?
# url << "&url=#{@url_head + @url}" if !@url.nil? && !@url_head.nil?
return CGI.escapeHTML(url)
end
def tag_info
tags = []
tags << "ISBN#{@isbn}"
tags << "reviewer=#{@affiliate_code}" unless @affiliate_code.nil?
tags << "url=#{@url}"
return tags.join(":")
end
def tag
# return ''
return ''
end
def word_delivery
return ['x', 'over']
end
end