well no
spain did manage to hold onto cuba and puerto rico for quite a long while and only really lost it due to foreign intervention
obviously they wouldn't have managed to hold onto the whole continent with just force, but politicaly there seems to have been quite a will from many sectors to remained as part of spain or at least linked with spain
i think the empire could have definitively survived the napoleonic wars, but idk for how long or how it would have fallen
because what triggered the collapse is, like i said, something incredibly unbelievably incomprehensible stupid as having both your king and the heir be kidnapped and forced to accept some random french dude as the king.
then came the whole guerrilla war and they formed juntas and whatever, and because the americans didn't want to recognize the regency juntas they made their own and the rest is history....
in and of itself there wasn't really enough support from revolutionary type of people to make the whole continent independent by themselves. there were definitively some learned people and some elites that were all into the whole republican thing, or even if not republicanism, at least into having some sort of autonomy, but it all went down because of a critical political failure of the top authority of the empire to just basically vanish and then you have a big power vacuum
not only did all this happen, but when the napoleonic wars were all wrapped up, then the spanish king kept being unbelievably stupid. the spanish (with their junta) ended up signing a constitution and then wanted the king to swear to that constitution. then the king was like "ugh no i dont wanna" and brought back absolutism. then they couped him (and some of these couping soldiers were supposed to be part of a big armada to retake america), and made him accept the constitution again. and THEN he killed the libs again, with the help of the french, and went back to absolutism again.
all of this political flip-flopping from the mainland obviously didn't help at all with establishing some sort of accord with the americans, nor to fight them back effectively
it both pissed off the more liberal people who wanted a constitutional monarchy, and the royalists/elites who wanted nothing to do with that.
then not only that, if you somehow imagine a world where they reconquer america effectively, or at least like 80% of it, there comes the epic meme that the retarded king couldn't even produce a male heir, and in the 30s you have the whole Carlist war autism. (which itself, as well as being a succession crisis/war, ended up also turning into a Libs vs Absolutists conflict too). so even in this world, the empire would have probably fallen apart
so for the empire to survive the 19th century, the monarchy would have had to not get kidnapped nor end up in any silly civil wars, and the king would have had to...well you know...have sex..........................more........