!str_starts_with($mob, "id=") && !str_contains($mob, "Old ") && $mob != "NPC" && $mob != "Agent" && !str_ends_with($mob, "Ghost") && $mob != "Giant" && $mob != "Killer Bunny" ); echo "Fetching image URLs...\n"; $mobs = array_map(fn ($mob) => [ "name" => $mob, "image" => getImage($mob) ], $mobs); echo "Removing non-existing images...\n"; $mobs = array_filter($mobs, fn ($mob) => $mob["image"] != ""); echo "Removing duplicates...\n"; $mobs = array_reduce($mobs, function ($mobs, $mob) { $urls = array_map(fn ($mob) => $mob["image"], $mobs); if (!in_array($mob["image"], $urls)) { $mobs[] = $mob; } return $mobs; }, []); echo "Downloading images...\n"; foreach ($mobs as &$mob) { echo " ... " . $mob["name"] . "\n"; $filename = downloadImage($mob["image"], $mob["name"]); $mob["filename"] = $filename; } echo "Adding to database...\n"; foreach ($mobs as &$mob) { echo " ... " . $mob["name"] . "\n"; addOrUpdateMob($mob["name"], $mob["filename"]); } echo "Done.";