nicoseiga: fix login endpoint.
* Update the login endpoint. The old endpoint returns 404 now. POST https://account.nicovideo.jp/api/v1/login -> POST https://account.nicovideo.jp/login/redirector?site=seiga * Let Danbooru::Http cache the login request instead of caching it manually. * Let Danbooru::Http automatically follow redirects instead of dealing with the Location header manually.
This commit is contained in:
@@ -82,7 +82,7 @@ module Sources
|
||||
end
|
||||
|
||||
resp = api_client.get(img)
|
||||
if resp.headers["Location"] =~ %r{https?://.+/(\w+/\d+/\d+)\z}i
|
||||
if resp.uri.to_s =~ %r{https?://.+/(\w+/\d+/\d+)\z}i
|
||||
"https://lohas.nicoseiga.jp/priv/#{$1}"
|
||||
else
|
||||
img
|
||||
@@ -180,12 +180,12 @@ module Sources
|
||||
|
||||
def api_client
|
||||
if illust_id.present?
|
||||
NicoSeigaApiClient.new(work_id: illust_id, type: "illust")
|
||||
NicoSeigaApiClient.new(work_id: illust_id, type: "illust", http: http)
|
||||
elsif manga_id.present?
|
||||
NicoSeigaApiClient.new(work_id: manga_id, type: "manga")
|
||||
NicoSeigaApiClient.new(work_id: manga_id, type: "manga", http: http)
|
||||
elsif image_id.present?
|
||||
# We default to illust to attempt getting the api anyway
|
||||
NicoSeigaApiClient.new(work_id: image_id, type: "illust")
|
||||
NicoSeigaApiClient.new(work_id: image_id, type: "illust", http: http)
|
||||
end
|
||||
end
|
||||
memoize :api_client
|
||||
|
||||
Reference in New Issue
Block a user