sources: remove unused methods from base strategy.
Remove unused `urls`, `parsed_urls`, and `domains` methods.
This commit is contained in:
@@ -16,14 +16,12 @@
|
||||
module Sources
|
||||
module Strategies
|
||||
class Base
|
||||
class DownloadError < StandardError; end
|
||||
extend Memoist
|
||||
|
||||
# The http timeout to download a file.
|
||||
DOWNLOAD_TIMEOUT = 60
|
||||
|
||||
attr_reader :url, :referer_url, :urls, :parsed_url, :parsed_referer, :parsed_urls
|
||||
|
||||
extend Memoist
|
||||
attr_reader :url, :referer_url, :parsed_url, :parsed_referer
|
||||
|
||||
# Should return true if all prerequisites for using the strategy are met.
|
||||
# Return false if the strategy requires api keys that have not been configured.
|
||||
@@ -44,24 +42,15 @@ module Sources
|
||||
def initialize(url, referer_url = nil)
|
||||
@url = url.to_s
|
||||
@referer_url = referer_url&.to_s
|
||||
@urls = [@url, @referer_url].select(&:present?)
|
||||
|
||||
@parsed_url = Source::URL.parse(url)
|
||||
@parsed_referer = Source::URL.parse(referer_url) if referer_url.present?
|
||||
@parsed_urls = [parsed_url, parsed_referer].select(&:present?)
|
||||
end
|
||||
|
||||
# Should return true if this strategy should be used. By default, checks
|
||||
# if the main url belongs to any of the domains associated with this site.
|
||||
def match?
|
||||
return false if parsed_url.nil?
|
||||
parsed_url.domain.in?(domains)
|
||||
end
|
||||
|
||||
# The list of base domains belonging to this site. Subdomains are
|
||||
# automatically included (i.e. "pixiv.net" matches "fanbox.pixiv.net").
|
||||
def domains
|
||||
[]
|
||||
false
|
||||
end
|
||||
|
||||
def site_name
|
||||
@@ -87,8 +76,6 @@ module Sources
|
||||
"Erogamescape"
|
||||
when /facebook\.com\z/i
|
||||
"Facebook"
|
||||
when /fantia\.jp\z/i
|
||||
"Fantia"
|
||||
when /fc2\.com\z/i
|
||||
"FC2"
|
||||
when /gumroad\.com\z/i
|
||||
@@ -99,8 +86,6 @@ module Sources
|
||||
"Ko-fi"
|
||||
when /livedoor\.(jp|com)\z/i
|
||||
"Livedoor"
|
||||
when /lofter\.com\z/i
|
||||
"Lofter"
|
||||
when /mangaupdates\.com\z/i
|
||||
"Mangaupdates"
|
||||
when /melonbooks\.co\.jp\z/i
|
||||
@@ -141,7 +126,7 @@ module Sources
|
||||
# be a list of JPEG, PNG, GIF, WEBM, MP4, ZIP, etc. It is what the
|
||||
# downloader will fetch and save to disk.
|
||||
def image_urls
|
||||
raise NotImplementedError
|
||||
[]
|
||||
end
|
||||
|
||||
def image_url
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
module Sources
|
||||
module Strategies
|
||||
class Foundation < Base
|
||||
extend Memoist
|
||||
|
||||
def match?
|
||||
parsed_url&.site_name == "Foundation"
|
||||
end
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
module Sources
|
||||
module Strategies
|
||||
class HentaiFoundry < Base
|
||||
extend Memoist
|
||||
|
||||
def match?
|
||||
parsed_url&.site_name == "Hentai Foundry"
|
||||
end
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
module Sources
|
||||
module Strategies
|
||||
class Lofter < Base
|
||||
extend Memoist
|
||||
|
||||
def match?
|
||||
parsed_url&.site_name == "Lofter"
|
||||
end
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
module Sources
|
||||
module Strategies
|
||||
class PixivSketch < Base
|
||||
extend Memoist
|
||||
|
||||
def match?
|
||||
Source::URL::PixivSketch === parsed_url
|
||||
end
|
||||
|
||||
@@ -4,14 +4,12 @@
|
||||
module Sources
|
||||
module Strategies
|
||||
class Plurk < Base
|
||||
extend Memoist
|
||||
|
||||
def domains
|
||||
["plurk.com"]
|
||||
def match?
|
||||
Source::URL::Plurk === parsed_url
|
||||
end
|
||||
|
||||
def site_name
|
||||
"Plurk"
|
||||
parsed_url.site_name
|
||||
end
|
||||
|
||||
def image_urls
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
module Sources
|
||||
module Strategies
|
||||
class Skeb < Base
|
||||
extend Memoist
|
||||
|
||||
def match?
|
||||
parsed_url&.site_name == "Skeb"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user