<commit_before>#!/usr/bin/env bash
# Usage: wb.sh [eu|na|tr|vn]

cd `dirname $0`

error()
{
    echo "failed"
    exit $1
}

case "$1" in
    eu|na|tr )
        read -p "Email: " email
        read -s -p "Password: " psswd
        echo
        echo -n 'Connecting...'

        res=$(curl -ks \
            --data-urlencode "email=${email}" \
            --data-urlencode "pwd=${<PASSWORD>}" \
            'https://gface.com/api/-text/auth/login.json') || error 3

        echo "$res" | grep 'fail' && error 1
        echo 'done'

        token=$(echo "$res" | sed 's/^.*token":"\([-0-9a-f]*\).*$/\1/')
        userid=$(echo "$res" | sed 's/^.*userid":\([0-9]*\).*$/\1/')
        ;;

    vn )
        read -p "Username: " username
        read -s -p "Password: " psswd
        echo
        echo -n 'Connecting...'

        psswd=$(echo "$psswd" | md5sum | sed 's/ .*//')
        ip=$(dig +short myip.opendns.com @resolver1.opendns.com)

        res=$(curl -Gs \
            --data-urlencode "username=${username}" \
            --data-urlencode "password=${<PASSWORD>}" \
            --data "cpid=10001" \
            --data "clientip=${ip}" \
            --data "sign=9a8c2995cc35eb97ec33b203c68200c9" \
            'http://account.goplay.vn/fastlogin') || error 3

        echo "$res" | grep -- '"ret":-' && error 1
        echo 'done'

        token=$(echo "$res" | sed 's/^.*token":"\([-0-9a-f]*\).*$/\1/')
        userid=$(echo "$res" | sed 's/^.*ret":\([0-9]*\).*$/\1/')
        ;;

    * )
        echo "Unimplemented"
        error 2<commit_msg>Fix auth script for Vietnam version<commit_after>#!/usr/bin/env bash
# Usage: wb.sh [eu|na|tr|vn]

cd `dirname $0`

error()
{
    echo "failed"
    exit $1
}

case "$1" in
    eu|na|tr )
        read -p "Email: " email
        read -s -p "Password: " psswd
        echo
        echo -n 'Connecting...'

        res=$(curl -ks \
            --data-urlencode "email=${email}" \
            --data-urlencode "pwd=${<PASSWORD>}" \
            'https://gface.com/api/-text/auth/login.json') || error 3

        echo "$res" | grep 'fail' && error 1
        echo 'done'

        token=$(echo "$res" | sed 's/^.*token":"\([-0-9a-f]*\).*$/\1/')
        userid=$(echo "$res" | sed 's/^.*userid":\([0-9]*\).*$/\1/')
        ;;

    vn )
        read -p "Username: " username
        read -s -p "Password: " psswd
        echo
        echo -n 'Connecting...'

        psswd=$(echo -n "$psswd" | md5sum | sed 's/ .*//')
        ip=$(dig +short myip.opendns.com @resolver1.opendns.com)

        res=$(curl -Gs \
            --data-urlencode "username=${username}" \
            --data-urlencode "password=${<PASSWORD>}" \
            --data "cpid=100001" \
            --data "clientip=${ip}" \
            --data "sign=9a8c2995cc35eb97ec33b203c68200c9" \
            'http://account.goplay.vn/fastlogin') || error 3

        echo "$res" | grep -- '"ret":-' && error 1
        echo 'done'

        token=$(echo "$res" | sed 's/^.*token":"\([^"]*\).*$/\1/')
        userid=$(echo "$res" | sed 's/^.*ret":\([0-9]*\).*$/\1/')
        ;;

    * )
        echo "Unimplemented"
        error 2
{'fraction_non_alphanumeric': 0.224, 'fraction_numerical': 0.0304, 'mean_word_length': 1.6291000841042893, 'pattern_counts': {'":': 10, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2685463', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1138, 'n_words': 231}