-
Notifications
You must be signed in to change notification settings - Fork 0
/
pgsk
executable file
·115 lines (94 loc) · 4.51 KB
/
pgsk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
# Help
if [[ "$1" = "-h" || "$1" = "--help" ]]; then
echo -e "Usage: pgsk [DIRECTORY] [PLATFORM] \"[COMMAND]\"\n"
echo -e "Pegasus Skyscraper is a game scraper and metadata generator for the Pegasus-frontend\n"
echo -e "-> pgsk -p or pgsk --platform to see supported platforms"
echo -e "-> The media folder and the metadata file are both stored in [DIRECTORY]"
echo -e "-> [COMMAND] is optional and is stored in ~/.config/pgsk/commands.txt"
echo -e "\nEXAMPLE: pgsk ~/Games/PS2/ ps2 \"pcsx2-qt {file.path}\""
echo -e "-> stores media and metadata in '~/Games/GBA/'. The commands are stored in ~/.config/pgsk/commands.txt"
# supported platforms
elif [[ "$1" = "-p" || "$1" = "--platform" ]]; then
echo "=== Supported platforms are: ==="
echo "3do, 3ds, amiga, amigacd32, amstradcpc, apple2, arcade, astrocde, atari800, atari2600, atari5200, atari7800, atarijaguar, atarijaguarcd, atarilynx, atarist, atomiswave, c16, c64, c128, channelf, coco, coleco, daphne, dragon32, dreamcast, easyrpg, fba, fds, gameandwatch, gamegear, gb, gba, gbc, gc, genesis, intellivision, mame-advmame, mame-libretro, mame-mame4all, mastersystem, megacd, megadrive, moto, msx, msx2, n64, naomi, nds, neogeo, neogeocd, nes, ngp, ngpc, openbor, oric, pc, pc88, pc98, pcfx, pcengine, pcenginecd, pico8, pokemini, ports, ps2, psp, psx, saturn, scummvm, sega32x, segacd, sg-1000, snes, steam, switch, ti99, trs-80, vectrex, vic20, videopac, virtualboy, wii, wiiu, wonderswan, wonderswancolor, x68000, x1, zmachine, zx81, zxspectrum"
# Check if the inputs are correct, then execute
elif [[ -e "$1" && -n "$2" ]]; then
# pgsk directory doesn't exist?
if ! [[ -e ~/.config/pgsk ]]; then
echo "Creating ~/.config/pgsk/"
mkdir ~/.config/pgsk
fi
# commands file doesn't exist?
if ! [[ -e ~/.config/pgsk/commands.txt ]]; then
echo "Creating ~/.config/pgsk/commands.txt"
touch ~/.config/pgsk/commands.txt
fi
# check if platform config already exists 0 = no, 1 = yes...
i=0
lines=$(wc -l ~/.config/pgsk/commands.txt | awk '{print $1}')
echo "$lines lines found in config file..."
for y in $(eval echo "{1..$lines}")
do
platform=$(awk -F: '{ print $1 }' ~/.config/pgsk/commands.txt | sed -n $y'p')
if [[ "$platform" = "$2" ]]; then
# found!
i=1
platcommand=$(awk -F: '{ print $2 }' ~/.config/pgsk/commands.txt | sed -n $y'p')
echo "Found command '$platcommand' for '$2'"
fi
done
if [[ "$i" = "0" ]]; then
platcommand=default
fi
# if 3rd argument is supplied, store the command in a file with platform...
if [[ -n "$3" ]]; then
echo -e "=== Command '$3' for platform '$2'... ==="
if ! [[ "$i" = "1" ]]; then
echo "$2:$3" >> ~/.config/pgsk/commands.txt
else
echo "Platform configuration found for $2, skipping..."
fi
dire=$1
plat=$2
comm=$3
echo "Directory : $dire"
echo "Platform : $plat"
echo "Command : $comm"
Skyscraper -s screenscraper -i $dire -p $plat
echo -e "\n=== Scraping compelete, proceeding with metadata generation ===\n"
Skyscraper -f pegasus -i $dire -p $plat -e "$comm"
echo -e "\n=== Pegasus metadata creation complete ===\n"
# no 3rd argument, proceed as normal.
elif ! [[ -n "$3" ]]; then
dire=$1
plat=$2
echo "Directory : $dire"
echo "Platform : $plat"
if [[ $platcommand = "default" ]]; then
echo "Command : default"
Skyscraper -s screenscraper -i $dire -p $plat
echo -e "\n=== Scraping compelete, proceeding with metadata generation ===\n"
Skyscraper -f pegasus -i $dire -p $plat
echo -e "\n=== Pegasus metadata creation complete ===\n"
else
echo "Command : $platcommand"
Skyscraper -s screenscraper -i $dire -p $plat
echo -e "\n=== Scraping compelete, proceeding with metadata generation ===\n"
Skyscraper -f pegasus -i $dire -p $plat -e "$platcommand"
echo -e "\n=== Pegasus metadata creation complete ===\n"
fi
fi
# Incorrect inputs
else
if ! [[ -e "$1" ]]; then
echo "Directory '$1' does not exists."
fi
if ! [[ -n "$2" ]]; then
echo "Platform not specified."
fi
echo ""
echo "USAGE : pgsk [DIRECTORY] [PLATFORM] \"[COMMAND]\""
echo ""
echo "EXAMPLE : pgsk ~/Games/PS2/ ps2 \"pcsx2-qt {file.path}\""
fi