# これはnot(のとや)さん作 amazon4.rb が機能することを前提にしたスクリプトです。 require 'amazon4.rb' # # module Amazon # amazon4.rbで定義されている Item class を拡張 # class Item def to_bibtex return '' if text('//ProductGroup').empty? case text('//ProductGroup')[0] when 'Book' to_bibtex_book # when 'CE' # to_bibtex_ce # when 'Kitchen' # to_bibtex_kitchen # when 'Music' # to_bibtex_music # when 'DVD', 'Video' # to_bibtex_dvd # when 'Software' # to_bibtex_software # when 'Video Games' # to_bibtex_videogames # when 'Toy' # to_bibtex_toy else to_bibtex_base end end private def to_bibtex_base() "bibtex base" end ## # 本のデータをbibtex 形式にして出力。 # 他の形式のデータの処理は不明。 # # Title :: #{text('//Title')} # Publisher :: #{text('//Publisher')} # Author :: #{author} # Binding :: #{text('//Binding')} # Price :: #{text('//OfferSummary/LowestNewPrice/FormattedPrice')} # PublicationDate :: #{text('//PublicationDate')} # ISBN :: #{hyphened_isbn(text('//ASIN')[0])} # raw-ISBN :: #{text('//ASIN')[0]} # def to_bibtex_book author = page = '' t = text('//Creator', 'Role') if t.size.nonzero? then author = t.join(', ') end t = text('//NumberOfPages') if t.size.nonzero? then page ="#{t}ページ / " end "\@Book{, author = \{\{#{author}\}\}, title = \{\{ #{text('//Title')} \}\}, publsher = \{\{ #{text('//Publisher')} \}\}, year = \{ #{text('//PublicationDate')} \}, annote = \{ \}, ISBN = \{ #{text('//ASIN')[0]} \} }" end end end aws = Amazon::WebService::new list = aws.itemsearch({'Author'=>CGI::escape(ARGV[0].toutf8), 'SearchIndex'=>"Books"}) list.each{ |item| puts item.to_bibtex }