There are several popular playlists used for internet radio streaming: asx, m3u, smil, asf, pls... The playlist extension is not always visible in the URL that an ipradio station returns. Furthermore, the MIME type is not always correct. Sometimes one has no choice but to guess the playlist type by looking for the presence of certain markers.
After fruitless searches on the internet, I wrote an python library that detects playlist type. You can download it here.
I am sure that the detection algorithm can be improved. Please write suggestions in the comments.