You are talking about "transcodes".
The easiest way to determine the quality of the track is by looking at spectrograms. The higher the quality of the sound, the higher will the spectrogram "peak". When analysing MP3s, you will get 16kHz for 128 CBR and around 19-20kHz for V0 (VBR) and 320 CBR.
Here's how a spectrogram looks like:
Bear in mind however that this just gives you a general idea of the quality of the track. If the track is not mastered well, or is an ambient track without much detail, or is based on lossy samples, or is simply a shoddy production, even when you download a track from an official source, it might not have a great spectrogram.
So in general there is no automated way of determining the exact history of the file, however the above way allows you to get a general idea of the sound quality of the song and perhaps see whether the file is an obvious transcode.