tasks now uses steam api to get game name
This commit is contained in:
parent
091303fc88
commit
5bf5161d93
@ -1,5 +1,5 @@
|
|||||||
#! /usr/bin/env nix-shell
|
#! /usr/bin/env nix-shell
|
||||||
#! nix-shell -i bash -p bash trashy fd ripgrep file
|
#! nix-shell -i bash -p bash trashy fd ripgrep file jq
|
||||||
|
|
||||||
directories=("$HOME/Pictures/To Organize/" "$HOME/Downloads/" "$HOME/Downloads/cache")
|
directories=("$HOME/Pictures/To Organize/" "$HOME/Downloads/" "$HOME/Downloads/cache")
|
||||||
|
|
||||||
@ -66,30 +66,42 @@ fi
|
|||||||
|
|
||||||
# Where steam screenshots are stored, may need to replace with ur ID
|
# Where steam screenshots are stored, may need to replace with ur ID
|
||||||
dir_steam=$XDG_DATA_HOME/Steam/userdata/107446271/760/remote
|
dir_steam=$XDG_DATA_HOME/Steam/userdata/107446271/760/remote
|
||||||
declare -A games
|
cache_file="$dir_steam/game_cache"
|
||||||
# Insert here new games, put between [] the ID of the game
|
if ! [[ -f $cache_file ]]; then
|
||||||
# You can find it by visiting the $dir_steam directory
|
echo "creating games database"
|
||||||
# the ID is simply the name of the folder in there.
|
touch "$cache_file"
|
||||||
games+=(
|
fi
|
||||||
[386360]=Smite
|
|
||||||
[960090]="Bloons Tower Defense 6"
|
|
||||||
[648800]=Raft
|
|
||||||
[262060]="Darkest Dungeon"
|
|
||||||
[234140]="Mad Max"
|
|
||||||
[433340]="Slime Rancher"
|
|
||||||
[1190460]="Death Stranding"
|
|
||||||
[1850570]="Death Stranding"
|
|
||||||
[440900]="Conan Exiles"
|
|
||||||
[679110]="Werewolf Apocalypse"
|
|
||||||
[2221490]="The Division 2"
|
|
||||||
)
|
|
||||||
|
|
||||||
for key in "${!games[@]}"; do
|
fetch_game_name() {
|
||||||
|
local game_id
|
||||||
|
game_id=$1
|
||||||
|
|
||||||
|
local cache_entry
|
||||||
|
cache_entry=$(grep "^$game_id," "$cache_file")
|
||||||
|
if [ -n "$cache_entry" ]; then
|
||||||
|
echo "$cache_entry" | cut -d ',' -f2-
|
||||||
|
else
|
||||||
|
local response
|
||||||
|
response=$(curl -s "https://store.steampowered.com/api/appdetails?appids=${game_id}")
|
||||||
|
local game_name
|
||||||
|
game_name=$(echo "$response" | jq -r ".\"${game_id}\".data.name")
|
||||||
|
if [ -n "$game_name" ]; then
|
||||||
|
echo "$game_id,$game_name" >>"$cache_file"
|
||||||
|
echo "$game_name"
|
||||||
|
else
|
||||||
|
echo "error finding game $game_id"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
while IFS= read -r game_dir; do
|
||||||
|
game_id=$(basename "$game_dir")
|
||||||
|
game_name=$(fetch_game_name "$game_id")
|
||||||
# Modify this to store your screenshots somewhere else
|
# Modify this to store your screenshots somewhere else
|
||||||
dir_dest=$(realpath "$HOME/Pictures/Screenshots/Games")/${games[$key]}
|
dir_dest=$(realpath "$HOME/Pictures/Screenshots/Games")/"$game_name"
|
||||||
dir_game=$(realpath "$dir_steam")/$key/screenshots
|
dir_game=$(realpath "$dir_steam")/"$game_id"/screenshots
|
||||||
# If there are not screenshots currently stored, why bother lol
|
# If there are not screenshots currently stored, why bother lol
|
||||||
if ! [[ -d $dir_game ]]; then #
|
if ! [[ -d $dir_game ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
# If screenshots exist however...
|
# If screenshots exist however...
|
||||||
@ -98,14 +110,8 @@ for key in "${!games[@]}"; do
|
|||||||
fi
|
fi
|
||||||
# Create destination directory
|
# Create destination directory
|
||||||
mkdir -vp "$dir_dest"
|
mkdir -vp "$dir_dest"
|
||||||
echo "Moving ${games[$key]} screenshots..."
|
fd . "$dir_game" -d 1 -tf -x cp -n {} "$dir_dest"/
|
||||||
fd . "$dir_game" -d 1 -tf -x mv -n {} "$dir_dest"/
|
done < <(fd . "$dir_steam" -td --max-depth 1 --absolute-path)
|
||||||
# Delete thumnnails
|
|
||||||
echo "Deleting ${games[$key]} thumbnails..."
|
|
||||||
rm -rf "$dir_game"/thumbnails
|
|
||||||
done
|
|
||||||
# Clearing up empty directories
|
|
||||||
fd . "$dir_steam" -td -te -x trash {}
|
|
||||||
|
|
||||||
cyberpunk_dir=$HOME/Games/gog/cyberpunk-2077/drive_c/users/jawz/Pictures/"Cyberpunk 2077"
|
cyberpunk_dir=$HOME/Games/gog/cyberpunk-2077/drive_c/users/jawz/Pictures/"Cyberpunk 2077"
|
||||||
if [[ -d $cyberpunk_dir ]]; then
|
if [[ -d $cyberpunk_dir ]]; then
|
||||||
@ -117,13 +123,17 @@ fi
|
|||||||
|
|
||||||
proton_dir=$HOME/.steam/steam/compatibilitytools.d
|
proton_dir=$HOME/.steam/steam/compatibilitytools.d
|
||||||
if [[ -d "$proton_dir" ]]; then
|
if [[ -d "$proton_dir" ]]; then
|
||||||
while IFS= read -r protonver; do
|
while IFS= read -r proton_version; do
|
||||||
lutrisdir=$XDG_DATA_HOME/lutris/runners/wine/$(basename "$protonver")
|
proton_name=$(basename "$proton_version")
|
||||||
|
if [ "$proton_name" == "LegacyRuntime" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
lutrisdir=$XDG_DATA_HOME/lutris/runners/wine/"$proton_name"
|
||||||
if [ -d "$lutrisdir" ] && [ -L "$lutrisdir" ]; then
|
if [ -d "$lutrisdir" ] && [ -L "$lutrisdir" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "Symlink $lutrisdir doesn't exist, creating link..."
|
echo "Symlink $lutrisdir doesn't exist, creating link..."
|
||||||
ln -s "$(realpath "$protonver")"/files "$lutrisdir"
|
ln -s "$(realpath "$proton_version")"/files "$lutrisdir"
|
||||||
done < <(fd . "$proton_dir" -d 1 -td)
|
done < <(fd . "$proton_dir" -d 1 -td)
|
||||||
fi
|
fi
|
||||||
fd . "$XDG_DATA_HOME/lutris/runners/wine" -d1 -tl -Lx trash {}
|
fd . "$XDG_DATA_HOME/lutris/runners/wine" -d1 -tl -Lx trash {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user