summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ0J0 T <jojo@peek-a-boo.at>2022-08-12 09:33:09 +0200
committerJ0J0 Todos <jojo@peek-a-boo.at>2023-03-29 07:21:27 +0200
commit39e4b90b5c8c947950cc54beb0f197cc216724bd (patch)
tree4c948f698ea4520583a442baf64d5279842ad8bb
parent68240f6e03d91c622a53d02b90b0755673fd2e7f (diff)
convert: playlist: Add tests checking extm3u and
fix extm3u check in load method.
-rw-r--r--beets/util/__init__.py2
-rw-r--r--test/rsrc/playlist_non_ext.m3u2
-rw-r--r--test/test_m3ufile.py12
3 files changed, 15 insertions, 1 deletions
diff --git a/beets/util/__init__.py b/beets/util/__init__.py
index 9f0460ce1..e28039927 100644
--- a/beets/util/__init__.py
+++ b/beets/util/__init__.py
@@ -162,7 +162,7 @@ class M3UFile():
"""
with open(self.path, "r") as playlist_file:
raw_contents = playlist_file.readlines()
- self.extm3u = True if raw_contents[0] == "#EXTM3U" else False
+ self.extm3u = True if raw_contents[0] == "#EXTM3U\n" else False
for line in raw_contents[1:]:
if line.startswith("#"):
# Some EXTM3U comment, do something. FIXME
diff --git a/test/rsrc/playlist_non_ext.m3u b/test/rsrc/playlist_non_ext.m3u
new file mode 100644
index 000000000..a2d179010
--- /dev/null
+++ b/test/rsrc/playlist_non_ext.m3u
@@ -0,0 +1,2 @@
+/This/is/a/path/to_a_file.mp3
+/This/is/another/path/to_a_file.mp3
diff --git a/test/test_m3ufile.py b/test/test_m3ufile.py
index e0ab80fa0..a3f8703b5 100644
--- a/test/test_m3ufile.py
+++ b/test/test_m3ufile.py
@@ -72,6 +72,18 @@ class M3UFileTest(unittest.TestCase):
self.assertEqual(m3ufile.media_list[0],
'/This/is/å/path/to_a_file.mp3\n')
+ def test_playlist_load_extm3u(self):
+ the_playlist_file = path.join(RSRC, b'playlist.m3u')
+ m3ufile = M3UFile(the_playlist_file)
+ m3ufile.load()
+ self.assertTrue(m3ufile.extm3u)
+
+ def test_playlist_load_non_extm3u(self):
+ the_playlist_file = path.join(RSRC, b'playlist_non_ext.m3u')
+ m3ufile = M3UFile(the_playlist_file)
+ m3ufile.load()
+ self.assertFalse(m3ufile.extm3u)
+
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)