lib/bookshark/extractors/bibliographical_book_extractor.rb in bookshark-1.0.1 vs lib/bookshark/extractors/bibliographical_book_extractor.rb in bookshark-1.0.3

- old
+ new

@@ -168,13 +168,20 @@ if !publisher_node.nil? details_hash[:publisher] = { text: publisher_node.text, b_id: (publisher_node[:href].split("/"))[2] } - after_last_author_text = @nodeset + last_author = @nodeset .xpath("//a[@class='booklink' and @href[contains(.,'/author/') ]][last()]").last - .next_sibling.text.strip - puts after_last_author_text + + if !last_author.nil? && !last_author.empty? + after_last_author_text = last_author.next_sibling.text.strip + else + last_book = @nodeset + .xpath("//a[@class='booklink' and @href[contains(.,'/book/') ]][last()]").last + after_last_author_text = last_book.next_sibling.text.strip + end + details_hash[:publication] = { year: after_last_author_text[/(?<=: )\d+(?=\.)/], version: after_last_author_text[/(?<=- )\d+(?=η)/], place: after_last_author_text[/(?<=- )\p{Word}+( \S)?( \p{Word}+( \S)?)*(?= :)/] }