Skip to content

Commit 8d58a82

Browse files
committed
playlist: Support m3u8 ending in playlist plugin
1 parent 8fd20b9 commit 8d58a82

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
@@ -23,6 +22,10 @@
2322
from beets.util import path_as_posix
2423

2524

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

@@ -46,7 +49,7 @@ def __init__(self, _, pattern: str, __):
4649

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

@@ -149,7 +152,7 @@ def find_playlists(self):
149152
return
150153

151154
for filename in dir_contents:
152-
if fnmatch.fnmatch(filename, "*.[mM]3[uU]"):
155+
if is_m3u_file(filename):
153156
yield os.path.join(self.playlist_dir, filename)
154157

155158
def update_playlist(self, filename, base_dir):

0 commit comments

Comments
 (0)