Keep auth_secure cookie from deviantart
Unlike this projects, all other DA scrapers I found[0] require that both "auth" and "auth_secure" are set. While the current approach, for some reason, seems to have worked fine in the past, it has stopped functioning on some systems, sometimes permanently (apparently sometimes only temporarily). I don't have the means to find out the reason behind that, since all configurations I've tried (mobile, VPN, and regular connection + 4 seperate accounts) resulted in me being effectively logged out and unable to view mature works after deleting the "auth_secure" cookie. The "if auth_cookie" part might not actually be necessary, its only purpose is to prevent unintended breakage due to lack of information on my part. [0]:b662b46a44 (diff-aab4e263d591d1c7f23d015a2e540a32R161)cbaecf5507 (diff-9f9821e7d744874a2fe42e0a69e4b14aR33)
This commit is contained in:
@@ -118,7 +118,7 @@ module Sources
|
|||||||
def agent
|
def agent
|
||||||
@agent ||= begin
|
@agent ||= begin
|
||||||
mech = Mechanize.new
|
mech = Mechanize.new
|
||||||
auth, userinfo = session_cookies(mech)
|
auth, userinfo, auth_secure = session_cookies(mech)
|
||||||
|
|
||||||
if auth
|
if auth
|
||||||
# This cookie needs to be set to allow viewing of mature works
|
# This cookie needs to be set to allow viewing of mature works
|
||||||
@@ -136,6 +136,13 @@ module Sources
|
|||||||
cookie.domain = ".deviantart.com"
|
cookie.domain = ".deviantart.com"
|
||||||
cookie.path = "/"
|
cookie.path = "/"
|
||||||
mech.cookie_jar.add(cookie)
|
mech.cookie_jar.add(cookie)
|
||||||
|
|
||||||
|
if auth_secure
|
||||||
|
cookie = Mechanize::Cookie.new("auth_secure", auth_secure)
|
||||||
|
cookie.domain = ".deviantart.com"
|
||||||
|
cookie.path = "/"
|
||||||
|
mech.cookie_jar.add(cookie)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mech
|
mech
|
||||||
@@ -166,9 +173,10 @@ module Sources
|
|||||||
|
|
||||||
auth = mech.cookies.find { |cookie| cookie.name == "auth" }.try(:value)
|
auth = mech.cookies.find { |cookie| cookie.name == "auth" }.try(:value)
|
||||||
userinfo = mech.cookies.find { |cookie| cookie.name == "userinfo" }.try(:value)
|
userinfo = mech.cookies.find { |cookie| cookie.name == "userinfo" }.try(:value)
|
||||||
|
auth_secure = mech.cookies.find { |cookie| cookie.name == "auth_secure" }.try(:value)
|
||||||
mech.cookie_jar.clear
|
mech.cookie_jar.clear
|
||||||
|
|
||||||
[auth, userinfo]
|
[auth, userinfo, auth_secure]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user