programs with non zero and equal episode numbers are considered duplicates

Not sure you want this but here goes:
After getting tired of removing dups i tried this change, it seem to have worked fine for me so far (i use XMLTV).
I was a bit perplexed to see that the exisiting code did compare two episode struct pointers but perhaps it make sense for those who understand the tvheadend innards well.
Off topic: I wish tvheadend was written in C++ to make it easy to understand, i guess C is needed for "small devices".