POL_GoG_login

Informations

Créateur Messages
Ground0

Information

Cet installateur a été accepté par l'équipe.

Informations

Plate-formes :
Téléchargements : 171329
Wine: System

Retours d'expérience

Description

Create a Login Session Cookie and set the var GOG_LOGIN to Ok if successfull and if the User Cancel it exit.

Code source

#!/usr/bin/env playonlinux-bash

# CHANGELOG
# [Ground0] (2016-02-17 09:45)
#   Initial Version
#
# Date : (2016-02-17 09:45)
# Last revision : (2016-02-17 09:45)
# Distribution used to test : OpenSUSE Tumbleweed / openSUSE Leap 42.1 / OS X 10.11.2
# Author : René Linder rene.linder@lihaso.ch
# Script licence : GPL v.2
# Depend :

#############################################
#
# Login / open session for using
#
#
# The Cookies:
#

local COOKIES="$POL_USER_ROOT/tmp/gog_cookies"
local COOKIES_2="$POL_USER_ROOT/tmp/gog_cookies2"
local COOKIES_3="$POL_USER_ROOT/tmp/gog_cookies3"
local COOKIES_4="$POL_USER_ROOT/tmp/gog_cookies4"
COOKIES_FINAL="$POL_USER_ROOT/tmp/gog_cookie_logedin"

local USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36"

local APP_ANSWER

while true; do
        POL_SetupWindow_login "$(eval_gettext 'Please enter your gog.com login to download $BASENAME')" "$TITLE" "http://www.gog.com/"

        POL_SetupWindow_wait "$(eval_gettext 'Please wait...')" "$TITLE"
        
    ##########################
    #
    # Cleanup existing cookies:
    # 
        
        rm "$COOKIES" 2> /dev/null
        rm "$COOKIES_2" 2> /dev/null
        rm "$COOKIES_3" 2> /dev/null
        rm "$COOKIES_4" 2> /dev/null
        rm "$COOKIES_FINAL" 2> /dev/null
        
        ##########################
        #
        # Get the Login Link:
        #
        
        local login_link="$($POL_WGET https://www.gog.com -O- --keep-session-cookies --save-cookies=$COOKIES --user-agent="$USER_AGENT" | sed -ne "s@.*'\(https://auth.gog.com/[^']*\)'.*@\1@p")"
    
    POL_Debug_Message "Login Link: $login_link"
    
    ##########################
    #
    # Get the initial Cookie
    #
    
    $POL_WGET https://www.gog.com/userData.json -O- --keep-session-cookies --save-cookies=$COOKIES_2 --load-cookies=$COOKIES --referer=https://www.gog.com/ --user-agent="$USER_AGENT" 
    
    ##########################
    #
    # Get the Login session token
    
        local token="$($POL_WGET "$login_link" -O- --keep-session-cookies --save-cookies=$COOKIES_3 --load-cookies=$COOKIES_2 --referer=https://www.gog.com/ --user-agent="$USER_AGENT" | sed -ne 's@.*<input type="hidden" id="login__token" name="login\[_token\]" value="\([^"]*\)" />.*@\1@p')"

    POL_Debug_Message "token: $token"
        
        ##########################
        #
        # Main Login part:
        #
        # RegEx to get the token : <input type="hidden" id="login__token" name="login\[_token\]" value="(.*?)" \/>
        # 

        $POL_WGET https://login.gog.com/login_check -O- --keep-session-cookies --save-cookies=$COOKIES_4 --load-cookies=$COOKIES_3 --post-data="login%5Busername%5D=$(POL_Website_urlencode "$POL_LOGIN")&login%5Bpassword%5D=$(POL_Website_urlencode "$POL_PASSWORD")&login%5Blogin%5D=&login%5B_token%5D=$token" --no-check-certificate  --referer=$login_link --user-agent="$USER_AGENT"
        
        POL_Debug_Message "info: $outputget"

        ##########################
        #
        # Clear Login informations from vars.
        
        unset POL_LOGIN POL_PASSWORD

        ##########################
        #
        # Generate the final Cookie
        # To get it call again : https://www.gog.com/userData.json

        $POL_WGET https://www.gog.com/userData.json -O- --keep-session-cookies --save-cookies=$COOKIES_FINAL --load-cookies=$COOKIES_4 --referer=https://www.gog.com/ --user-agent="$USER_AGENT"

        ##########################
        #
        # Test if the Cookie has the gog_us session code inside.
        #
        local AUTH_SESSION="$(awk '$6 == "gog_us" { print $7 }' $COOKIES_FINAL)"
        [ "$AUTH_SESSION" ] && GOG_LOGIN="Ok" && POL_Debug_Message "AUTH SESSION: $AUTH_SESSION" && break
        
        unset AUTH_SESSION

        POL_SetupWindow_question "$(eval_gettext 'Gog.com login failed, try again?')" "$TITLE"
        if [ "$APP_ANSWER" = "FALSE" ]; then
                POL_SetupWindow_Close
                exit 1
        fi
done

Contributions

Filters:

Contribuer
Membre Messages
petch Mercredi 17 Février 2016 à 20:09
petch

Information

Cette mise à jour a été acceptée par l'équipe

Messages

Make variables local to avoid polluting the environment ;)

Differences

@@ -19,13 +19,15 @@
 # The Cookies:
 #
 
-COOKIES="$POL_USER_ROOT/tmp/gog_cookies"
-COOKIES_2="$POL_USER_ROOT/tmp/gog_cookies2"
-COOKIES_3="$POL_USER_ROOT/tmp/gog_cookies3"
-COOKIES_4="$POL_USER_ROOT/tmp/gog_cookies4"
+local COOKIES="$POL_USER_ROOT/tmp/gog_cookies"
+local COOKIES_2="$POL_USER_ROOT/tmp/gog_cookies2"
+local COOKIES_3="$POL_USER_ROOT/tmp/gog_cookies3"
+local COOKIES_4="$POL_USER_ROOT/tmp/gog_cookies4"
 COOKIES_FINAL="$POL_USER_ROOT/tmp/gog_cookie_logedin"
 
-USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36"
+local USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36"
+
+local APP_ANSWER
 
 while true; do
 	POL_SetupWindow_login "$(eval_gettext 'Please enter your gog.com login to download $BASENAME')" "$TITLE" "http://www.gog.com/"
@@ -48,7 +50,7 @@
 	# Get the Login Link:
 	#
 	
-	login_link="$($POL_WGET https://www.gog.com -O- --keep-session-cookies --save-cookies=$COOKIES --user-agent="$USER_AGENT" | sed -ne "s@.*'\(https://auth.gog.com/[^']*\)'.*@\1@p")"
+	local login_link="$($POL_WGET https://www.gog.com -O- --keep-session-cookies --save-cookies=$COOKIES --user-agent="$USER_AGENT" | sed -ne "s@.*'\(https://auth.gog.com/[^']*\)'.*@\1@p")"
     
     POL_Debug_Message "Login Link: $login_link"
     
@@ -63,7 +65,7 @@
     #
     # Get the Login session token
     
-	token="$($POL_WGET "$login_link" -O- --keep-session-cookies --save-cookies=$COOKIES_3 --load-cookies=$COOKIES_2 --referer=https://www.gog.com/ --user-agent="$USER_AGENT" | sed -ne 's@.*<input type="hidden" id="login__token" name="login\[_token\]" value="\([^"]*\)" />.*@\1@p')"
+	local token="$($POL_WGET "$login_link" -O- --keep-session-cookies --save-cookies=$COOKIES_3 --load-cookies=$COOKIES_2 --referer=https://www.gog.com/ --user-agent="$USER_AGENT" | sed -ne 's@.*<input type="hidden" id="login__token" name="login\[_token\]" value="\([^"]*\)" />.*@\1@p')"
 
     POL_Debug_Message "token: $token"
 	
@@ -95,14 +97,14 @@
 	#
 	# Test if the Cookie has the gog_us session code inside.
 	#
-	AUTH_SESSION="$(awk '$6 == "gog_us" { print $7 }' $COOKIES_FINAL)"
-	[ "$AUTH_SESSION" != "" ] && GOG_LOGIN="Ok" && POL_Debug_Message "AUTH SESSION: $AUTH_SESSION" && break
+	local AUTH_SESSION="$(awk '$6 == "gog_us" { print $7 }' $COOKIES_FINAL)"
+	[ "$AUTH_SESSION" ] && GOG_LOGIN="Ok" && POL_Debug_Message "AUTH SESSION: $AUTH_SESSION" && break
 	
 	unset AUTH_SESSION
 
 	POL_SetupWindow_question "$(eval_gettext 'Gog.com login failed, try again?')" "$TITLE"
 	if [ "$APP_ANSWER" = "FALSE" ]; then
 		POL_SetupWindow_Close
-		exit
+		exit 1
 	fi
 done

Nouveau code source

#!/usr/bin/env playonlinux-bash

# CHANGELOG
# [Ground0] (2016-02-17 09:45)
#   Initial Version
#
# Date : (2016-02-17 09:45)
# Last revision : (2016-02-17 09:45)
# Distribution used to test : OpenSUSE Tumbleweed / openSUSE Leap 42.1 / OS X 10.11.2
# Author : René Linder rene.linder@lihaso.ch
# Script licence : GPL v.2
# Depend :

#############################################
#
# Login / open session for using
#
#
# The Cookies:
#

local COOKIES="$POL_USER_ROOT/tmp/gog_cookies"
local COOKIES_2="$POL_USER_ROOT/tmp/gog_cookies2"
local COOKIES_3="$POL_USER_ROOT/tmp/gog_cookies3"
local COOKIES_4="$POL_USER_ROOT/tmp/gog_cookies4"
COOKIES_FINAL="$POL_USER_ROOT/tmp/gog_cookie_logedin"

local USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36"

local APP_ANSWER

while true; do
        POL_SetupWindow_login "$(eval_gettext 'Please enter your gog.com login to download $BASENAME')" "$TITLE" "http://www.gog.com/"

        POL_SetupWindow_wait "$(eval_gettext 'Please wait...')" "$TITLE"
        
    ##########################
    #
    # Cleanup existing cookies:
    # 
        
        rm "$COOKIES" 2> /dev/null
        rm "$COOKIES_2" 2> /dev/null
        rm "$COOKIES_3" 2> /dev/null
        rm "$COOKIES_4" 2> /dev/null
        rm "$COOKIES_FINAL" 2> /dev/null
        
        ##########################
        #
        # Get the Login Link:
        #
        
        local login_link="$($POL_WGET https://www.gog.com -O- --keep-session-cookies --save-cookies=$COOKIES --user-agent="$USER_AGENT" | sed -ne "s@.*'\(https://auth.gog.com/[^']*\)'.*@\1@p")"
    
    POL_Debug_Message "Login Link: $login_link"
    
    ##########################
    #
    # Get the initial Cookie
    #
    
    $POL_WGET https://www.gog.com/userData.json -O- --keep-session-cookies --save-cookies=$COOKIES_2 --load-cookies=$COOKIES --referer=https://www.gog.com/ --user-agent="$USER_AGENT" 
    
    ##########################
    #
    # Get the Login session token
    
        local token="$($POL_WGET "$login_link" -O- --keep-session-cookies --save-cookies=$COOKIES_3 --load-cookies=$COOKIES_2 --referer=https://www.gog.com/ --user-agent="$USER_AGENT" | sed -ne 's@.*<input type="hidden" id="login__token" name="login\[_token\]" value="\([^"]*\)" />.*@\1@p')"

    POL_Debug_Message "token: $token"
        
        ##########################
        #
        # Main Login part:
        #
        # RegEx to get the token : <input type="hidden" id="login__token" name="login\[_token\]" value="(.*?)" \/>
        # 

        $POL_WGET https://login.gog.com/login_check -O- --keep-session-cookies --save-cookies=$COOKIES_4 --load-cookies=$COOKIES_3 --post-data="login%5Busername%5D=$(POL_Website_urlencode "$POL_LOGIN")&login%5Bpassword%5D=$(POL_Website_urlencode "$POL_PASSWORD")&login%5Blogin%5D=&login%5B_token%5D=$token" --no-check-certificate  --referer=$login_link --user-agent="$USER_AGENT"
        
        POL_Debug_Message "info: $outputget"

        ##########################
        #
        # Clear Login informations from vars.
        
        unset POL_LOGIN POL_PASSWORD

        ##########################
        #
        # Generate the final Cookie
        # To get it call again : https://www.gog.com/userData.json

        $POL_WGET https://www.gog.com/userData.json -O- --keep-session-cookies --save-cookies=$COOKIES_FINAL --load-cookies=$COOKIES_4 --referer=https://www.gog.com/ --user-agent="$USER_AGENT"

        ##########################
        #
        # Test if the Cookie has the gog_us session code inside.
        #
        local AUTH_SESSION="$(awk '$6 == "gog_us" { print $7 }' $COOKIES_FINAL)"
        [ "$AUTH_SESSION" ] && GOG_LOGIN="Ok" && POL_Debug_Message "AUTH SESSION: $AUTH_SESSION" && break
        
        unset AUTH_SESSION

        POL_SetupWindow_question "$(eval_gettext 'Gog.com login failed, try again?')" "$TITLE"
        if [ "$APP_ANSWER" = "FALSE" ]; then
                POL_SetupWindow_Close
                exit 1
        fi
done

Réponses

Ground0 Mercredi 17 Février 2016 à 10:13
Ground0

Warning

Cette mise à jour n'a pas été approuvée par l'équipe.
Utilisez-la à vos risques et périls

Differences

@@ -0,0 +1,108 @@
+#!/usr/bin/env playonlinux-bash
+
+# CHANGELOG
+# [Ground0] (2016-02-17 09:45)
+#   Initial Version
+#
+# Date : (2016-02-17 09:45)
+# Last revision : (2016-02-17 09:45)
+# Distribution used to test : OpenSUSE Tumbleweed / openSUSE Leap 42.1 / OS X 10.11.2
+# Author : René Linder rene.linder@lihaso.ch
+# Script licence : GPL v.2
+# Depend :
+
+#############################################
+#
+# Login / open session for using
+#
+#
+# The Cookies:
+#
+
+COOKIES="$POL_USER_ROOT/tmp/gog_cookies"
+COOKIES_2="$POL_USER_ROOT/tmp/gog_cookies2"
+COOKIES_3="$POL_USER_ROOT/tmp/gog_cookies3"
+COOKIES_4="$POL_USER_ROOT/tmp/gog_cookies4"
+COOKIES_FINAL="$POL_USER_ROOT/tmp/gog_cookie_logedin"
+
+USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36"
+
+while true; do
+	POL_SetupWindow_login "$(eval_gettext 'Please enter your gog.com login to download $BASENAME')" "$TITLE" "http://www.gog.com/"
+
+	POL_SetupWindow_wait "$(eval_gettext 'Please wait...')" "$TITLE"
+	
+    ##########################
+    #
+    # Cleanup existing cookies:
+    # 
+	
+	rm "$COOKIES" 2> /dev/null
+	rm "$COOKIES_2" 2> /dev/null
+	rm "$COOKIES_3" 2> /dev/null
+	rm "$COOKIES_4" 2> /dev/null
+	rm "$COOKIES_FINAL" 2> /dev/null
+	
+	##########################
+	#
+	# Get the Login Link:
+	#
+	
+	login_link="$($POL_WGET https://www.gog.com -O- --keep-session-cookies --save-cookies=$COOKIES --user-agent="$USER_AGENT" | sed -ne "s@.*'\(https://auth.gog.com/[^']*\)'.*@\1@p")"
+    
+    POL_Debug_Message "Login Link: $login_link"
+    
+    ##########################
+    #
+    # Get the initial Cookie
+    #
+    
+    $POL_WGET https://www.gog.com/userData.json -O- --keep-session-cookies --save-cookies=$COOKIES_2 --load-cookies=$COOKIES --referer=https://www.gog.com/ --user-agent="$USER_AGENT" 
+    
+    ##########################
+    #
+    # Get the Login session token
+    
+	token="$($POL_WGET "$login_link" -O- --keep-session-cookies --save-cookies=$COOKIES_3 --load-cookies=$COOKIES_2 --referer=https://www.gog.com/ --user-agent="$USER_AGENT" | sed -ne 's@.*<input type="hidden" id="login__token" name="login\[_token\]" value="\([^"]*\)" />.*@\1@p')"
+
+    POL_Debug_Message "token: $token"
+	
+	##########################
+	#
+	# Main Login part:
+	#
+	# RegEx to get the token : <input type="hidden" id="login__token" name="login\[_token\]" value="(.*?)" \/>
+	# 
+
+	$POL_WGET https://login.gog.com/login_check -O- --keep-session-cookies --save-cookies=$COOKIES_4 --load-cookies=$COOKIES_3 --post-data="login%5Busername%5D=$(POL_Website_urlencode "$POL_LOGIN")&login%5Bpassword%5D=$(POL_Website_urlencode "$POL_PASSWORD")&login%5Blogin%5D=&login%5B_token%5D=$token" --no-check-certificate  --referer=$login_link --user-agent="$USER_AGENT"
+	
+	POL_Debug_Message "info: $outputget"
+
+	##########################
+	#
+	# Clear Login informations from vars.
+	
+	unset POL_LOGIN POL_PASSWORD
+
+	##########################
+	#
+	# Generate the final Cookie
+	# To get it call again : https://www.gog.com/userData.json
+
+	$POL_WGET https://www.gog.com/userData.json -O- --keep-session-cookies --save-cookies=$COOKIES_FINAL --load-cookies=$COOKIES_4 --referer=https://www.gog.com/ --user-agent="$USER_AGENT"
+
+	##########################
+	#
+	# Test if the Cookie has the gog_us session code inside.
+	#
+	AUTH_SESSION="$(awk '$6 == "gog_us" { print $7 }' $COOKIES_FINAL)"
+	[ "$AUTH_SESSION" != "" ] && GOG_LOGIN="Ok" && POL_Debug_Message "AUTH SESSION: $AUTH_SESSION" && break
+	
+	unset AUTH_SESSION
+
+	POL_SetupWindow_question "$(eval_gettext 'Gog.com login failed, try again?')" "$TITLE"
+	if [ "$APP_ANSWER" = "FALSE" ]; then
+		POL_SetupWindow_Close
+		exit
+	fi
+done

Nouveau code source

#!/usr/bin/env playonlinux-bash

# CHANGELOG
# [Ground0] (2016-02-17 09:45)
#   Initial Version
#
# Date : (2016-02-17 09:45)
# Last revision : (2016-02-17 09:45)
# Distribution used to test : OpenSUSE Tumbleweed / openSUSE Leap 42.1 / OS X 10.11.2
# Author : René Linder rene.linder@lihaso.ch
# Script licence : GPL v.2
# Depend :

#############################################
#
# Login / open session for using
#
#
# The Cookies:
#

COOKIES="$POL_USER_ROOT/tmp/gog_cookies"
COOKIES_2="$POL_USER_ROOT/tmp/gog_cookies2"
COOKIES_3="$POL_USER_ROOT/tmp/gog_cookies3"
COOKIES_4="$POL_USER_ROOT/tmp/gog_cookies4"
COOKIES_FINAL="$POL_USER_ROOT/tmp/gog_cookie_logedin"

USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36"

while true; do
        POL_SetupWindow_login "$(eval_gettext 'Please enter your gog.com login to download $BASENAME')" "$TITLE" "http://www.gog.com/"

        POL_SetupWindow_wait "$(eval_gettext 'Please wait...')" "$TITLE"
        
    ##########################
    #
    # Cleanup existing cookies:
    # 
        
        rm "$COOKIES" 2> /dev/null
        rm "$COOKIES_2" 2> /dev/null
        rm "$COOKIES_3" 2> /dev/null
        rm "$COOKIES_4" 2> /dev/null
        rm "$COOKIES_FINAL" 2> /dev/null
        
        ##########################
        #
        # Get the Login Link:
        #
        
        login_link="$($POL_WGET https://www.gog.com -O- --keep-session-cookies --save-cookies=$COOKIES --user-agent="$USER_AGENT" | sed -ne "s@.*'\(https://auth.gog.com/[^']*\)'.*@\1@p")"
    
    POL_Debug_Message "Login Link: $login_link"
    
    ##########################
    #
    # Get the initial Cookie
    #
    
    $POL_WGET https://www.gog.com/userData.json -O- --keep-session-cookies --save-cookies=$COOKIES_2 --load-cookies=$COOKIES --referer=https://www.gog.com/ --user-agent="$USER_AGENT" 
    
    ##########################
    #
    # Get the Login session token
    
        token="$($POL_WGET "$login_link" -O- --keep-session-cookies --save-cookies=$COOKIES_3 --load-cookies=$COOKIES_2 --referer=https://www.gog.com/ --user-agent="$USER_AGENT" | sed -ne 's@.*<input type="hidden" id="login__token" name="login\[_token\]" value="\([^"]*\)" />.*@\1@p')"

    POL_Debug_Message "token: $token"
        
        ##########################
        #
        # Main Login part:
        #
        # RegEx to get the token : <input type="hidden" id="login__token" name="login\[_token\]" value="(.*?)" \/>
        # 

        $POL_WGET https://login.gog.com/login_check -O- --keep-session-cookies --save-cookies=$COOKIES_4 --load-cookies=$COOKIES_3 --post-data="login%5Busername%5D=$(POL_Website_urlencode "$POL_LOGIN")&login%5Bpassword%5D=$(POL_Website_urlencode "$POL_PASSWORD")&login%5Blogin%5D=&login%5B_token%5D=$token" --no-check-certificate  --referer=$login_link --user-agent="$USER_AGENT"
        
        POL_Debug_Message "info: $outputget"

        ##########################
        #
        # Clear Login informations from vars.
        
        unset POL_LOGIN POL_PASSWORD

        ##########################
        #
        # Generate the final Cookie
        # To get it call again : https://www.gog.com/userData.json

        $POL_WGET https://www.gog.com/userData.json -O- --keep-session-cookies --save-cookies=$COOKIES_FINAL --load-cookies=$COOKIES_4 --referer=https://www.gog.com/ --user-agent="$USER_AGENT"

        ##########################
        #
        # Test if the Cookie has the gog_us session code inside.
        #
        AUTH_SESSION="$(awk '$6 == "gog_us" { print $7 }' $COOKIES_FINAL)"
        [ "$AUTH_SESSION" != "" ] && GOG_LOGIN="Ok" && POL_Debug_Message "AUTH SESSION: $AUTH_SESSION" && break
        
        unset AUTH_SESSION

        POL_SetupWindow_question "$(eval_gettext 'Gog.com login failed, try again?')" "$TITLE"
        if [ "$APP_ANSWER" = "FALSE" ]; then
                POL_SetupWindow_Close
                exit
        fi
done

Réponses

This site allows content generated by members, and we promptly remove any content that infringes copyright according to our Terms of Service. To report copyright infringement, please send a notice to dmca-notice@playonlinux.com