about summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2019-09-30 03:10:59 +0200
committeraszlig <aszlig@nix.build>2019-09-30 03:43:06 +0200
commit348fd31a0a597b73259d6c51988686356e136785 (patch)
tree470a3bd07c406fd4f52da1ef53427292d967d90b /pkgs/games
parenta6b50f6c417b568ed82f6370bbb65667b5ca48c7 (diff)
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 <aszlig@nix.build>
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/gog/fetch-gog/default.nix29
1 files changed, 20 insertions, 9 deletions
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