From 348fd31a0a597b73259d6c51988686356e136785 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 30 Sep 2019 03:10:59 +0200 Subject: fetch-gog: Fix login with captcha The way GOG embeds recaptcha has changed a while ago and it's now embedded via additional JavaScript which no longer directly contains "google.com/recaptcha", because it is now contained within an iframe. Fortunately, the fix is relatively easy, because everything else is still implemented in the same way, we just need to match portions of that JavaScript code. I also fixed up the Qt plugin path for the captcha prompt if a newer nixpkgs revision is used, where we have wrapQtAppsHook. Signed-off-by: aszlig --- pkgs/games/gog/fetch-gog/default.nix | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'pkgs/games') diff --git a/pkgs/games/gog/fetch-gog/default.nix b/pkgs/games/gog/fetch-gog/default.nix index d4a35a05..c1d350ce 100644 --- a/pkgs/games/gog/fetch-gog/default.nix +++ b/pkgs/games/gog/fetch-gog/default.nix @@ -147,14 +147,24 @@ let } ''; - in runCommandCC "get-captcha" { - nativeBuildInputs = [ pkgconfig ]; + in stdenv.mkDerivation { + name = "get-captcha"; + + dontUnpack = true; + + nativeBuildInputs = [ pkgconfig (qt5.wrapQtAppsHook or null) ]; buildInputs = [ qt5.qtbase qt5.qtwebengine ]; preferLocalBuild = true; - } '' - g++ $(pkg-config --libs --cflags Qt5WebEngineWidgets Qt5WebEngine) \ - -Wall -std=c++11 -o "$out" ${application} - ''; + + buildPhase = '' + g++ $(pkg-config --libs --cflags Qt5WebEngineWidgets Qt5WebEngine) \ + -Wall -std=c++11 -o get-captcha ${application} + ''; + + installPhase = '' + install -vD get-captcha "$out/bin/get-captcha" + ''; + }; mkPyStr = str: "'${stdenv.lib.escape ["'" "\\"] (toString str)}'"; @@ -178,7 +188,7 @@ let def login(self): browser = mechanicalsoup.StatefulBrowser() response = browser.open(${mkPyStr authURL}) - if "google.com/recaptcha" in response.text: + if "https://www.recaptcha.net/recaptcha" in response.text: token_url = self.login_with_captcha() else: browser.select_form('form[name="login"]') @@ -190,7 +200,7 @@ let if 'code' not in query: sys.stderr.write( - "Unable to login with the provided GOG credentials." + "Unable to login with the provided GOG credentials.\n" ) raise SystemExit(1) @@ -210,7 +220,8 @@ let def login_with_captcha(self): sys.stderr.write("Solving a captcha is required to log in.\n") - sys.stderr.write("Please run " ${mkPyStr getCaptcha} " now.\n") + sys.stderr.write("Please run " ${mkPyStr getCaptcha} + "/bin/get-captcha now.\n") sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sys.stderr.write("Waiting for connection") i = 0 -- cgit 1.4.1