Skip to content

Commit

Permalink
Update mangahere adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
jphager2 committed Oct 21, 2017
1 parent 2890e2a commit 49c3d03
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -2,7 +2,7 @@ source 'https://rubygems.org'

gem 'activerecord'
gem 'hanami-cli', github: 'hanami/cli'
gem 'mangdown', '~> 0.14.0'
gem 'mangdown', '~> 0.15.0'
gem 'pg'

group :development do
Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Expand Up @@ -30,15 +30,15 @@ GEM
concurrent-ruby (~> 1.0)
transproc (~> 1.0)
i18n (0.8.6)
mangdown (0.14.1)
mangdown (0.15.0)
nokogiri (~> 1.6)
ruby-filemagic
rubyzip (~> 1.1)
typhoeus (~> 0.7)
mini_portile2 (2.2.0)
mini_portile2 (2.3.0)
minitest (5.10.3)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
parallel (1.12.0)
parser (2.4.0.0)
ast (~> 2.2)
Expand Down Expand Up @@ -71,7 +71,7 @@ PLATFORMS
DEPENDENCIES
activerecord
hanami-cli!
mangdown (~> 0.14.0)
mangdown (~> 0.15.0)
minitest
pg
rubocop
Expand Down
19 changes: 15 additions & 4 deletions lib/mangdown/adapters/manga_here.rb
@@ -1,23 +1,34 @@
class MangaHere < Mangdown::Adapter::Base
site :manga_here

ROOT = 'http://www.mangahere.co/'
CDN = 'http://l.mhcdn.net/store/manga/'
ROOT = 'http://www.mangahere.co/'.freeze
CDNS = [
'http://l.mhcdn.net/store/manga/',
'https://mhcdn.secure.footprint.net/store/manga/'
].freeze

attr_reader :root

def self.for?(uri_or_site)
uri_or_site.to_s.start_with?(ROOT) ||
uri_or_site.start_with?(CDN) ||
cdn_uri?(uri_or_site) ||
uri_or_site.to_s == 'manga_here'
end

def self.cdn_uri?(uri)
CDNS.any? { |cdn| uri.to_s.start_with?(cdn) }
end

def initialize(uri, doc, name)
super

@root = ROOT
end

def hydra_opts
{ max_concurrency: 1 }
end

def is_manga_list?(uri = @uri)
uri =~ /#{root}mangalist/
end
Expand All @@ -34,7 +45,7 @@ def is_chapter?(uri = @uri)

# Must return true/false if uri represents a page for adapter
def is_page?(uri = @uri)
uri.start_with?(CDN)
self.class.cdn_uri?(uri)
end

# Return Array of Hash with keys: :uri, :name, :site
Expand Down

0 comments on commit 49c3d03

Please sign in to comment.