Skip to content

Commit a01e603

Browse files
authored
Support m3u8 ending in playlist plugin (#5829)
m3u8 files are technically supported in the playlist plugin, only the difference in the file ending prevented usage of such files.
2 parents d5f8726 + cf557fb commit a01e603

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

beetsplug/playlist.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@
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
18+
from pathlib import Path
1919

2020
import beets
2121
from beets.dbcore.query import BLOB_TYPE, InQuery
2222
from beets.util import path_as_posix
2323

2424

25+
def is_m3u_file(path: str) -> bool:
26+
return Path(path).suffix.lower() in {".m3u", ".m3u8"}
27+
28+
2529
class PlaylistQuery(InQuery[bytes]):
2630
"""Matches files listed by a playlist file."""
2731

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

4650
paths = []
4751
for playlist_path in playlist_paths:
48-
if not fnmatch.fnmatch(playlist_path, "*.[mM]3[uU]"):
52+
if not is_m3u_file(playlist_path):
4953
# This is not am M3U playlist, skip this candidate
5054
continue
5155

@@ -148,7 +152,7 @@ def find_playlists(self):
148152
return
149153

150154
for filename in dir_contents:
151-
if fnmatch.fnmatch(filename, "*.[mM]3[uU]"):
155+
if is_m3u_file(filename):
152156
yield os.path.join(self.playlist_dir, filename)
153157

154158
def update_playlist(self, filename, base_dir):

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ New features:
2626
* :doc:`plugins/duplicates`: Add ``--remove`` option, allowing to remove from
2727
the library without deleting media files.
2828
:bug:`5832`
29+
* :doc:`plugins/playlist`: Support files with the `.m3u8` extension.
30+
:bug:`5829`
2931

3032
Bug fixes:
3133

0 commit comments

Comments
 (0)