X-Git-Url: https://git.rvb.name/vpproxy.git/blobdiff_plain/21abfc4eb5f6f49ef263d0c1961fb1dff19f337c..1074f7e8729c2ff065d73960c5450c9356c2fd11:/plugins/modules/M3uParser.py diff --git a/plugins/modules/M3uParser.py b/plugins/modules/M3uParser.py index 01dbcc9..9e2fce6 100644 --- a/plugins/modules/M3uParser.py +++ b/plugins/modules/M3uParser.py @@ -2,6 +2,8 @@ # http://n4k3d.com/the-m3u-file-format/ import sys +import hexdump +import codecs class track(): def __init__(self, length, title, path): @@ -23,6 +25,9 @@ def parseM3U(infile): #EXTM3U # this is not a valid M3U and we should stop.. line = inf.readline() + line = line.lstrip('\xef\xbb\xbf') + line = line.rstrip('\n') + line = line.strip() if not line.startswith('#EXTM3U'): return @@ -31,10 +36,13 @@ def parseM3U(infile): song=track(None,None,None) for line in inf: - line=line.strip() + line = line.lstrip('\xef\xbb\xbf') + line = line.rstrip('\n') + line = line.strip() if line.startswith('#EXTINF:'): # pull length and title from #EXTINF line length,title=line.split('#EXTINF:')[1].split(',',1) + title=title.decode('string_escape') song=track(length,title,None) elif (len(line) != 0): # pull song path from all other, non-blank lines