Skip to content

Commit dc3410f

Browse files
committed
This PR improves the regex detection used for the drive_sep_replace default.
1 parent edbf737 commit dc3410f

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

beets/dbcore/db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ def _get_formatted(self, model: Model, key: str) -> str:
159159
sep_repl: str = beets.config["path_sep_replace"].as_str()
160160
sep_drive: str = beets.config["drive_sep_replace"].as_str()
161161

162-
if re.match(r"^\w:", value):
163-
value = re.sub(r"(?<=^\w):", sep_drive, value)
162+
if re.match(r"^[a-zA-Z]:", value):
163+
value = re.sub(r"(?<=[a-zA-Z]):", sep_drive, value)
164164

165165
for sep in (os.path.sep, os.path.altsep):
166166
if sep:

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ Bug fixes
6060
``duplicate_action`` config options were silently ignored for as-is imports.
6161
- :doc:`/plugins/convert`: Fix extension substitution inside path of the
6262
exported playlist.
63+
- :ref:`replace`: Made ``drive_sep_replace`` regex logic more precise to prevent
64+
edge-case mismatches (e.g., a song titled "1:00 AM" would incorrectly be
65+
considered a Windows drive path).
6366

6467
For plugin developers
6568
~~~~~~~~~~~~~~~~~~~~~

docs/plugins/duplicates.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ file. The available options mirror the command-line options:
5757
- **delete**: Remove matched items from the library and from the disk. Default:
5858
``no``
5959
- **format**: A specific format with which to print every track or album. This
60-
uses the same template syntax as beets' :doc:`path
61-
formats</reference/pathformat>`. The usage is inspired by, and therefore
62-
similar to, the :ref:`list <list-cmd>` command. Default: :ref:`format_item`
60+
uses the same template syntax as beets' :doc:`path formats
61+
</reference/pathformat>`. The usage is inspired by, and therefore similar to,
62+
the :ref:`list <list-cmd>` command. Default: :ref:`format_item`
6363
- **full**: List every track or album that has duplicates, not just the
6464
duplicates themselves. Default: ``no``
6565
- **keys**: Define in which track or album fields duplicates are to be searched.

0 commit comments

Comments
 (0)