Merge pull request #929 from kingosticks/fix/utf8-chars-in-m3u-playlists

Support utf-8 chars in m3u playlists
This commit is contained in:
Stein Magnus Jodal 2015-01-04 22:19:08 +01:00
commit 378daeb35a
3 changed files with 14 additions and 6 deletions

View File

@ -93,6 +93,14 @@ v0.20.0 (UNRELEASED)
- Add basic tests for the stream library provider.
v0.19.6 (UNRELEASED)
====================
**Audio**
- Support UTF-8 in M3U playlists. (Fixes: :issue:`853`)
v0.19.5 (2014-12-23)
====================

View File

@ -58,11 +58,11 @@ def parse_m3u(data):
# TODO: convert non URIs to file URIs.
found_header = False
for line in data.readlines():
if found_header or line.startswith('#EXTM3U'):
if found_header or line.startswith(b'#EXTM3U'):
found_header = True
else:
continue
if not line.startswith('#') and line.strip():
if not line.startswith(b'#') and line.strip():
yield line.strip()

View File

@ -13,7 +13,7 @@ BAD = b'foobarbaz'
M3U = b"""#EXTM3U
#EXTINF:123, Sample artist - Sample title
file:///tmp/foo
#EXTINF:321,Example Artist - Example title
#EXTINF:321,Example Artist - Example \xc5\xa7\xc5\x95
file:///tmp/bar
#EXTINF:213,Some Artist - Other title
file:///tmp/baz
@ -25,7 +25,7 @@ File1=file:///tmp/foo
Title1=Sample Title
Length1=123
File2=file:///tmp/bar
Title2=Example title
Title2=Example \xc5\xa7\xc5\x95
Length2=321
File3=file:///tmp/baz
Title3=Other title
@ -40,7 +40,7 @@ ASX = b"""<ASX version="3.0">
<REF href="file:///tmp/foo" />
</ENTRY>
<ENTRY>
<TITLE>Example title</TITLE>
<TITLE>Example \xc5\xa7\xc5\x95</TITLE>
<REF href="file:///tmp/bar" />
</ENTRY>
<ENTRY>
@ -65,7 +65,7 @@ XSPF = b"""<?xml version="1.0" encoding="UTF-8"?>
<location>file:///tmp/foo</location>
</track>
<track>
<title>Example title</title>
<title>Example \xc5\xa7\xc5\x95</title>
<location>file:///tmp/bar</location>
</track>
<track>