-
Notifications
You must be signed in to change notification settings - Fork 0
/
Used2BeTXT.sh
executable file
·617 lines (532 loc) · 22.7 KB
/
Used2BeTXT.sh
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
#!/usr/bin/env bash
# Used2BeTXT.sh
###############
#
# This script converts synopsis text files to gamelist.xml files.
#
# More info in this forum thread: https://retropie.org.uk/forum/post/79022
#
# meleu - 2017/Jun
FULL_FLAG=0
NO_DESC_FLAG=0
ONLY_NEW_FLAG=0
ONLY_IMG_FLAG=0
DEFAULT_GAMELIST_FLAG=0
REVERSE_FLAG=0
PLATFORM=
IMG_DIR="Artwork/Box Front"
GAMELIST=
readonly RP_DATA="$HOME/RetroPie"
readonly SCRIPT_DIR="$(cd "$(dirname $0)" && pwd)"
readonly SCRIPT_NAME="$(basename "$0")"
readonly SCRIPT_FULL="$SCRIPT_DIR/$SCRIPT_NAME"
readonly SCRIPT_URL="https://raw.githubusercontent.com/meleu/Used2BeTXT/master/Used2BeTXT.sh"
readonly BKP_DIR="used2betxt-backups"
readonly HELP="
Usage:
$0 [OPTIONS] synopsis1.txt [synopsisN.txt ...]
The script gets data from \"synopsis1.txt\" and adds those data in xml format to
a file named \"PLATFORM_gamelist.xml\", where PLATFORM is the one indicated in
'Platform:' line in \"synopsis.txt\".
The OPTIONS are:
-h|--help print this message and exit.
-u|--update update the script and exit.
--only-new only add new entries to \"gamelist.xml\" (do not update
existing entries).
--no-desc do not generate <desc> entries.
--full generate gamelist.xml using all metadata from \"synopsis1.txt\",
including the ones unused for EmulationStation. The converted
file will be named \"PLATFORM_FULL_gamelist.xml\"
(see: --default-gamelist).
--default-gamelist the converted file will be named \"PLATFORM_gamelist.xml\"
even if using --full option.
--image TYPE choose the art type for <image>. Valid options for
TYPE: boxfront, cart, title, action, 3dbox.
--only-image if updating a \"gamelist.xml\", only update the <image>,
useful for changing image TYPE (see: --image).
# TODO: ADD HELP MESSAGES FOR --reverse and --platform
"
function update_script() {
local err_flag=0
local err_msg
if err_msg=$(wget "$SCRIPT_URL" -O "/tmp/$SCRIPT_NAME" 2>&1); then
if diff -q "$SCRIPT_FULL" "/tmp/$SCRIPT_NAME" >/dev/null; then
echo "You already have the latest version. Nothing changed."
rm -f "/tmp/$SCRIPT_NAME"
exit 0
fi
err_msg=$(mv "/tmp/$SCRIPT_NAME" "$SCRIPT_FULL" 2>&1) \
|| err_flag=1
else
err_flag=1
fi
if [[ $err_flag -ne 0 ]]; then
err_msg=$(echo "$err_msg" | tail -1)
echo "Failed to update \"$SCRIPT_NAME\": $err_msg" >&2
exit 1
fi
chmod a+x "$SCRIPT_FULL"
echo "The script has been successfully updated. You can run it again."
exit 0
}
# TODO: better management of apersand '&'
function get_data() {
grep -m 1 -i "^$1:" "$2" | sed -e "s/^$1: //I; s/&/&/g; s/\r//g"
}
function find_file() {
local found
local dir="$( echo "$1" | tr '[]&' '???')"
local file="$(echo "$2" | tr '[]&' '???')"
shift 2
local args=()
local ext
if [[ -z "$1" ]]; then
args=( -iname "${file}.*" )
else
args=( -iname "${file}.$1" )
shift
for ext in "$@"; do
args+=( -o -iname "${file}.$ext" )
done
fi
if [[ "$dir" == [Rr]oms ]]; then
found="$(find "$RP_DATA/roms/$platform" -type f \( "${args[@]}" \) -print -quit 2> /dev/null)"
if [[ -n "$found" ]]; then
echo "${found//&/&}"
return
fi
fi
found="$(find "$RP_DATA/Media/$platform/$dir" -type f \( "${args[@]}" \) -print -quit 2> /dev/null)"
if [[ -z "$found" && -n "$xtras_system" ]]; then
found="$(
find "$RP_DATA/Media" \
-type f \
-ipath "$RP_DATA/Media/$xtras_system/$dir/*" \
\( "${args[@]}" \) \
-print -quit 2> /dev/null)"
fi
echo "${found//&/&}"
}
# CONVERTING FROM GAMELIST.XML TO SYNOPSIS.TXT
# TODO: not sure what to do if the gamelist.xml has a <folder> entry.
function gamelist2synopsis() {
if [[ -z "$PLATFORM" ]]; then
echo "ERROR: you must set a platform with the option \"--platform\"." >&2
exit 1
fi
local platform
local synopsis
local var
local tag
declare -A tags=(
[region]="Region"
[media]="Media"
[controller]="Controller"
[genre]="Genre"
[gametype]="Gametype"
[releasedate]="Release Year"
[developer]="Developer"
[publisher]="Publisher"
[players]="Players"
[originaltitle]="Original Title"
[alternatetitle]="Alternate Title"
[hackedby]="Hacked by"
[translatedby]="Translated by"
[version]="Version"
[license]="License"
[programmer]="Programmer"
[musician]="Musician"
)
IFS=$'\n' names=($(xmlstarlet sel -t -v "/gameList/game/name" "$GAMELIST"))
for name in "${names[@]}"; do
[[ -z "$name" ]] && continue
synopsis="${name}.txt"
echo -n "Generating \"$synopsis\"... "
platform="$(xmlstarlet sel -t -v "/gameList/game[name=\"$name\"]/platform" "$GAMELIST")"
[[ -z "$platform" ]] && platform="$PLATFORM"
echo "$name" > "$synopsis"
echo "Platform: $platform" >> "$synopsis"
# XXX: I'm not using "${!tags[@]}" because I want a very specific order
for tag in \
region media controller genre gametype releasedate developer \
publisher players originaltitle alternatetitle hackedby \
translatedby version license programmer musician
do
var="$(xmlstarlet sel -t -v "/gameList/game[name=\"$name\"]/$tag" "$GAMELIST")"
[[ -n "$var" ]] && echo "${tags[$tag]}: $var" >> "$synopsis"
done
# sed trick to convert <releasedate> format to "Release Year"
sed -i 's/^\(Release Year: *[[:digit:]]\{4\}\).*/\1/' "$synopsis"
echo "_________________________" >> "$synopsis"
echo "$(xmlstarlet sel -t -v "/gameList/game[name=\"$name\"]/desc" "$GAMELIST")" >> "$synopsis"
echo "Done!"
done
}
# creating backups
function backup() {
mkdir -p "$BKP_DIR"
while IFS= read -r gamelist || [[ -n $gamelist ]]; do
bkp_file="$BKP_DIR/${gamelist%%.*}_$(date +"%Y-%m-%d_%H%M%S").xml"
if [[ ! -f "$bkp_file.gz" ]]; then
cp "$gamelist" "$bkp_file"
gzip "$bkp_file"
fi
done < <(find . -maxdepth 1 -name '*_gamelist.xml')
}
function scrape_data() {
for file in "$@"; do
if [[ ! -f "$file" ]]; then
echo "WARNING: ignoring \"$file\": no such file." >&2
continue
fi
echo "Scraping \"$file\"..."
file_name="$(basename "${file%.*}")"
platform=$(grep -m 1 "^Platform: " "$file" | cut -d: -f2 | tr -d ' \r' | tr [:upper:] [:lower:])
[[ -z "$platform" ]] && continue
# name : the very first line of the txt file
name_real="$(head -1 "$file" | tr -d '\r')"
name="${name_real//&/&}"
[[ -z "$name" ]] && continue
ROM_EXT="zip"
[[ "$(get_data "Media" "$file")" =~ ^(cd|compact disc)$ ]] && ROM_EXT+=" cue"
case "$platform" in
atari2600)
xtras_system="atari 2600"
;;
atari7800)
xtras_system="atari 7800"
;;
atari5200|atari800)
xtras_system="atari 5200"
ROM_EXT+=" bin"
;;
nintendoentertainmentsystem|thefamilycomputerdisksystem|familycomputerdisksystem|nes)
platform="nes"
xtras_system="nes"
;;
nintendogameboyadvance|gba)
platform="gba"
xtras_system="game boy advance"
;;
nintendogameboycolor|gbc)
platform="gbc"
xtras_system="game boy color"
;;
nintendogameboy|gb)
platform="gb"
xtras_system="game boy"
;;
nintendovirtualboy|virtualboy)
platform="virtualboy"
;;
supernintendoentertainmentsystem|snes)
platform="snes"
xtras_system="snes"
;;
segamastersystem|mastersystem)
platform="mastersystem"
xtras_system="master system"
;;
segagamegear|gamegear)
platform="gamegear"
;;
segasg-1000|sg-1000)
platform="sg-1000"
;;
segagenesis/megadrive|genesis|megadrive)
platform="megadrive"
xtras_system="genesis"
;;
sega/megacd|segacd)
platform="segacd"
;;
turbografx-16/pcengine|pcengine)
platform="pcengine"
;;
neogeopocket|ngp)
platform="ngp"
xtras_system="neo geo pocket"
;;
colecovision|coleco)
platform="coleco"
;;
bandaiwonderswan|wonderswan)
platform="wonderswan"
;;
bandaiwonderswancolor|wonderswancolor)
platform="wonderswancolor"
;;
magnavoxodyssey2|videopac)
platform="videopac"
ROM_EXT+=" bin"
;;
esac
gamelist="$platform"
[[ "$FULL_FLAG" == 1 && "$DEFAULT_GAMELIST_FLAG" != 1 ]] && gamelist+="_FULL"
gamelist+="_gamelist.xml"
[[ -f "$gamelist" ]] || echo "<gameList />" > "$gamelist"
# folder : "Folder"
folder="$(get_data "Folder" "$file")"
[[ -n "$folder" ]] && game=folder || game=game
if [[ $(xmlstarlet sel -t -v "count(/gameList/$game[name=\"$name_real\"])" "$gamelist") == 0 ]]; then
NEW_ENTRY_FLAG=1
else
NEW_ENTRY_FLAG=0
fi
[[ "$NEW_ENTRY_FLAG" == 0 && "$ONLY_NEW_FLAG" == 1 ]] && continue
# image : find the box art
if [[ -n "$folder" ]]; then
image="$(find_file "Artwork/Folders" "$file_name" png jpg )"
else
image="$(find_file "$IMG_DIR" "$file_name" png jpg )"
fi
if [[ "$NEW_ENTRY_FLAG" == 1 || "$ONLY_IMG_FLAG" == 0 ]]; then
# path : find the path
if [[ -n "$folder" ]]; then
# first - search in the "ressurection.xtras" style
path="$(find "$RP_DATA/Media" -type d -ipath "*/$xtras_system/roms/*" -iname "$folder" -print -quit)"
if [[ -z "$path" ]]; then
# second - search in the "Used2BeRX" style
path="$(find "$RP_DATA/Media" -type d -ipath "*/$platform/roms/*" -iname "$folder" -print -quit)"
if [[ -z "$path" ]]; then
# third (last) - search in the RetroPie style
path="$(find "$RP_DATA" -type d -ipath "*/roms/$platform/*" -iname "$folder" -print -quit)"
fi
fi
else
path="$(find_file Roms "$file_name" $ROM_EXT )"
fi
# video : find the video preview
video="$(find_file Movies "$file_name" "???")"
# marquee : find the marquee
# TODO: need tests
marquee="$(find_file "Artwork/Marquee" "$file_name" png jpg )"
# releasedate : "Release Year"
releasedate="$(get_data "Release Year" "$file")"
# Note: releasedate must be a date/time in the format %Y%m%dT%H%M%S or empty
if [[ "$releasedate" =~ ^[[:digit:]]{1,4}$ ]]; then
releasedate="$(date -d ${releasedate}-1-1 +%Y%m%dT%H%M%S)" || realeasedate=""
else
releasedate=""
fi
# developer : "Developer"
developer="$(get_data "Developer" "$file")"
# publisher : "Publisher"
publisher="$(get_data "Publisher" "$file")"
# genre : "Genre"
genre="$(get_data "Genre" "$file")"
# players : "Players"
players="$(get_data "Players" "$file")"
# Note: players must be an integer
[[ -n "$players" ]] && players=$(echo $players | sed 's/[^0-9 ]//g' | tr -s ' ' '\n' | sort -nr | head -1)
# desc : the content below "______" to the end of file
if [[ "$NO_DESC_FLAG" == 0 ]]; then
desc="$(sed '/^__________/,$!d' "$file" | tail -n +2 | tr -d '\r' | sed 's/&/&/g')"
desc="$(grep -Ev '^(https?|ftp)://[^\s/$.?#].[^\s]*$' <<< "$desc")"
fi
if [[ "$FULL_FLAG" == 1 ]]; then
if [[ -n "$folder" ]]; then
xtrasname="$folder"
else
xtrasname="${file_name%.*}"
fi
region="$(get_data "Region" "$file")"
media="$(get_data "Media" "$file")"
controller="$(get_data "Controller" "$file")"
gametype="$(get_data "Gametype" "$file")"
originaltitle="$(get_data "Original Title" "$file")"
alternatetitle="$(get_data "Alternate Title" "$file")"
hackedby="$(get_data "Hacked by" "$file")"
translatedby="$(get_data "Translated by" "$file")"
version="$(get_data "Version" "$file")"
license="$(get_data "License" "$file")"
programmer="$(get_data "Programmer" "$file")"
musician="$(get_data "Musician" "$file")"
# cart : find it
cart="$(find_file "Artwork/Cart" "$file_name" png jpg)"
# title : find it
title="$(find_file "Artwork/Titles" "$file_name" png jpg)"
# action : find it
action="$(find_file "Artwork/Action" "$file_name" png jpg)"
# threedbox : find it
threedbox="$(find_file "Artwork/3D Boxart" "$file_name" png jpg)"
# gamefaq : find it
gamefaq="$(find_file "GameFAQs" "$file_name" zip)"
# manual : find it
manual="$(find_file "Manuals" "$file_name" zip)"
# vgmap : find it
vgmap="$(find_file "VGMaps" "$file_name" zip)"
fi # end of if FULL_FLAG
fi # end of if ONLY_IMG_FLAG
fill_gamelist
echo "\"$file\" data has been added to \"$gamelist\"."
done
}
function fill_gamelist() {
if [[ "$NEW_ENTRY_FLAG" == 1 ]]; then
xmlstarlet ed -L -s "/gameList" -t elem -n "$game" -v "" \
-s "/gameList/$game[last()]" -t elem -n "name" -v "$name" \
-s "/gameList/$game[last()]" -t elem -n "path" -v "$path" \
-s "/gameList/$game[last()]" -t elem -n "image" -v "$image" \
-s "/gameList/$game[last()]" -t elem -n "video" -v "$video" \
-s "/gameList/$game[last()]" -t elem -n "marquee" -v "$marquee" \
-s "/gameList/$game[last()]" -t elem -n "desc" -v "$desc" \
-s "/gameList/$game[last()]" -t elem -n "releasedate" -v "$releasedate" \
-s "/gameList/$game[last()]" -t elem -n "developer" -v "$developer" \
-s "/gameList/$game[last()]" -t elem -n "publisher" -v "$publisher" \
-s "/gameList/$game[last()]" -t elem -n "genre" -v "$genre" \
-s "/gameList/$game[last()]" -t elem -n "players" -v "$players" \
"$gamelist"
if [[ "$game" == game && "$FULL_FLAG" == 1 ]]; then
xmlstarlet ed -L \
-s "/gameList/game[last()]" -t elem -n "region" -v "$region" \
-s "/gameList/game[last()]" -t elem -n "platform" -v "$platform" \
-s "/gameList/game[last()]" -t elem -n "media" -v "$media" \
-s "/gameList/game[last()]" -t elem -n "controller" -v "$controller" \
-s "/gameList/game[last()]" -t elem -n "gametype" -v "$gametype" \
-s "/gameList/game[last()]" -t elem -n "xtrasname" -v "$xtrasname" \
-s "/gameList/game[last()]" -t elem -n "originaltitle" -v "$originaltitle" \
-s "/gameList/game[last()]" -t elem -n "alternatetitle" -v "$alternatetitle" \
-s "/gameList/game[last()]" -t elem -n "hackedby" -v "$hackedby" \
-s "/gameList/game[last()]" -t elem -n "translatedby" -v "$translatedby" \
-s "/gameList/game[last()]" -t elem -n "version" -v "$version" \
-s "/gameList/game[last()]" -t elem -n "cart" -v "$cart" \
-s "/gameList/game[last()]" -t elem -n "title" -v "$title" \
-s "/gameList/game[last()]" -t elem -n "action" -v "$action" \
-s "/gameList/game[last()]" -t elem -n "threedbox" -v "$threedbox" \
-s "/gameList/game[last()]" -t elem -n "gamefaq" -v "$gamefaq" \
-s "/gameList/game[last()]" -t elem -n "manual" -v "$manual" \
-s "/gameList/game[last()]" -t elem -n "vgmap" -v "$vgmap" \
-s "/gameList/game[last()]" -t elem -n "license" -v "$license" \
-s "/gameList/game[last()]" -t elem -n "programmer" -v "$programmer" \
-s "/gameList/game[last()]" -t elem -n "musician" -v "$musician" \
"$gamelist"
fi
elif [[ "$ONLY_IMG_FLAG" == 1 ]]; then
xmlstarlet ed -L \
-u "/gameList/$game[name=\"$name_real\"]/image" -v "${image//&/&}" \
"$gamelist"
else
xmlstarlet ed -L \
-u "/gameList/$game[name=\"$name_real\"]/path" -v "${path//&/&}" \
-u "/gameList/$game[name=\"$name_real\"]/image" -v "${image//&/&}" \
-u "/gameList/$game[name=\"$name_real\"]/video" -v "${video//&/&}" \
-u "/gameList/$game[name=\"$name_real\"]/marquee" -v "${marquee//&/&}" \
-u "/gameList/$game[name=\"$name_real\"]/desc" -v "${desc//&/&}" \
-u "/gameList/$game[name=\"$name_real\"]/releasedate" -v "${releasedate//&/&}" \
-u "/gameList/$game[name=\"$name_real\"]/developer" -v "${developer//&/&}" \
-u "/gameList/$game[name=\"$name_real\"]/publisher" -v "${publisher//&/&}" \
-u "/gameList/$game[name=\"$name_real\"]/genre" -v "${genre//&/&}" \
-u "/gameList/$game[name=\"$name_real\"]/players" -v "${players//&/&}" \
"$gamelist"
if [[ "$game" == game && "$FULL_FLAG" == 1 ]]; then
xmlstarlet ed -L \
-u "/gameList/game[name=\"$name_real\"]/region" -v "${region//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/platform" -v "${platform//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/media" -v "${media//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/controller" -v "${controller//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/gametype" -v "${gametype//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/xtrasname" -v "${xtrasname//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/originaltitle" -v "${originaltitle//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/alternatetitle" -v "${alternatetitle//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/hackedby" -v "${hackedby//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/translatedby" -v "${translatedby//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/version" -v "${version//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/cart" -v "${cart//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/title" -v "${title//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/action" -v "${action//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/threedbox" -v "${threedbox//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/gamefaq" -v "${gamefaq//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/manual" -v "${manual//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/vgmap" -v "${vgmap//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/license" -v "${license//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/programmer" -v "${programmer//&/&}" \
-u "/gameList/game[name=\"$name_real\"]/musician" -v "${musician//&/&}" \
"$gamelist"
fi
fi
}
# MAIN #######################################################################
function main() {
if [[ -z "$1" ]]; then
echo "ERROR: missing arguments." >&2
exit 1
fi
# parsing arguments
while [[ -n "$1" ]]; do
case "$1" in
-h|--help)
echo "$HELP" >&2
exit 0
;;
-u|--update)
update_script
;;
--full)
FULL_FLAG=1
;;
--no-desc)
NO_DESC_FLAG=1
;;
--only-new)
ONLY_NEW_FLAG=1
;;
--only-image)
ONLY_IMG_FLAG=1
;;
--default-gamelist)
DEFAULT_GAMELIST_FLAG=1
;;
--image)
shift
case "$1" in
boxfront)
IMG_DIR="Artwork/Box Front" ;;
cart)
IMG_DIR="Artwork/Cart" ;;
title)
IMG_DIR="Artwork/Titles" ;;
action)
IMG_DIR="Artwork/Action" ;;
3dbox)
IMG_DIR="Artwork/3D Boxart" ;;
*)
echo "ERROR: invalid option for --image: \"$1\"" >&2
exit 1
;;
esac
;;
-r|--reverse)
shift
GAMELIST="$1"
if [[ ! -f "$GAMELIST" ]]; then
echo "ERROR: no such file: \"$GAMELIST\"" >&2
exit 1
fi
REVERSE_FLAG=1
;;
-p|--platform)
shift
PLATFORM="$1"
if [[ -z "$PLATFORM" ]]; then
echo "ERROR: you must set a platform." >&2
exit 1
fi
;;
*)
break
;;
esac
shift
done # end of parsing args
# checking if user wants to generate sysnpsis.txt files from a gamelist.xml
if [[ "$REVERSE_FLAG" == 1 ]]; then
gamelist2synopsis
fi
shopt -s nocaseglob
shopt -s nocasematch
backup
# scanning all synopsis.txt files
scrape_data "$@"
}
main "$@"