mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-16 16:20:04 +00:00
Add scripts for test library generation
This commit is contained in:
@@ -0,0 +1,53 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
CREATE_README=false
|
||||||
|
NUM_GAMES=50
|
||||||
|
TARGET_DIR="."
|
||||||
|
|
||||||
|
# Helper: print usage
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [--create-readme|-r] [--games|-g <number>] [--directory|-d <path>]"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
while [[ "$#" -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--create-readme|-r)
|
||||||
|
CREATE_README=true
|
||||||
|
;;
|
||||||
|
--games|-g)
|
||||||
|
shift
|
||||||
|
NUM_GAMES="$1"
|
||||||
|
;;
|
||||||
|
--directory|-d)
|
||||||
|
shift
|
||||||
|
TARGET_DIR="$1"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown parameter: $1"
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# Ensure target directory exists
|
||||||
|
mkdir -p "$TARGET_DIR"
|
||||||
|
|
||||||
|
# Fetch game data from GOG
|
||||||
|
API_URL="https://catalog.gog.com/v1/catalog?limit=$NUM_GAMES&systems=in%3Awindows&order=desc%3Abestselling&productType=in%3Agame%2Cpack"
|
||||||
|
RESPONSE=$(curl -s "$API_URL")
|
||||||
|
|
||||||
|
# Extract titles and create folders
|
||||||
|
echo "$RESPONSE" | jq -r '.products[].title' | while read -r TITLE; do
|
||||||
|
# Replace problematic characters in folder names
|
||||||
|
SAFE_TITLE=$(echo "$TITLE" | tr -cd '[:alnum:] _-')
|
||||||
|
GAME_DIR="$TARGET_DIR/$SAFE_TITLE"
|
||||||
|
mkdir -p "$GAME_DIR"
|
||||||
|
if $CREATE_README; then
|
||||||
|
touch "$GAME_DIR/README.md"
|
||||||
|
fi
|
||||||
|
echo "Created: $GAME_DIR"
|
||||||
|
done
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
CREATE_README=false
|
||||||
|
NUM_GAMES=50
|
||||||
|
DEST_DIR="./games"
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--create-readme|-r)
|
||||||
|
CREATE_README=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--games|-g)
|
||||||
|
NUM_GAMES="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--directory|-d)
|
||||||
|
DEST_DIR="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown parameter: $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Create parent directory
|
||||||
|
mkdir -p "$DEST_DIR"
|
||||||
|
|
||||||
|
# Fetch top-selling games from SteamSpy API
|
||||||
|
GAMES_JSON=$(curl -s "https://steamspy.com/api.php?request=top100in2weeks")
|
||||||
|
|
||||||
|
# Extract the top N game names
|
||||||
|
GAME_TITLES=$(echo "$GAMES_JSON" | jq -r 'to_entries | sort_by(.value.median_forever) | reverse | .[0:'"$NUM_GAMES"'] | .[].value.name')
|
||||||
|
|
||||||
|
# Create folders and README.md files
|
||||||
|
while IFS= read -r title; do
|
||||||
|
# Sanitize title to make a valid folder name
|
||||||
|
folder_name=$(echo "$title" | tr -cd '[:alnum:] _-')
|
||||||
|
game_path="$DEST_DIR/$folder_name"
|
||||||
|
mkdir -p "$game_path"
|
||||||
|
|
||||||
|
if $CREATE_README; then
|
||||||
|
touch "$game_path/README.md"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Created folder: $game_path"
|
||||||
|
done <<< "$GAME_TITLES"
|
||||||
Reference in New Issue
Block a user