Commit 332503d7 authored by Mikhail Tergoev's avatar Mikhail Tergoev

added finding ppdb files

parent 4829f278
......@@ -8236,3 +8236,49 @@ update_ext_ppdb () {
fatal "ppdb file \"$1\" not found!"
fi
}
find_ext_ppdb () {
if [[ -z "$1" ]] || [[ ! -f "$1" ]] ; then
fatal "Broken arguments for function: find_ext_ppdb"
fi
local exe_filename find_metadata_url get_ppdb_info current_ppdb_file
exe_filename="$(basename "$1")"
current_ppdb_file="${1}.ppdb"
find_metadata_url="https://ppdb.linux-gaming.ru/api/lookup/exe/$exe_filename"
print_info "Get metadata from $find_metadata_url"
get_ppdb_info=$(curl -A 'PortProton' -s "$find_metadata_url")
if [[ -z "$get_ppdb_info" ]] ; then
yad_error "${translations[Error: failed to fetch metadata.]}\n($find_metadata_url)"
restart_pp
elif [[ "$get_ppdb_info" =~ 'No game found' ]] ; then
yad_error "${translations[Error: settings file not found for]} $exe_filename"
restart_pp
fi
source <(jq -r 'to_entries[] | "json_\(.key)=\"\(.value)\""' <<< "$get_ppdb_info")
print_info "New variables from $find_metadata_url:"
declare -p ${!json_@} | awk -F'--' '{print $2}'
if yad_question "\
${translations[Settings file was found for]} $exe_filename:
${translations[Name]}: $json_name
${translations[Rating]}: $json_rating
${translations[URL]}: $json_url
${translations[Would you like to use this settings file?]}"
then
print_info "Replacing PPDB from: $json_ppdb_url"
try_remove_file "$current_ppdb_file"
if curl -A 'PortProton' -fsSL "$json_ppdb_url" -o "$current_ppdb_file" ; then
restart_pp
else
yad_error "${translations[Failed to download PPDB from URL: $json_ppdb_url]}"
exit 1
fi
else
restart_pp
fi
}
......@@ -95,7 +95,7 @@ elif [[ "$1" == portproton://* ]] ; then
PW_TMP_PPDB_FILE="$PW_TMPFS_PATH/tmp_from_url.ppdb"
print_info "Downloading PPDB from: $PPDB_URL"
if curl -fsSL "$PPDB_URL" -o "$PW_TMP_PPDB_FILE" ; then
if curl -A 'PortProton' -fsSL "$PPDB_URL" -o "$PW_TMP_PPDB_FILE" ; then
update_ext_ppdb "$PW_TMP_PPDB_FILE" "url"
else
fatal "Failed to download PPDB from URL: $PPDB_URL"
......@@ -757,6 +757,7 @@ if [[ -f "$portwine_exe" ]] ; then
--field=" MangoHud!$PW_GUI_ICON_PATH/$BUTTON_SIZE.png!${translations[Enable Mangohud by default (R_SHIFT + F12 keyboard shortcuts disable Mangohud)]}":"FBTN" '@bash -c "button_click --start 122"' \
--field=" dgVoodoo2!$PW_GUI_ICON_PATH/$BUTTON_SIZE.png!${translations[Enable dgVoodoo2 by default (This wrapper fixes many compatibility and rendering issues when running old games)]}":"FBTN" '@bash -c "button_click --start 124"' \
--field=" GameScope!$PW_GUI_ICON_PATH/$BUTTON_SIZE.png!${translations[Enable GameScope by default (Wayland micro compositor)]}":"FBTN" '@bash -c "button_click --start 126"' \
--field=" ${translations[Find settings (ppdb)]}!$PW_GUI_ICON_PATH/$BUTTON_SIZE.png!${translations[Try to find the settings on the website ppdb.linux-gaming.ru and apply them.]}":"FBTN" '@bash -c "button_click --start find_ext_ppdb"' \
2>/dev/null &
if [[ $PW_GUI_START == "NOTEBOOK" ]] ; then
......@@ -1199,6 +1200,7 @@ case "$PW_YAD_SET" in
open_changelog) open_changelog ;;
change_loc) change_loc ;;
open_game_folder) open_game_folder ;;
find_ext_ppdb) find_ext_ppdb "$portwine_exe" ;;
118) gui_edit_db ;;
120) gui_vkbasalt ;;
122) gui_mangohud ;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment