From dcd3a9f7f493d66e1e5df318b057af31325218a3 Mon Sep 17 00:00:00 2001 From: J0J0 Todos Date: Wed, 22 Nov 2023 00:03:02 +0100 Subject: [PATCH 1/3] playlist: Support m3u8 ending in playlist plugin --- beetsplug/playlist.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/beetsplug/playlist.py b/beetsplug/playlist.py index cb16fb5bc..8f1a2413d 100644 --- a/beetsplug/playlist.py +++ b/beetsplug/playlist.py @@ -12,7 +12,6 @@ # included in all copies or substantial portions of the Software. -import fnmatch import os import tempfile from collections.abc import Sequence @@ -22,6 +21,10 @@ from beets.dbcore.query import BLOB_TYPE, InQuery from beets.util import path_as_posix +def is_m3u_file(path): + return os.path.splitext(path)[1].lower() in {".m3u", ".m3u8"} + + class PlaylistQuery(InQuery[bytes]): """Matches files listed by a playlist file.""" @@ -45,7 +48,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 +151,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): From 257991c73de79820819275a60af2d697a3b42c34 Mon Sep 17 00:00:00 2001 From: J0J0 Todos Date: Thu, 3 Jul 2025 10:52:41 +0200 Subject: [PATCH 2/3] playlist: Changelog for #5829 --- docs/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index d1a477cb5..5cf0557cc 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -26,6 +26,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: From cf557fb41b28ef254881cf40656a3012618647fa Mon Sep 17 00:00:00 2001 From: J0J0 Todos <2733783+JOJ0@users.noreply.github.com> Date: Sun, 6 Jul 2025 08:57:58 +0200 Subject: [PATCH 3/3] playlist: Use pathlib.Path and add types for is_m3u_file() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Šarūnas Nejus --- beetsplug/playlist.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/beetsplug/playlist.py b/beetsplug/playlist.py index 8f1a2413d..7a27b02a3 100644 --- a/beetsplug/playlist.py +++ b/beetsplug/playlist.py @@ -15,14 +15,15 @@ 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): - return os.path.splitext(path)[1].lower() in {".m3u", ".m3u8"} +def is_m3u_file(path: str) -> bool: + return Path(path).suffix.lower() in {".m3u", ".m3u8"} class PlaylistQuery(InQuery[bytes]):