Catalysis of the removal of pyrimidine dimers by removing the 5' pyrimidine of the dimer by cleaving the N-C1' glycosidic bond between the 5' pyrimidine of the dimer and the deoxyribose sugar. The reaction releases the 5' pyrimidine of the dimer and leaves an apurinic (AP) site. The reaction involves the formation of a covalent enzyme substrate intermediate. Release of the enzyme and free base by a beta-elimination or a beta, gamma-elimination mechanism results in the cleavage of the DNA backbone 3' of the apyrimidinic (AP) site.