mirror of
https://github.com/sigmasternchen/mobmash.click
synced 2025-03-15 08:09:02 +00:00
cleanup: Filter out non-existing images
This commit is contained in:
parent
e0d6605a44
commit
c242caea11
2 changed files with 11 additions and 2 deletions
|
@ -10,7 +10,8 @@ echo "Filtering invalid entries...\n";
|
|||
$mobs = array_filter($mobs, fn ($mob) =>
|
||||
!str_starts_with($mob, "id=") &&
|
||||
!str_contains($mob, "Old ") &&
|
||||
$mob != "NPC" && $mob != "Agent" &&
|
||||
$mob != "NPC" &&
|
||||
$mob != "Agent" &&
|
||||
!str_ends_with($mob, "Ghost") &&
|
||||
$mob != "Giant" &&
|
||||
$mob != "Killer Bunny"
|
||||
|
@ -22,6 +23,9 @@ $mobs = array_map(fn ($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);
|
||||
|
|
|
@ -69,7 +69,12 @@ function getImageUrlFromName(string $filename): string {
|
|||
}
|
||||
|
||||
function getImage(string $name): string {
|
||||
return getImageUrlFromName(getImageName($name));
|
||||
$name = getImageName($name);
|
||||
if ($name == "") {
|
||||
return "";
|
||||
} else {
|
||||
return getImageUrlFromName($name);
|
||||
}
|
||||
}
|
||||
|
||||
function downloadImage(string $url, string $mobname): string {
|
||||
|
|
Loading…
Reference in a new issue