diff --git a/beetsplug/playlist.py b/beetsplug/playlist.py index cb16fb5bc..7a27b02a3 100644 --- a/beetsplug/playlist.py +++ b/beetsplug/playlist.py @@ -12,16 +12,20 @@ # included in all copies or substantial portions of the Software. -import fnmatch import os import tempfile from collections.abc import Sequence +from pathlib import Path import beets from beets.dbcore.query import BLOB_TYPE, InQuery from beets.util import path_as_posix +def is_m3u_file(path: str) -> bool: + return Path(path).suffix.lower() in {".m3u", ".m3u8"} + + class PlaylistQuery(InQuery[bytes]): """Matches files listed by a playlist file.""" @@ -45,7 +49,7 @@ class PlaylistQuery(InQuery[bytes]): paths = [] for playlist_path in playlist_paths: - if not fnmatch.fnmatch(playlist_path, "*.[mM]3[uU]"): + if not is_m3u_file(playlist_path): # This is not am M3U playlist, skip this candidate continue @@ -148,7 +152,7 @@ class PlaylistPlugin(beets.plugins.BeetsPlugin): return for filename in dir_contents: - if fnmatch.fnmatch(filename, "*.[mM]3[uU]"): + if is_m3u_file(filename): yield os.path.join(self.playlist_dir, filename) def update_playlist(self, filename, base_dir): diff --git a/docs/changelog.rst b/docs/changelog.rst index fb4434b66..ff4c63f4b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -28,6 +28,8 @@ New features: * :doc:`plugins/duplicates`: Add ``--remove`` option, allowing to remove from the library without deleting media files. :bug:`5832` +* :doc:`plugins/playlist`: Support files with the `.m3u8` extension. + :bug:`5829` Bug fixes: