mirror of https://github.com/captn3m0/muse-dl.git
Adds Book parser
This commit is contained in:
parent
9447c8e30a
commit
e7754344d8
|
@ -2,11 +2,17 @@ require "crest"
|
|||
|
||||
module Muse::Dl
|
||||
class Fetch
|
||||
def get_info(url : String) : (Muse::Dl::Book | Muse::Dl::Issue)
|
||||
def get_info(url : String) : (Muse::Dl::Book | Muse::Dl::Journal)
|
||||
match = /https:\/\/muse.jhu.edu\/(book|journal)\/(\d+)/.match url
|
||||
if match
|
||||
begin
|
||||
response = Crest.get url
|
||||
case match[1]
|
||||
when "book"
|
||||
return Muse::Dl::Book.new response
|
||||
when "journal"
|
||||
return Muse::Dl::Journal.new response
|
||||
end
|
||||
rescue ex : Crest::NotFound
|
||||
raise Muse::Dl::InvalidLink
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require "./parser.cr"
|
||||
require "./pdftk.cr"
|
||||
require "./fetch.cr"
|
||||
require "./book.cr"
|
||||
|
||||
# TODO: Write documentation for `Muse::Dl`
|
||||
module Muse::Dl
|
||||
|
|
Loading…
Reference in New Issue