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 Sources
|
||||||
module Strategies
|
module Strategies
|
||||||
class Base
|
class Base
|
||||||
class DownloadError < StandardError; end
|
extend Memoist
|
||||||
|
|
||||||
# The http timeout to download a file.
|
# The http timeout to download a file.
|
||||||
DOWNLOAD_TIMEOUT = 60
|
DOWNLOAD_TIMEOUT = 60
|
||||||
|
|
||||||
attr_reader :url, :referer_url, :urls, :parsed_url, :parsed_referer, :parsed_urls
|
attr_reader :url, :referer_url, :parsed_url, :parsed_referer
|
||||||
|
|
||||||
extend Memoist
|
|
||||||
|
|
||||||
# Should return true if all prerequisites for using the strategy are met.
|
# 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.
|
# 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)
|
def initialize(url, referer_url = nil)
|
||||||
@url = url.to_s
|
@url = url.to_s
|
||||||
@referer_url = referer_url&.to_s
|
@referer_url = referer_url&.to_s
|
||||||
@urls = [@url, @referer_url].select(&:present?)
|
|
||||||
|
|
||||||
@parsed_url = Source::URL.parse(url)
|
@parsed_url = Source::URL.parse(url)
|
||||||
@parsed_referer = Source::URL.parse(referer_url) if referer_url.present?
|
@parsed_referer = Source::URL.parse(referer_url) if referer_url.present?
|
||||||
@parsed_urls = [parsed_url, parsed_referer].select(&:present?)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Should return true if this strategy should be used. By default, checks
|
# 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.
|
# if the main url belongs to any of the domains associated with this site.
|
||||||
def match?
|
def match?
|
||||||
return false if parsed_url.nil?
|
false
|
||||||
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
|
|
||||||
[]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def site_name
|
def site_name
|
||||||
@@ -87,8 +76,6 @@ module Sources
|
|||||||
"Erogamescape"
|
"Erogamescape"
|
||||||
when /facebook\.com\z/i
|
when /facebook\.com\z/i
|
||||||
"Facebook"
|
"Facebook"
|
||||||
when /fantia\.jp\z/i
|
|
||||||
"Fantia"
|
|
||||||
when /fc2\.com\z/i
|
when /fc2\.com\z/i
|
||||||
"FC2"
|
"FC2"
|
||||||
when /gumroad\.com\z/i
|
when /gumroad\.com\z/i
|
||||||
@@ -99,8 +86,6 @@ module Sources
|
|||||||
"Ko-fi"
|
"Ko-fi"
|
||||||
when /livedoor\.(jp|com)\z/i
|
when /livedoor\.(jp|com)\z/i
|
||||||
"Livedoor"
|
"Livedoor"
|
||||||
when /lofter\.com\z/i
|
|
||||||
"Lofter"
|
|
||||||
when /mangaupdates\.com\z/i
|
when /mangaupdates\.com\z/i
|
||||||
"Mangaupdates"
|
"Mangaupdates"
|
||||||
when /melonbooks\.co\.jp\z/i
|
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
|
# be a list of JPEG, PNG, GIF, WEBM, MP4, ZIP, etc. It is what the
|
||||||
# downloader will fetch and save to disk.
|
# downloader will fetch and save to disk.
|
||||||
def image_urls
|
def image_urls
|
||||||
raise NotImplementedError
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
def image_url
|
def image_url
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
module Sources
|
module Sources
|
||||||
module Strategies
|
module Strategies
|
||||||
class Foundation < Base
|
class Foundation < Base
|
||||||
extend Memoist
|
|
||||||
|
|
||||||
def match?
|
def match?
|
||||||
parsed_url&.site_name == "Foundation"
|
parsed_url&.site_name == "Foundation"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
module Sources
|
module Sources
|
||||||
module Strategies
|
module Strategies
|
||||||
class HentaiFoundry < Base
|
class HentaiFoundry < Base
|
||||||
extend Memoist
|
|
||||||
|
|
||||||
def match?
|
def match?
|
||||||
parsed_url&.site_name == "Hentai Foundry"
|
parsed_url&.site_name == "Hentai Foundry"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
module Sources
|
module Sources
|
||||||
module Strategies
|
module Strategies
|
||||||
class Lofter < Base
|
class Lofter < Base
|
||||||
extend Memoist
|
|
||||||
|
|
||||||
def match?
|
def match?
|
||||||
parsed_url&.site_name == "Lofter"
|
parsed_url&.site_name == "Lofter"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
module Sources
|
module Sources
|
||||||
module Strategies
|
module Strategies
|
||||||
class PixivSketch < Base
|
class PixivSketch < Base
|
||||||
extend Memoist
|
|
||||||
|
|
||||||
def match?
|
def match?
|
||||||
Source::URL::PixivSketch === parsed_url
|
Source::URL::PixivSketch === parsed_url
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,14 +4,12 @@
|
|||||||
module Sources
|
module Sources
|
||||||
module Strategies
|
module Strategies
|
||||||
class Plurk < Base
|
class Plurk < Base
|
||||||
extend Memoist
|
def match?
|
||||||
|
Source::URL::Plurk === parsed_url
|
||||||
def domains
|
|
||||||
["plurk.com"]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def site_name
|
def site_name
|
||||||
"Plurk"
|
parsed_url.site_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def image_urls
|
def image_urls
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
module Sources
|
module Sources
|
||||||
module Strategies
|
module Strategies
|
||||||
class Skeb < Base
|
class Skeb < Base
|
||||||
extend Memoist
|
|
||||||
|
|
||||||
def match?
|
def match?
|
||||||
parsed_url&.site_name == "Skeb"
|
parsed_url&.site_name == "Skeb"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user