Skip books that don't support PDF

This commit is contained in:
Nemo 2020-04-01 01:35:59 +05:30
parent 2a78be1022
commit f3c757984a
2 changed files with 5 additions and 0 deletions

View File

@ -25,6 +25,7 @@ module Muse::Dl
return
end
# TODO: Remove this hardcoding, and make this more generic by generating it within the Book class
url = "https://muse.jhu.edu/chapter/#{chapter_id}/pdf"
headers = HEADERS.merge({
"Referer" => "https://muse.jhu.edu/verify?url=%2Fchapter%2F#{chapter_id}%2Fpdf",

View File

@ -15,6 +15,10 @@ module Muse::Dl
return unless thing
if thing.is_a? Muse::Dl::Book
unless thing.formats.includes? :pdf
STDERR.puts "Book not available in PDF format, skipping: #{url}"
return
end
# Will have no effect if parser has a custom title
parser.output = Util.slug_filename "#{thing.title}.pdf"