def read_m3u(self, plsname): """ This is the (m3u) playlist reading function. Arguments: plsname - the playlist filename Returns: The list of interesting lines in the playlist """ try: lines = util.readfile(plsname) except IOError: print 'Cannot open file "%s"' % plsname return 0 try: playlist_lines_dos = map(lambda l: l.strip(), lines) playlist_lines = filter(lambda l: l[0] != '#', playlist_lines_dos) except IndexError: print 'Bad m3u playlist file "%s"' % plsname return 0 (curdir, playlistname) = os.path.split(plsname) for line in playlist_lines: if '\0' in line: print 'WARNING m3u file contains NULL byte character(s), lines skipped' + line return 1 if line.endswith('\r\n'): line = line.replace('\\', '/') # Fix MSDOS slashes if os.path.exists(os.path.join(curdir,line)): self.playlist.append(os.path.join(curdir,line))