Skip to content

Commit dcd3a9f

Browse files
committed
playlist: Support m3u8 ending in playlist plugin
1 parent d5f8726 commit dcd3a9f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

beetsplug/playlist.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# included in all copies or substantial portions of the Software.
1313

1414

15-
import fnmatch
1615
import os
1716
import tempfile
1817
from collections.abc import Sequence
@@ -22,6 +21,10 @@
2221
from beets.util import path_as_posix
2322

2423

24+
def is_m3u_file(path):
25+
return os.path.splitext(path)[1].lower() in {".m3u", ".m3u8"}
26+
27+
2528
class PlaylistQuery(InQuery[bytes]):
2629
"""Matches files listed by a playlist file."""
2730

@@ -45,7 +48,7 @@ def __init__(self, _, pattern: str, __):
4548

4649
paths = []
4750
for playlist_path in playlist_paths:
48-
if not fnmatch.fnmatch(playlist_path, "*.[mM]3[uU]"):
51+
if not is_m3u_file(playlist_path):
4952
# This is not am M3U playlist, skip this candidate
5053
continue
5154

@@ -148,7 +151,7 @@ def find_playlists(self):
148151
return
149152

150153
for filename in dir_contents:
151-
if fnmatch.fnmatch(filename, "*.[mM]3[uU]"):
154+
if is_m3u_file(filename):
152155
yield os.path.join(self.playlist_dir, filename)
153156

154157
def update_playlist(self, filename, base_dir):

0 commit comments

Comments
 (0)