MadeBaruna / paimon-moe

Your best Genshin Impact companion! Help you plan what to farm with ascension calculator and database. Also track your progress with todo and wish counter.
https://paimon.moe
MIT License
1.39k stars 268 forks source link

Wish History on Linux #526

Open Cha14ka opened 8 months ago

Cha14ka commented 8 months ago

If someone needs to get history easily on Linux without manually opening data_2, here's a Bash script

#!/usr/bin/env bash
set -e
GIPATH="."

function get_path_from_pid() {
    # tee eats the status value
    _pid=$(pgrep -f -- "GenshinImpact.exe" | tee)
    if [ -z "$_pid" ]; then
        _pid=$(pgrep -f -- "YuanShen.exe" | tee)
    fi
    [ -z "$_pid" ] && echo "Game process not found" && exit 1
    GIPATH=$(pwdx "$_pid")
    GIPATH=${GIPATH#*\ } # remove leading "pid: "
}

get_path_from_pid

# Get the most recently modified "data_2" file: ISO timestamp + absolute path
CACHEFILE=$(find "$GIPATH" -type f -wholename '*/Cache_Data/data_2' -printf "%T+ %p\n" | sort | tail -n 1)
CACHEFILE=${CACHEFILE#*\ } # remove leading timestamp
echo "Found cache file: $CACHEFILE"
echo "===== Matching links:"

strings "$CACHEFILE" | grep -o "https://.*/e20190909gacha-v2/.*" | tail -n1
MeGA-ct commented 4 months ago

Hi, I was just testing this and I think the url has changed from e20190909gacha-v2 to e20190909gacha-v3.

Cha14ka commented 4 months ago

Hi, I was just testing this and I think the url has changed from e20190909gacha-v2 to e20190909gacha-v3.

Yeah. You'd better use it from this link. I'm keeping an eye on the updates in this repo. https://notabug.org/Krock/dawn/src/master/compat/get_gacha_url.sh


#!/usr/bin/env bash
# DESCRIPTION
#     Extracts the gacha URL from the Chromium Embedded Framework cache.
#     The file paths are detected automatically based on the game process ID
#     and executable path.
#
# NOTES
#     This script currently returns the last URL in the cache file, which
#     usually works but is not entirely reliable.
#
# EXIT STATUS
#     0 on success

set -e
GIPATH="."

function get_path_from_pid() {
    # tee eats the status value
    _pid=$(pgrep -f -- "GenshinImpact.exe" | tee | head -1)
    if [ -z "$_pid" ]; then
        _pid=$(pgrep -f -- "YuanShen.exe" | tee | head -1)
    fi
    [ -z "$_pid" ] && echo "Game process not found" && exit 1
    GIPATH=$(pwdx "$_pid")
    GIPATH=${GIPATH#*\ } # remove leading "pid: "
}

get_path_from_pid

# Get the most recently modified "data_2" file: ISO timestamp + absolute path
CACHEFILE=$(find "$GIPATH" -type f -wholename '*/Cache_Data/data_2' -printf "%T+ %p\n" | sort | tail -n 1)
CACHEFILE=${CACHEFILE#*\ } # remove leading timestamp
echo "Found cache file: $CACHEFILE"
echo "===== Matching links:"

strings "$CACHEFILE" | grep -o "https://.*/e20190909gacha-v3/.*" | tail -n1```
MeGA-ct commented 4 months ago

Oh, thx, I'll bookmark that.