Catch books with missing dates

This commit is contained in:
Nemo 2020-04-04 01:10:11 +05:30
parent 0b241d6a47
commit 1a5086b2d7
5 changed files with 1928 additions and 3 deletions

3
.gitignore vendored
View File

@ -4,4 +4,5 @@
/.shards/ /.shards/
*.dwarf *.dwarf
*.pdf *.pdf
*.o *.o
muse-dl-static*

View File

@ -72,4 +72,10 @@ describe Muse::Dl::Book do
book.formats.should contain :pdf book.formats.should contain :pdf
book.formats.should contain :html book.formats.should contain :html
end end
it "should note both formats for book/57833" do
html = File.new("spec/fixtures/book-57833.html").gets_to_end
book = Muse::Dl::Book.new html
book.formats.should contain :pdf
end
end end

1914
spec/fixtures/book-57833.html vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -39,7 +39,11 @@ module Muse::Dl
end end
def self.date(myhtml : Myhtml::Parser) def self.date(myhtml : Myhtml::Parser)
myhtml.css("#book_about_info .date").map(&.inner_text).to_a[0].strip begin
myhtml.css("#book_about_info .date").map(&.inner_text).to_a[0].strip
rescue e : Exception
nil
end
end end
def self.publisher(myhtml : Myhtml::Parser) def self.publisher(myhtml : Myhtml::Parser)

View File

@ -6,7 +6,7 @@ module Muse::Dl
@info = Hash(String, String).new @info = Hash(String, String).new
@title : String @title : String
@author : String @author : String
@date : String @date : String | Nil
@publisher : String @publisher : String
@summary : String @summary : String
@summary_html : String @summary_html : String