-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path03-Game-Installer.sh
executable file
·1643 lines (1404 loc) · 59 KB
/
03-Game-Installer.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
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Set terminal size: 100 columns and 40 rows
echo -e "\e[8;40;100t"
# Set paths
TOOLKIT_PATH="$(pwd)"
ICONS_DIR="${TOOLKIT_PATH}/icons"
ARTWORK_DIR="${ICONS_DIR}/art"
HELPER_DIR="${TOOLKIT_PATH}/helper"
ASSETS_DIR="${TOOLKIT_PATH}/assets"
POPSTARTER="${ASSETS_DIR}/POPStarter/POPSTARTER.ELF"
NEUTRINO_DIR="${ASSETS_DIR}/neutrino"
LOG_FILE="${TOOLKIT_PATH}/game-installer.log"
MISSING_ART=${TOOLKIT_PATH}/missing-art.log
MISSING_APP_ART=${TOOLKIT_PATH}/missing-app-art.log
# Modify this path if your games are stored in a different location:
GAMES_PATH="${TOOLKIT_PATH}/games"
POPS_FOLDER="${GAMES_PATH}/POPS"
PS1_LIST="${TOOLKIT_PATH}/ps1.list"
PS2_LIST="${TOOLKIT_PATH}/ps2.list"
ALL_GAMES="${TOOLKIT_PATH}/master.list"
clear
cd "${TOOLKIT_PATH}"
# Check if the helper files exists
if [[ ! -f "${HELPER_DIR}/PFS Shell.elf" || ! -f "${HELPER_DIR}/HDL Dump.elf" ]]; then
echo "Required helper files not found. Please ensure you are in the 'PSBBN-Definitive-English-Patch'"
echo "directory and try again."
exit 1
fi
echo "########################################################################################################" | tee -a "${LOG_FILE}" >/dev/null 2>&1
if [ $? -ne 0 ]; then
sudo rm -f "${LOG_FILE}"
echo "########################################################################################################" | tee -a "${LOG_FILE}" >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo
echo "Error: Cannot to create log file."
read -n 1 -s -r -p "Press any key to exit..."
echo
exit 1
fi
fi
date >> "${LOG_FILE}"
echo >> "${LOG_FILE}"
cat /etc/*-release >> "${LOG_FILE}" 2>&1
echo >> "${LOG_FILE}"
echo "Path set to: $TOOLKIT_PATH" >> "${LOG_FILE}"
echo "Helper files found." >> "${LOG_FILE}"
# Check if the Python virtual environment exists
if [ -f "./venv/bin/activate" ]; then
echo "The Python virtual environment exists." >> "${LOG_FILE}"
else
echo "Error: The Python virtual environment does not exist. Run 01-Setup.sh and try again." | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit..."
echo
exit 1
fi
# Check if the current directory is a Git repository
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
echo "This is not a Git repository. Skipping update check." | tee -a "${LOG_FILE}"
else
# Fetch updates from the remote
git fetch >> "${LOG_FILE}" 2>&1
# Check the current status of the repository
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @ @{u})
if [ "$LOCAL" = "$REMOTE" ]; then
echo "The repository is up to date." | tee -a "${LOG_FILE}"
else
echo "Downloading updates..."
# Get a list of files that have changed remotely
UPDATED_FILES=$(git diff --name-only "$LOCAL" "$REMOTE")
if [ -n "$UPDATED_FILES" ]; then
echo "Files updated in the remote repository:" | tee -a "${LOG_FILE}"
echo "$UPDATED_FILES" | tee -a "${LOG_FILE}"
# Reset only the files that were updated remotely (discard local changes to them)
echo "$UPDATED_FILES" | xargs git checkout -- >> "${LOG_FILE}" 2>&1
# Pull the latest changes
git pull --ff-only >> "${LOG_FILE}" 2>&1
if [[ $? -ne 0 ]]; then
echo
echo "Error: Update failed. Delete the PSBBN-Definitive-English-Patch directory and run the command:"
echo
echo "git clone https://github.com/CosmicScale/PSBBN-Definitive-English-Patch.git"
echo
read -n 1 -s -r -p "Then try running the script again. Press any key to exit"
echo
exit 1
fi
echo
echo "The repository has been successfully updated." | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit, set your custom game path if required, then run the script again."
echo
exit 0
else
echo "The repository is up to date." | tee -a "${LOG_FILE}"
fi
fi
fi
function clean_up() {
# Loop through all items in the target directory
for item in "$ICONS_DIR"/*; do
# Check if the item is a directory and not the 'art' or 'ico' folder
if [ -d "$item" ] && [ "$(basename "$item")" != "art" ] && [ "$(basename "$item")" != "ico" ]; then
rm -rf "$item" >> "${LOG_FILE}" 2>&1
fi
done
# Find and delete all subdirectories in APPS direcrtory
while IFS= read -r dir; do
rm -rf -- "$dir"
done < <(find "${GAMES_PATH}/APPS" -mindepth 1 -maxdepth 1 -type d | sort -r)
rm -f "${TOOLKIT_PATH}/package.json" >> "${LOG_FILE}" 2>&1
rm -f "${TOOLKIT_PATH}/package-lock.json" >> "${LOG_FILE}" 2>&1
rm -f "${PS1_LIST}" >> "${LOG_FILE}" 2>&1
rm -f "${PS2_LIST}" >> "${LOG_FILE}" 2>&1
rm -f "${ALL_GAMES}" >> "${LOG_FILE}" 2>&1
rm -f "${ARTWORK_DIR}/tmp"/* >> "${LOG_FILE}" 2>&1
}
clean_up
rm -f $MISSING_ART 2>>"${LOG_FILE}"
rm -f $MISSING_APP_ART 2>>"${LOG_FILE}"
echo " _____ _____ _ _ _ ";
echo " | __ \ |_ _| | | | | | ";
echo " | | \/ __ _ _ __ ___ ___ | | _ __ ___| |_ __ _| | | ___ ___ ";
echo " | | __ / _\` | '_ \` _ \ / _ \ | || '_ \/ __| __/ _\` | | |/ _ \ __|";
echo " | |_\ \ (_| | | | | | | __/ _| || | | \__ \ || (_| | | | __/ | ";
echo " \____/\__,_|_| |_| |_|\___| \___/_| |_|___/\__\__,_|_|_|\___|_| ";
echo " ";
echo " Written by CosmicScale"
echo
echo " ##############################################################################################"
echo " # This tool synchronizes the games on your PC with those on your PS2's HDD/SSD. #"
echo " # #"
echo " # Ensure the PS2 drive is connected to your PC before proceeding. #"
echo " # #"
echo " # How Syncing Works: #"
echo " # #"
echo " # Copying: Games in your PC's 'games' folder that are missing from your PS2 will be added #"
echo " # #"
echo " # Removal: Games on your PS2 that are not in your PC's 'games' folder will be removed. #"
echo " # #"
echo " ##############################################################################################"
echo
read -n 1 -s -r -p " Press any key to continue..."
echo
# Choose the PS2 storage device
while true; do
clear
echo
echo " _____ _____ _ _ _ ";
echo " | __ \ |_ _| | | | | | ";
echo " | | \/ __ _ _ __ ___ ___ | | _ __ ___| |_ __ _| | | ___ ___ ";
echo " | | __ / _\` | '_ \` _ \ / _ \ | || '_ \/ __| __/ _\` | | |/ _ \ __|";
echo " | |_\ \ (_| | | | | | | __/ _| || | | \__ \ || (_| | | | __/ | ";
echo " \____/\__,_|_| |_| |_|\___| \___/_| |_|___/\__\__,_|_|_|\___|_| ";
echo " ";
echo " Written by CosmicScale"
echo | tee -a "${LOG_FILE}"
lsblk -p -o MODEL,NAME,SIZE,LABEL,MOUNTPOINT | tee -a "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
read -p "Choose your PS2 HDD from the list above (e.g., /dev/sdx): " DEVICE
# Check if the device exists and is valid
if [[ -n "$DEVICE" ]] && lsblk -dp -n -o NAME | grep -q "^$DEVICE$"; then
echo
echo -e "Selected drive: \"${DEVICE}\"" | tee -a "${LOG_FILE}"
# Run HDL Dump and capture output
output=$(sudo "${TOOLKIT_PATH}"/helper/HDL\ Dump.elf toc ${DEVICE} 2>&1)
# Check for the word "aborting" in the output
if echo "$output" | grep -qE "aborting|No medium found"; then
echo
echo "Error: APA partition is broken on ${DEVICE}." | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit..."
echo
exit 1
fi
# Check if 'OPL' partition exists with blkid
if ! sudo blkid "${DEVICE}3" | grep -q OPL; then
echo "Error: OPL partition not found on ${DEVICE}" | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit..."
echo
exit 1
fi
break
else
echo
echo "Error: Invalid input. Please enter a valid device name (e.g., /dev/sdx)."
read -n 1 -s -r -p "Press any key to try again..."
echo
fi
done
# Find all mounted volumes associated with the device
mounted_volumes=$(lsblk -ln -o MOUNTPOINT "$DEVICE" | grep -v "^$")
# Iterate through each mounted volume and unmount it
echo | tee -a "${LOG_FILE}"
echo "Unmounting volumes associated with $DEVICE..."
for mount_point in $mounted_volumes; do
echo "Unmounting $mount_point..." | tee -a "${LOG_FILE}"
if sudo umount "$mount_point"; then
echo "Successfully unmounted $mount_point." | tee -a "${LOG_FILE}"
else
echo "Failed to unmount $mount_point. Please unmount manually." | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit..."
echo
exit 1
fi
done
echo "All volumes unmounted for $DEVICE."| tee -a "${LOG_FILE}"
# Validate the GAMES_PATH
if [[ ! -d "$GAMES_PATH" ]]; then
echo
echo "Error: GAMES_PATH is not a valid directory: $GAMES_PATH" | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit..."
echo
exit 1
fi
echo | tee -a "${LOG_FILE}"
echo "GAMES_PATH is valid: $GAMES_PATH" | tee -a "${LOG_FILE}"
# Create necessary folders if they don't exist
for folder in APPS ART CFG CHT LNG THM VMC POPS CD DVD; do
dir="${GAMES_PATH}/${folder}"
[[ -d "$dir" ]] || mkdir -p "$dir" || {
echo "Error: Failed to create $dir. Make sure you have write permissions to $GAMES_PATH" | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit..."
echo
exit 1
}
done
# Check if GAMES_PATH is custom
if [[ "${GAMES_PATH}" != "${TOOLKIT_PATH}/games" ]]; then
echo | tee -a "${LOG_FILE}"
echo "Using custom game path." | tee -a "${LOG_FILE}"
cp "${TOOLKIT_PATH}/games/APPS/"{BOOT.ELF,Launch-Disc.elf,HDD-OSD.elf,PSBBN.ELF} "${GAMES_PATH}/APPS" >> "${LOG_FILE}" 2>&1
else
echo | tee -a "${LOG_FILE}"
echo "Using default game path." | tee -a "${LOG_FILE}"
fi
mkdir -p "${ICONS_DIR}/bbnl"
echo | tee -a "${LOG_FILE}"
echo "Please choose a game launcher:"
echo "1) Open PS2 Loader (OPL)"
echo "2) Neutrino"
echo
while true; do
read -p "Enter 1 or 2: " choice
case "$choice" in
1) LAUNCHER="OPL"; DESC="Open PS2 Loader (OPL)";;
2) LAUNCHER="NEUTRINO"; DESC="Neutrino";;
*) echo; echo "Invalid choice. Please enter 1 or 2."; continue ;;
esac
echo
read -p "You selected $DESC. Are you sure? (y/n): " confirm
[[ "$confirm" =~ ^[Yy]$ ]] && break # Exit loop if "y"
done
echo "$DESC selected." >> "${LOG_FILE}"
echo >> "${LOG_FILE}"
# Delete old game partitions
delete_partition=$(sudo "${HELPER_DIR}/HDL Dump.elf" toc "$DEVICE" | grep -o 'PP\.[^ ]\+')
COMMANDS="device ${DEVICE}\n"
while IFS= read -r partition; do
COMMANDS+="rmpart ${partition}\n"
done <<< "$delete_partition"
COMMANDS+="rmpart +OPL\n"
COMMANDS+="exit"
echo -e "$COMMANDS" | sudo "${HELPER_DIR}/PFS Shell.elf" >> "${LOG_FILE}" 2>&1
echo | tee -a "${LOG_FILE}"
echo "Preparing to sync apps..." | tee -a "${LOG_FILE}"
cd "${GAMES_PATH}/APPS"
# Check if any .psu or .PSU files exist in the source directory
if find "${GAMES_PATH}/APPS/" -maxdepth 1 -type f \( -name "*.psu" -o -name "*.PSU" \) | grep -q .; then
echo | tee -a "${LOG_FILE}"
echo "Processing PSU files:" | tee -a "${LOG_FILE}"
# Process each .psu file in the source directory
for file in "${GAMES_PATH}/APPS/"*.psu "${GAMES_PATH}/APPS/"*.PSU; do
[ -e "$file" ] || continue # Skip if no PSU files exist
echo "Extracting $file..."
"${HELPER_DIR}/PSU Extractor.elf" "$file" >> "${LOG_FILE}" 2>&1
done
for dir in */; do
[[ -d "$dir" ]] || continue
# Check for .elf/.ELF file
if find "$dir" -maxdepth 1 -type f \( -iname "*.elf" \) | grep -q . && \
[[ -f "$dir/icon.sys" && -f "$dir/title.cfg" ]]; then
cp -r "$dir" "${ICONS_DIR}"
fi
done
# Loop through each folder in DST_DIR, excluding 'art', 'bbnl' and 'ico', sorted in reverse alphabetical order
find "$ICONS_DIR" -mindepth 1 -maxdepth 1 -type d ! -name "art" ! -name "bbnl" ! -name "ico" | sort -r | while IFS= read -r dir; do
folder_name=$(basename "$dir")
# Find the first .ELF file in the extracted directory
elf_file=$(find "$dir" -maxdepth 1 -type f -iname "*.elf" | head -n 1)
# Extract only the filename if an ELF file was found
elf_filename=$(basename "$elf_file")
echo | tee -a "${LOG_FILE}"
echo "Found ELF file: $elf_filename" | tee -a "${LOG_FILE}"
if [ -f "$dir/list.icn" ]; then
mv "$dir/list.icn" "$dir/list.ico" 2>> "${LOG_FILE}"
[ -f "$dir/del.icn" ] && mv "$dir/del.icn" "$dir/del.ico" 2>> "${LOG_FILE}"
echo "list.icn found in $dir, converted to list.ico" | tee -a "${LOG_FILE}"
else
echo "list.icn not found in $dir, using default icon." | tee -a "${LOG_FILE}"
cp "${ICONS_DIR}/ico/app.ico" "$dir/list.ico" 2>> "${LOG_FILE}"
cp "${ICONS_DIR}/ico/app-del.ico" "$dir/del.ico" 2>> "${LOG_FILE}"
fi
# Convert the icon.sys file
icon_sys_filename="$dir/icon.sys"
python3 "${HELPER_DIR}/icon_sys_to_txt.py" "$icon_sys_filename" >> "${LOG_FILE}" 2>&1
mv "$dir/icon.txt" "$icon_sys_filename"
if [ $? -ne 0 ]; then
echo "Failed to convert icon.sys: $icon_sys_filename" | tee -a "${LOG_FILE}"
else
echo "Converted icon.sys: $icon_sys_filename" | tee -a "${LOG_FILE}"
fi
while IFS='=' read -r key value; do
key=$(echo "$key" | tr -d '\r' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
value=$(echo "$value" | tr -d '\r' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
# Remove non-ASCII and non-printable characters
value=$(printf '%s' "$value" | LC_ALL=C tr -cd '\40-\176')
case "$key" in
title) title="$value" ;;
boot) elf="$value" ;;
Developer) developer="$value" ;;
esac
done < "$dir/title.cfg"
# Generate the info.sys file
info_sys_filename="$dir/info.sys"
cat > "$info_sys_filename" <<EOL
title = $title
title_id = $folder_name
title_sub_id = 0
release_date =
developer_id =
publisher_id = $developer
note =
content_web =
image_topviewflag = 0
image_type = 0
image_count = 1
image_viewsec = 600
copyright_viewflag = 0
copyright_imgcount = 0
genre =
parental_lock = 1
effective_date = 0
expire_date = 0
violence_flag = 0
content_type = 255
content_subtype = 0
EOL
echo "Created info.sys: $info_sys_filename" | tee -a "${LOG_FILE}"
# Generate the bbnl cfg file
bbnl_filename="${ICONS_DIR}/bbnl/$folder_name.cfg"
cat > "$bbnl_filename" <<EOL
file_name=/APPS/$folder_name/$elf_filename
title_id=$folder_name
launcher=ELF
EOL
echo "Created bbnl config: $bbnl_filename" | tee -a "${LOG_FILE}"
png_file="${ARTWORK_DIR}/${folder_name}.png"
# Copy the matching PNG file from ART_DIR, or default to APP.png
if [ -f "$png_file" ]; then
cp "$png_file" "${ICONS_DIR}/$folder_name/jkt_001.png" | tee -a "${LOG_FILE}"
cp "$png_file" "${GAMES_PATH}/ART/${elf}_COV.png" | tee -a "${LOG_FILE}"
echo "Artwork found locally for $title" | tee -a "${LOG_FILE}"
else
echo "Artwork not found locally. Attempting to download from the PSBBN art database..." | tee -a "${LOG_FILE}"
wget --quiet --timeout=10 --tries=3 --output-document="$png_file" \
"https://raw.githubusercontent.com/CosmicScale/psbbn-art-database/main/apps/${folder_name}.png"
if [[ -s "$png_file" ]]; then
echo "Successfully downloaded artwork for $folder_name" | tee -a "${LOG_FILE}"
cp "$png_file" "${ICONS_DIR}/$folder_name/jkt_001.png" | tee -a "${LOG_FILE}"
cp "$png_file" "${GAMES_PATH}/ART/${elf}_COV.png" | tee -a "${LOG_FILE}"
else
rm -f "$png_file"
echo "Artwork not found for $folder_name. Using default APP image." | tee -a "${LOG_FILE}"
cp "$ARTWORK_DIR/APP.png" "${ICONS_DIR}/$folder_name/jkt_001.png" | tee -a "${LOG_FILE}"
echo "$folder_name,$title,$elf" >> "${MISSING_APP_ART}"
fi
fi
cp "${ASSETS_DIR}/BBNL"/{boot.kelf,system.cnf} "$dir"
COMMANDS="device ${DEVICE}\n"
COMMANDS+="mkpart PP.$folder_name 128M PFS\n"
COMMANDS+="mount PP.$folder_name\n"
COMMANDS+="mkdir res\n"
COMMANDS+="cd res\n"
COMMANDS+="lcd '${ICONS_DIR}/$folder_name'\n"
COMMANDS+="put info.sys\n"
COMMANDS+="put jkt_001.png\n"
COMMANDS+="cd /\n"
COMMANDS+="umount\n"
COMMANDS+="exit"
echo "Creating PP.$folder_name..." | tee -a "${LOG_FILE}"
echo -e "$COMMANDS" | sudo "${HELPER_DIR}/PFS Shell.elf" >> "${LOG_FILE}" 2>&1
cd "${ICONS_DIR}/$folder_name"
sudo "${HELPER_DIR}/HDL Dump.elf" modify_header "${DEVICE}" "PP.$folder_name" >> "${LOG_FILE}" 2>&1
done
else
echo | tee -a "${LOG_FILE}"
echo "No PSU files found." | tee -a "${LOG_FILE}"
fi
existing_folders=()
# Get all directories and add them to the exclusion list
while IFS= read -r dir; do
folder_name=$(basename "$dir")
existing_folders+=("$folder_name")
done < <(find "$ICONS_DIR" -mindepth 1 -maxdepth 1 -type d | sort -r)
# Build the exclusion conditions dynamically based on the existing_folders array
exclude_conditions=()
for folder in "${existing_folders[@]}"; do
exclude_conditions+=("-not" "-name" "$folder")
done
# Check if any ELF files exist in the source directory
if ! ls "${GAMES_PATH}/APPS/"*.elf "${GAMES_PATH}/APPS/"*.ELF >/dev/null 2>&1; then
echo | tee -a "${LOG_FILE}"
echo "No ELF files found." | tee -a "${LOG_FILE}"
else
# Process each ELF file in the source directory
echo | tee -a "${LOG_FILE}"
echo "Processing ELF files:"| tee -a "${LOG_FILE}"
for file in "${GAMES_PATH}/APPS/"*.elf "${GAMES_PATH}/APPS/"*.ELF; do
[ -e "$file" ] || continue # Skip if no ELF files exist
# Extract filename without path and extension
base_name=$(basename "$file")
base_name_no_ext="${base_name%.*}"
echo | tee -a "${LOG_FILE}"
echo "Found ELF file: $base_name" | tee -a "${LOG_FILE}"
app_name="${base_name_no_ext%%(*}" # Remove anything after an open bracket '('
app_name="${app_name%%[Vv][0-9]*}" # Remove versioning (e.g., v12 or V12)
app_name=$(echo "$app_name" | sed -E 's/[cC][oO][mM][pP][rR][eE][sS][sS][eE][dD].*//') # Remove "compressed"
app_name=$(echo "$app_name" | sed -E 's/[pP][aA][cC][kK][eE][dD].*//') # Remove "packed"
app_name=$(echo "$app_name" | sed 's/\.*$//') # Trim trailing full stops
AppDB_check=$(echo "$app_name" | sed 's/[ _-]//g' | tr 'a-z' 'A-Z')
# Check $HELPER_DIR/AppDB.csv for match in first column to $AppDB_check, set $cleaned_name based on second column from file if found. If no match found, set $cleaned_name with the remaining code
match=$(awk -F'|' -v key="$AppDB_check" '$1 && index(key, $1) == 1 {print $2; exit}' "$HELPER_DIR/AppDB.csv")
if [[ -n "$match" ]]; then
cleaned_name="$match"
else
# Use the processed name if no match is found
app_name="${app_name//[_-]/ }" # Replace underscores and hyphens with spaces
app_name="${app_name%"${app_name##*[![:space:]]}"}" # Trim trailing spaces again
app_name=$(echo "$app_name" | sed 's/\.*$//') # Trim trailing full stops again
app_name_before=$(echo "$app_name") # Save the string
app_name=$(echo "$app_name" | sed 's/\([a-z]\)\([A-Z]\)/\1 \2/g') # Add a space before capital letters when preceded by a lowercase letter
# Check if spaces were added by comparing before and after
if [[ "$app_name" != "$app_name_before" ]]; then
space_added=true
else
space_added=false
fi
# Process for title case and exceptions
input_str="$app_name"
# List of terms to ensure spaces before and after
terms=("3d" "3D" "ps2" "PS2" "ps1" "PS1")
# Loop over the terms
for term in "${terms[@]}"; do
input_str="${input_str//${term}/ ${term}}" # Ensure space before the term
input_str="${input_str//${term}/${term} }" # Ensure space after the term
done
# Special case for "hdd" and "HDD" - add spaces only if the string is longer than 5 characters
if [[ ${#input_str} -gt 5 ]]; then
input_str="${input_str//hdd/ hdd }"
input_str="${input_str//HDD/ HDD }"
fi
# Check if the string contains any lowercase letters
if ! echo "$input_str" | grep -q '[a-z]'; then
input_str="${input_str,,}" # Convert the entire string to lowercase
fi
result=""
# Define words to exclude from uppercase conversion (only consonant-only words)
exclude_list="by cry cyst crypt dry fly fry glyph gym gypsy hymn lynx my myth myrrh ply pry rhythm shy sky spy sly sty sync tryst why wry"
# Now process each word
for word in $input_str; do
# Handle words 3 characters or shorter, but only if no space was added by sed
if [[ ${#word} -le 3 ]] && ! $space_added && ! echo "$exclude_list" | grep -wi -q "$word"; then
result+=" ${word^^}" # Convert to uppercase
# Handle consonant-only words (only if not in exclusion list)
elif [[ "$word" =~ ^[b-df-hj-np-tv-z0-9]+$ ]] && ! echo "$exclude_list" | grep -w -q "$word"; then
result+=" ${word^^}" # Uppercase if the word is consonant-only and not in the exclusion list
else
result+=" ${word^}" # Capitalize first letter for all other words
fi
cleaned_name="${result# }"
done
# Remove leading space and ensure no double spaces are left
result="${result#"${result%%[![:space:]]*}"}" # Remove leading spaces
cleaned_name=$(echo "$result" | sed 's/ / /g') # Replace double spaces with single spaces
fi
folder_name=$(echo "$cleaned_name" | tr '[:lower:]' '[:upper:]' | tr -cd 'A-Z0-9' | cut -c1-11) # Replace spaces with underscores & capitalize
# Create the new folder in the destination directory
mkdir -p "${ICONS_DIR}/$folder_name"
# Generate the icon.sys file
icon_sys_filename="${ICONS_DIR}/$folder_name/icon.sys"
cat > "$icon_sys_filename" <<EOL
PS2X
title0=$cleaned_name
title1=
bgcola=0
bgcol0=0,0,0
bgcol1=0,0,0
bgcol2=0,0,0
bgcol3=0,0,0
lightdir0=1.0,-1.0,1.0
lightdir1=-1.0,1.0,-1.0
lightdir2=0.0,0.0,0.0
lightcolamb=64,64,64
lightcol0=64,64,64
lightcol1=16,16,16
lightcol2=0,0,0
uninstallmes0=
uninstallmes1=
uninstallmes2=
EOL
echo "Created icon.sys: $icon_sys_filename" | tee -a "${LOG_FILE}"
# Generate the info.sys file
if [[ "$cleaned_name" == "PSBBN" ]]; then
info_sys_filename="${ICONS_DIR}/$folder_name/info.sys"
cat > "$info_sys_filename" <<EOL
title = $cleaned_name
title_id = $folder_name
title_sub_id = 0
release_date =
developer_id =
publisher_id =
note =
content_web =
image_topviewflag = 0
image_type = 0
image_count = 1
image_viewsec = 600
copyright_viewflag = 0
copyright_imgcount = 0
genre =
parental_lock = 1
effective_date = 0
expire_date = 0
violence_flag = 0
content_type = 256
content_subtype = 0
EOL
else
info_sys_filename="${ICONS_DIR}/$folder_name/info.sys"
cat > "$info_sys_filename" <<EOL
title = $cleaned_name
title_id = $folder_name
title_sub_id = 0
release_date =
developer_id =
publisher_id =
note =
content_web =
image_topviewflag = 0
image_type = 0
image_count = 1
image_viewsec = 600
copyright_viewflag = 0
copyright_imgcount = 0
genre =
parental_lock = 1
effective_date = 0
expire_date = 0
violence_flag = 0
content_type = 255
content_subtype = 0
EOL
echo "Created info.sys: $info_sys_filename" | tee -a "${LOG_FILE}"
fi
if [[ "$folder_name" == "LAUNCHELF" ]]; then
bbnl_cfg="${ICONS_DIR}/bbnl/WLE.cfg"
elif [[ "$folder_name" == "LAUNCHDISC" ]]; then
bbnl_cfg="${ICONS_DIR}/bbnl/DISC.cfg"
else
bbnl_cfg="$ICONS_DIR/bbnl/$folder_name.cfg"
fi
cat > "$bbnl_cfg" <<EOL
file_name=/APPS/$base_name
title_id=$folder_name
launcher=ELF
EOL
echo "Created BBNL config: $folder_name.cfg" | tee -a "${LOG_FILE}"
echo "$cleaned_name=mass:/APPS/$base_name" >> "${ICONS_DIR}/bbnl/conf_apps.cfg" 2>> "${LOG_FILE}"
cp "${ASSETS_DIR}/BBNL/boot.kelf" "${ICONS_DIR}/$folder_name" | tee -a "${LOG_FILE}"
cp "${ASSETS_DIR}/BBNL/system.cnf" "${ICONS_DIR}/$folder_name" | tee -a "${LOG_FILE}"
if [[ "$folder_name" == "LAUNCHELF" ]]; then
cp "${ICONS_DIR}/ico/wle.ico" "${ICONS_DIR}/$folder_name/list.ico" | tee -a "${LOG_FILE}"
cp "${ICONS_DIR}/ico/wle-del.ico" "${ICONS_DIR}/$folder_name/del.ico" | tee -a "${LOG_FILE}"
elif [[ "$folder_name" == "PSBBN" ]]; then
cp "${ICONS_DIR}/ico/psbbn.ico" "${ICONS_DIR}/$folder_name/list.ico" | tee -a "${LOG_FILE}"
elif [[ "$folder_name" == "HDDOSD" ]]; then
cp "${ICONS_DIR}/ico/hdd-osd.ico" "${ICONS_DIR}/$folder_name/list.ico" | tee -a "${LOG_FILE}"
else
cp "${ICONS_DIR}/ico/app.ico" "${ICONS_DIR}/$folder_name/list.ico" | tee -a "${LOG_FILE}"
cp "${ICONS_DIR}/ico/app-del.ico" "${ICONS_DIR}/$folder_name/del.ico" | tee -a "${LOG_FILE}"
fi
png_file="${ARTWORK_DIR}/${folder_name}.png"
# Copy the matching PNG file from ART_DIR, or default to APP.png
if [ -f "$png_file" ]; then
cp "$png_file" "${ICONS_DIR}/$folder_name/jkt_001.png" | tee -a "${LOG_FILE}"
cp "$png_file" "${GAMES_PATH}/ART/${base_name}_COV.png" | tee -a "${LOG_FILE}"
echo "Artwork found locally for $base_name" | tee -a "${LOG_FILE}"
else
echo "Artwork not found locally. Attempting to download from the PSBBN art database..." | tee -a "${LOG_FILE}"
wget --quiet --timeout=10 --tries=3 --output-document="$png_file" \
"https://raw.githubusercontent.com/CosmicScale/psbbn-art-database/main/apps/${folder_name}.png"
if [[ -s "$png_file" ]]; then
echo "Successfully downloaded artwork for $base_name" | tee -a "${LOG_FILE}"
cp "$png_file" "${ICONS_DIR}/$folder_name/jkt_001.png" | tee -a "${LOG_FILE}"
cp "$png_file" "${GAMES_PATH}/ART/${base_name}_COV.png" | tee -a "${LOG_FILE}"
else
rm -f "$png_file"
echo "Artwork not found for $base_name. Using default APP image." | tee -a "${LOG_FILE}"
cp "$ARTWORK_DIR/APP.png" "${ICONS_DIR}/$folder_name/jkt_001.png" | tee -a "${LOG_FILE}"
if [[ "$folder_name" != "PSBBN" ]]; then
echo "$folder_name,$cleaned_name,$base_name" >> "${MISSING_APP_ART}"
fi
fi
fi
done
fi
echo | tee -a "${LOG_FILE}"
# Loop through each folder in ICONS_DIR, excluding folders that have already been processed, sorted in reverse alphabetical order
find "$ICONS_DIR" -mindepth 1 -maxdepth 1 -type d "${exclude_conditions[@]}" | sort -r | while IFS= read -r dir; do
COMMANDS="device ${DEVICE}\n"
# Set pp_name based on the folder name
if [[ "$(basename "$dir")" == "LAUNCHELF" ]]; then
pp_name="WLE"
elif [[ "$(basename "$dir")" == "LAUNCHDISC" ]]; then
pp_name="DISC"
else
pp_name=$(basename "$dir")
fi
COMMANDS+="mkpart PP.$pp_name 128M PFS\n"
COMMANDS+="mount PP.$pp_name\n"
if [ "$pp_name" = "DISC" ]; then
COMMANDS+="lcd '${ASSETS_DIR}/DISC'\n"
COMMANDS+="put PS1VModeNeg.elf\n"
fi
COMMANDS+="mkdir res\n"
COMMANDS+="cd res\n"
COMMANDS+="lcd '${ICONS_DIR}/$(basename "$dir")'\n"
COMMANDS+="put info.sys\n"
COMMANDS+="put jkt_001.png\n"
COMMANDS+="cd /\n"
COMMANDS+="umount\n"
COMMANDS+="exit"
echo "Creating PP.$pp_name..." | tee -a "${LOG_FILE}"
echo -e "$COMMANDS" | sudo "${HELPER_DIR}/PFS Shell.elf" >> "${LOG_FILE}" 2>&1
if [ "$pp_name" = "DISC" ]; then
cd "${ASSETS_DIR}/DISC"
sudo "${HELPER_DIR}/HDL Dump.elf" modify_header "${DEVICE}" "PP.$pp_name" >> "${LOG_FILE}" 2>&1
else
cd "${ICONS_DIR}/$(basename "$dir")"
sudo "${HELPER_DIR}/HDL Dump.elf" modify_header "${DEVICE}" "PP.$pp_name" >> "${LOG_FILE}" 2>&1
fi
done
# Create PP.LAUNCHER
echo | tee -a "${LOG_FILE}"
echo "Updating chosen game launcher..." | tee -a "${LOG_FILE}"
COMMANDS="device ${DEVICE}\n"
COMMANDS+="mkpart PP.LAUNCHER 128M PFS\n"
COMMANDS+="mount PP.LAUNCHER\n"
COMMANDS+="mkdir res\n"
COMMANDS+="cd res\n"
if [ "$LAUNCHER" = "OPL" ]; then
COMMANDS+="lcd '${ASSETS_DIR}/OPL'\n"
COMMANDS+="put info.sys\n"
COMMANDS+="lcd '${ARTWORK_DIR}'\n"
COMMANDS+="put OPENPS2LOAD.png\n"
COMMANDS+="rename OPENPS2LOAD.png jkt_001.png\n"
COMMANDS+="cd /\n"
elif [ "$LAUNCHER" = "NEUTRINO" ]; then
COMMANDS+="lcd '${ASSETS_DIR}/NHDDL'\n"
COMMANDS+="put info.sys\n"
COMMANDS+="lcd '${ARTWORK_DIR}'\n"
COMMANDS+="put NHDDL.png\n"
COMMANDS+="rename NHDDL.png jkt_001.png\n"
COMMANDS+="cd /\n"
fi
COMMANDS+="umount\n"
COMMANDS+="exit"
echo >> "${LOG_FILE}"
echo -e "$COMMANDS" | sudo "${HELPER_DIR}/PFS Shell.elf" >> "${LOG_FILE}" 2>&1
if [ "$LAUNCHER" = "OPL" ]; then
cp "${ASSETS_DIR}/BBNL/boot.kelf" "${ASSETS_DIR}/BBNL/system.cnf" "${ASSETS_DIR}/OPL"
cd "${ASSETS_DIR}/OPL"
elif [ "$LAUNCHER" = "NEUTRINO" ]; then
cp "${ASSETS_DIR}/BBNL/boot.kelf" "${ASSETS_DIR}/BBNL/system.cnf" "${ASSETS_DIR}/NHDDL"
cd "${ASSETS_DIR}/NHDDL"
fi
sudo "${HELPER_DIR}/HDL Dump.elf" modify_header "${DEVICE}" PP.LAUNCHER >> "${LOG_FILE}" 2>&1
cd "${TOOLKIT_PATH}"
echo | tee -a "${LOG_FILE}"
echo "Activating Python virtual environment..." | tee -a "${LOG_FILE}"
sleep 5
# Try activating the virtual environment twice before failing
if ! source "${TOOLKIT_PATH}/venv/bin/activate" 2>>"${LOG_FILE}"; then
echo "Failed to activate the Python virtual environment. Retrying..." | tee -a "${LOG_FILE}"
sleep 2
if ! source "${TOOLKIT_PATH}/venv/bin/activate" 2>>"${LOG_FILE}"; then
echo "Failed to activate the Python virtual environment." | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit..."
echo
exit 1
fi
fi
if [[ "$LAUNCHER" == "NEUTRINO" ]]; then
if find "$GAMES_PATH/CD" "$GAMES_PATH/DVD" -type f \( -iname "*.zso" \) | grep -q .; then
echo | tee -a "${LOG_FILE}"
echo "Games in the compressed ZSO format have been found in the CD/DVD folder." | tee -a "${LOG_FILE}"
echo "Neutrino does not support compressed ZSO files."
echo
echo "ZSO files will be converted to ISO files before proceeding."
read -n 1 -s -r -p "Press any key to continue..."
echo
echo
while IFS= read -r -d '' zso_file; do
iso_file="${zso_file%.*}.iso"
echo "Converting: $zso_file -> $iso_file" | tee -a "${LOG_FILE}"
python3 -u "${HELPER_DIR}/ziso.py" -c 0 "$zso_file" "$iso_file" | tee -a "${LOG_FILE}"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
rm -f "$iso_file"
echo "Error: Failed to uncompress $zso_file" | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit..."
echo
exit 1 # Properly exits the main script
fi
rm -f "$zso_file"
done < <(find "$GAMES_PATH/CD" "$GAMES_PATH/DVD" -type f -iname "*.zso" -print0)
fi
fi
# Create games list of PS1 and PS2 games to be installed
echo | tee -a "${LOG_FILE}"
echo "Creating PS1 games list..." | tee -a "${LOG_FILE}"
python3 -u "${HELPER_DIR}/list-builder-ps1.py" "${GAMES_PATH}" "${PS1_LIST}" | tee -a "${LOG_FILE}"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
echo "Error: Failed to create PS1 games list." | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit..."
echo
exit 1
fi
echo | tee -a "${LOG_FILE}"
echo "Creating PS2 games list..." | tee -a "${LOG_FILE}"
python3 -u "${HELPER_DIR}/list-builder-ps2.py" "${GAMES_PATH}" "${PS2_LIST}" | tee -a "${LOG_FILE}"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
echo "Error: Failed to create PS2 games list." | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit..."
echo
exit 1
fi
# Deactivate the virtual environment
deactivate
# Create master list combining PS1 and PS2 games to a single list
if [[ ! -f "${PS1_LIST}" && ! -f "${PS2_LIST}" ]]; then
echo
read -n 1 -s -r -p "No games found to install. Press any key to exit..."
echo
exit 1
elif [[ ! -f "${PS1_LIST}" ]]; then
{ cat "${PS2_LIST}" > "${ALL_GAMES}"; } 2>> "${LOG_FILE}"
else
{ cat "${PS1_LIST}" > "${ALL_GAMES}"; } 2>> "${LOG_FILE}"
{ cat "${PS2_LIST}" >> "${ALL_GAMES}"; } 2>> "${LOG_FILE}"
fi
# Check for master.list
if [[ ! -s "${ALL_GAMES}" ]]; then
echo "Failed to create games list (file is missing or empty)." | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit..."
echo
exit 1
fi
echo "Games list successfully created."| tee -a "${LOG_FILE}"
# Function to find available space
function function_space() {
output=$(sudo "${HELPER_DIR}/HDL Dump.elf" toc ${DEVICE} 2>&1)
# Check for the word "aborting" in the output
if echo "$output" | grep -q "aborting"; then
echo
echo "${DEVICE}: APA partition is broken; aborting." | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit..."
echo
exit 1
fi
# Extract the "used" value, remove "MB" and any commas
used=$(echo "$output" | awk '/used:/ {print $6}' | sed 's/,//; s/MB//')
capacity=124416
# Calculate available space (capacity - used)
available=$((capacity - used))
}
# Count the number of games to be installed
count=$(grep -c '^[^[:space:]]' "${ALL_GAMES}")
echo
echo "Number of games to install: $count" | tee -a "${LOG_FILE}"
function_space
partition_count=$((available / 128))
if [ "$count" -gt "$partition_count" ]; then
echo "Not enough space for $count partitions." | tee -a "${LOG_FILE}"
echo "The first $partition_count games will appear in the PSBBN Game Channel" | tee -a "${LOG_FILE}"
echo "Remaining PS2 games will appear in OPL/NHDDL only"
# Overwrite master.list with the first $partition_count lines
head -n "$partition_count" "$ALL_GAMES" > "${ALL_GAMES}.tmp"
mv "${ALL_GAMES}.tmp" "$ALL_GAMES"
fi
echo >> "${LOG_FILE}"
echo "master.list:" >> "${LOG_FILE}"
cat "$ALL_GAMES" >> "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Ready to install games. Press any key to continue..."
echo
mkdir -p "${ARTWORK_DIR}/tmp" 2>> "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
echo "Downloading artwork..." | tee -a "${LOG_FILE}"
cd "${TOOLKIT_PATH}"
# First loop: Run the art downloader script for each game_id if artwork doesn't already exist
while IFS='|' read -r game_title game_id publisher disc_type file_name; do
# Check if the artwork file already exists
png_file="${ARTWORK_DIR}/${game_id}.png"
if [[ -f "$png_file" ]]; then
echo "Artwork for game ID $game_id already exists. Skipping download." | tee -a "${LOG_FILE}"
else
# Attempt to download artwork using wget
echo "Artwork not found locally. Attempting to download from the PSBBN art database..." | tee -a "${LOG_FILE}"
wget --quiet --timeout=10 --tries=3 --output-document="$png_file" \
"https://raw.githubusercontent.com/CosmicScale/psbbn-art-database/main/art/${game_id}.png"
if [[ -s "$png_file" ]]; then
echo "Successfully downloaded artwork for game ID: $game_id" | tee -a "${LOG_FILE}"
else
# If wget fails, run the art downloader
[[ -f "$png_file" ]] && rm -f "$png_file"
echo "Trying IGN for game ID: $game_id" | tee -a "${LOG_FILE}"
node "${HELPER_DIR}/art_downloader.js" "$game_id" 2>&1 | tee -a "${LOG_FILE}"
fi
fi
# Skip downloading if disc_type is "POPS"
if [[ "$disc_type" == "POPS" ]]; then
continue
fi
png_file_cover="${GAMES_PATH}/ART/${game_id}_COV.png"
png_file_disc="${GAMES_PATH}/ART/${game_id}_ICO.png"
if [[ -f "$png_file_cover" ]]; then
echo "OPL Artwork for game ID $game_id already exists. Skipping download." | tee -a "${LOG_FILE}"
else
# Attempt to download artwork using wget
echo "OPL Artwork not found locally. Attempting to download from archive.org..." | tee -a "${LOG_FILE}"
wget --quiet --timeout=10 --tries=3 --output-document="$png_file_cover" \
"https://archive.org/download/OPLM_ART_2024_09/OPLM_ART_2024_09.zip/PS2/${game_id}/${game_id}_COV.png"
#wget --quiet --timeout=10 --tries=3 --output-document="$png_file_disc" \
# "https://archive.org/download/OPLM_ART_2024_09/OPLM_ART_2024_09.zip/PS2/${game_id}/${game_id}_ICO.png"
missing_files=()
if [[ ! -s "$png_file_cover" ]]; then
[[ -f "$png_file_cover" ]] && rm -f "$png_file_cover"
missing_files+=("cover")
fi
if [[ ! -s "$png_file_disc" ]]; then
[[ -f "$png_file_disc" ]] && rm -f "$png_file_disc"
missing_files+=("disc")
fi
if [[ -f "$png_file_cover" || -f "$png_file_disc" ]]; then
if [[ ${#missing_files[@]} -eq 0 ]]; then
echo "Successfully downloaded OPL artwork for game ID: $game_id" | tee -a "${LOG_FILE}"
else