I still haven't sorted out what to do when some of the file parts expires.
It is possible to look at even expired domains, but I am not sure how.
Use name_history instead of name_show, then fetch the last (i.e. latest) record of the result. If the domain has expired, the number of blocks found since the expiration time simply shows up as a negative number, e.g.
namecoin name_history d/capitalism
gives you
...
"expires_in : -144"
...In other words: d/capitalism has expired yesterday.