Something like this:
repeat_starts = -1
for ( i=31; i>16; i-- )
if ( title[i] == title[i-17] )
repeat_starts = i
else
break for_loop
if ( repeat_starts > 0 )
title[repeat_starts] = "\0"
In English: Compare the last character to the character 17 positions before it. If it's the same, assume it's been duplicated. Now check the prior positions for duplication. Keep moving back until there's not a duplication. This is the last valid character; chop everything else off.
There are definitely places where this will break, where there happen to be matching characters in the data:
01234567890123456789012345678901
Really long song titles break only in odd casesShould be "
Really long song titles break on" but will get corrupted to "
Really long song titles break ". Worse things have happened.