playlists: Rename M3U to EXTM3U
This commit is contained in:
parent
6af11b563f
commit
12c27142a3
@ -16,7 +16,7 @@ except ImportError:
|
||||
|
||||
def parse(data):
|
||||
handlers = {
|
||||
detect_m3u_header: parse_m3u,
|
||||
detect_extm3u_header: parse_extm3u,
|
||||
detect_pls_header: parse_pls,
|
||||
detect_asx_header: parse_asx,
|
||||
detect_xspf_header: parse_xspf,
|
||||
@ -27,7 +27,7 @@ def parse(data):
|
||||
return []
|
||||
|
||||
|
||||
def detect_m3u_header(data):
|
||||
def detect_extm3u_header(data):
|
||||
return data[0:7].upper() == b'#EXTM3U'
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ def detect_asx_header(data):
|
||||
return False
|
||||
|
||||
|
||||
def parse_m3u(data):
|
||||
def parse_extm3u(data):
|
||||
# TODO: convert non URIs to file URIs.
|
||||
found_header = False
|
||||
for line in data.splitlines():
|
||||
|
||||
@ -11,7 +11,7 @@ from mopidy.internal import playlists
|
||||
|
||||
BAD = b'foobarbaz'
|
||||
|
||||
M3U = b"""#EXTM3U
|
||||
EXTM3U = b"""#EXTM3U
|
||||
#EXTINF:123, Sample artist - Sample title
|
||||
file:///tmp/foo
|
||||
#EXTINF:321,Example Artist - Example \xc5\xa7\xc5\x95
|
||||
@ -82,7 +82,7 @@ EXPECTED = [b'file:///tmp/foo', b'file:///tmp/bar', b'file:///tmp/baz']
|
||||
|
||||
@pytest.mark.parametrize('data,result', [
|
||||
(BAD, []),
|
||||
(M3U, EXPECTED),
|
||||
(EXTM3U, EXPECTED),
|
||||
(PLS, EXPECTED),
|
||||
(ASX, EXPECTED),
|
||||
(SIMPLE_ASX, EXPECTED),
|
||||
@ -113,11 +113,11 @@ class BasePlaylistTest(object):
|
||||
self.assertEqual(uris, [])
|
||||
|
||||
|
||||
class M3uPlaylistTest(BasePlaylistTest, unittest.TestCase):
|
||||
valid = M3U
|
||||
class ExtM3uPlaylistTest(BasePlaylistTest, unittest.TestCase):
|
||||
valid = EXTM3U
|
||||
invalid = BAD
|
||||
detect = staticmethod(playlists.detect_m3u_header)
|
||||
parse = staticmethod(playlists.parse_m3u)
|
||||
detect = staticmethod(playlists.detect_extm3u_header)
|
||||
parse = staticmethod(playlists.parse_extm3u)
|
||||
|
||||
|
||||
class PlsPlaylistTest(BasePlaylistTest, unittest.TestCase):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user