From what I understand the first quote is from The Witcher.
‘Geralt,’ said the lawyer, closing his eyes. ‘What drives you? If you want to save Ciri . . . I wouldn’t have thought you could afford the luxury of contempt. No, that was badly expressed. You can’t afford the luxury of spurning contempt. A time of contempt is approaching, Witcher, my friend, a time of great and utter contempt. You have to adapt. What I’m proposing is a simple solution. Someone will die, so someone else can live. Someone you love will survive. A girl you don’t know, and whom you’ve never seen, will die—’ "
Apparently in the original Polish they used pogarda, meaning a "mix of feelings of lack of respect, aversion and superiority over someone". (Reddit link.)
In English, then, they mean contempt as in "disdain and hatred for something". In this case, I understand that Geralt is going to be hated (by society? by himself?), and the lawyer thinks Geralt has to use that hatred against him as emotional fuel to find Ciri.
The second one is more straightforward. Contempt here more means "hate". It sounds like it means the speaker will get something, but only by doing something that will make them hate themselves.
Probably someone who's read The Witcher could make this clearer.