refactored source code, work on pixiv integration
This commit is contained in:
@@ -3,11 +3,23 @@ module Sources
|
||||
class Base
|
||||
attr_reader :url, :agent
|
||||
|
||||
def self.url_match?(url)
|
||||
false
|
||||
end
|
||||
|
||||
def initialize(url)
|
||||
@url = url
|
||||
@agent = create_agent
|
||||
end
|
||||
|
||||
def get
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def site_name
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def artist_name
|
||||
raise NotImplementedError
|
||||
end
|
||||
@@ -24,6 +36,18 @@ module Sources
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def artist_alias
|
||||
nil
|
||||
end
|
||||
|
||||
def unique_id
|
||||
artist_name
|
||||
end
|
||||
|
||||
def artist_record
|
||||
Artist.other_names_match(artist_name)
|
||||
end
|
||||
|
||||
protected
|
||||
def create_agent
|
||||
raise NotImplementedError
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
module Sources
|
||||
module Strategies
|
||||
class Default < Base
|
||||
def site_name
|
||||
"?"
|
||||
end
|
||||
|
||||
def artist_name
|
||||
"?"
|
||||
end
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
module Sources
|
||||
module Strategies
|
||||
class Fc2 < Base
|
||||
def site_name
|
||||
"FC2"
|
||||
end
|
||||
|
||||
def artist_name
|
||||
"?"
|
||||
end
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
module Sources
|
||||
module Strategies
|
||||
class NicoSeiga < Base
|
||||
def site_name
|
||||
"Nico Seiga"
|
||||
end
|
||||
|
||||
def artist_name
|
||||
"?"
|
||||
end
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
module Sources
|
||||
module Strategies
|
||||
class Pixa < Base
|
||||
def site_name
|
||||
"Pixa"
|
||||
end
|
||||
|
||||
def artist_name
|
||||
"?"
|
||||
end
|
||||
|
||||
@@ -3,13 +3,21 @@ module Sources
|
||||
class Pixiv < Base
|
||||
attr_reader :artist_name, :profile_url, :image_url, :tags
|
||||
|
||||
def initialize(url)
|
||||
super
|
||||
get
|
||||
def self.url_match?(url)
|
||||
url =~ /^https?:\/\/(?:\w+\.)?pixiv\.net/
|
||||
end
|
||||
|
||||
def is_pixiv?
|
||||
url =~ /pixiv\.net/
|
||||
def initialize(url)
|
||||
super
|
||||
end
|
||||
|
||||
def site_name
|
||||
"Pixiv"
|
||||
end
|
||||
|
||||
def unique_id
|
||||
image_url =~ /\/img\/([^\/]+)/
|
||||
$1
|
||||
end
|
||||
|
||||
def get
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
module Sources
|
||||
module Strategies
|
||||
class Tinami < Base
|
||||
def site_name
|
||||
"Tinami"
|
||||
end
|
||||
|
||||
def artist_name
|
||||
"?"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user