Adds a skip-open-access flag
Diff
src/article.cr | 5 +++++
src/issue.cr | 7 +++++++
src/journal.cr | 7 +++++++
src/muse-dl.cr | 5 +++++
src/parser.cr | 4 +++-
src/thing.cr | 7 +++++++
6 files changed, 34 insertions(+), 1 deletion(-)
@@ -10,5 +10,10 @@
@id = id
@url = "https://muse.jhu.edu/article/#{id}"
end
def open_access
return false
end
end
end
@@ -24,6 +24,13 @@
@info = Hash(String, String).new
end
def open_access
if @info.has_key? "Open Access"
return @info["Open Access"] == "Yes"
end
false
end
def parse(html : String)
h = Myhtml::Parser.new html
@info = InfoParser.infobox(h)
@@ -19,6 +19,13 @@
parse_volumes(h)
end
def open_access
if @info.has_key? "Open Access"
return @info["Open Access"] == "Yes"
end
false
end
def parse_volumes(myhtml : Myhtml::Parser)
myhtml.css("#available_issues_list_text a").each do |a|
link = a.attribute_by("href").to_s
@@ -15,6 +15,11 @@
thing = Fetch.get_info(url) if url
return unless thing
if (thing.open_access) && (parser.skip_oa)
STDERR.puts "Skipping #{url}, available under Open Access"
return
end
if thing.is_a? Muse::Dl::Book
unless thing.formats.includes? :pdf
STDERR.puts "Book not available in PDF format, skipping: #{url}"
@@ -14,10 +14,11 @@
@input_list : String | Nil
@cookie : String | Nil
@h : Bool | Nil
@skip_oa = false
DEFAULT_FILE_NAME = "tempfilename.pdf"
getter :bookmarks, :tmp, :cleanup, :output, :url, :clobber, :input_list, :cookie, :strip_first
getter :bookmarks, :tmp, :cleanup, :output, :url, :clobber, :input_list, :cookie, :strip_first, :skip_oa
setter :url
@@ -57,6 +58,7 @@
parser.on(long_flag = "--clobber", description = "Overwrite the output file, if it already exists. Not compatible with input-pdf") { @clobber = true }
parser.on(long_flag = "--dont-strip-first-page", description = "Disables first page from being stripped. Use carefully") { @strip_first = false }
parser.on(long_flag = "--cookie COOKIE", description = "Cookie-header") { |cookie| @cookie = cookie }
parser.on(long_flag = "--skip-open-access", description = "Don't download open access content") { @skip_oa = true }
parser.on("-h", "--help", "Show this help") { @h = true; puts parser }
parser.unknown_args do |args|
@@ -19,6 +19,13 @@
private getter :h
def open_access
if @info.has_key? "Open Access"
return @info["Open Access"] == "Yes"
end
false
end
def initialize(html : String)
@h = Myhtml::Parser.new html
@info = InfoParser.infobox(h)