Article 9.3 of the Spanish Rental Acts clearly states that if the landlord says he/she needs the house because of a divorce, it has to have a judicial final decision (sentencia firme de divorcio). So, ask the landlord for a “testimonio judicial de la sentencia y su firmeza” = a judicial certification of the decision and its final validity.
The landlord has to ask you to leave and provide you with this “judicial final decision” two months before the date you will have to leave the house.
If the situation is not as clear as that, I would look for a lawyer. It may be that you don’t have to leave the house.