sources: factor out Source::URL::DeviantArt and Source::URL::Stash.
This commit is contained in:
36
app/logical/source/url/stash.rb
Normal file
36
app/logical/source/url/stash.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Source
|
||||
class URL::Stash < Source::URL
|
||||
attr_reader :work_id, :username
|
||||
|
||||
def self.match?(url)
|
||||
url.domain == "sta.sh"
|
||||
end
|
||||
|
||||
def site_name
|
||||
"Sta.sh"
|
||||
end
|
||||
|
||||
def parse
|
||||
case [domain, *path_segments]
|
||||
|
||||
# https://sta.sh/21leo8mz87ue (folder)
|
||||
# https://sta.sh/2uk0v5wabdt (subfolder)
|
||||
# https://sta.sh/0wxs31o7nn2 (single image)
|
||||
in "sta.sh", work_id
|
||||
@work_id = work_id
|
||||
|
||||
# https://sta.sh/zip/21leo8mz87ue
|
||||
in "sta.sh", "zip", work_id
|
||||
@work_id = work_id
|
||||
|
||||
else
|
||||
end
|
||||
end
|
||||
|
||||
def page_url
|
||||
"https://sta.sh/#{work_id}"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user