diff --git a/beets/importer.py b/beets/importer.py index f7d6aedba..4f73c768e 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -1457,7 +1457,7 @@ def albums_in_dir(path): match = marker_pat.match(subdir) if match: subdir_pat = re.compile( - r'^%s\d' % re.escape(match.group(1)), re.I + b'^%s\d' % re.escape(match.group(1)), re.I ) else: start_collapsing = False @@ -1478,8 +1478,9 @@ def albums_in_dir(path): start_collapsing = True # Set the current pattern to match directories with the same # prefix as this one, followed by a digit. + print(repr(re.escape(match.group(1)))) collapse_pat = re.compile( - r'^%s\d' % re.escape(match.group(1)), re.I + b'^%s\d' % re.escape(match.group(1)), re.I ) break diff --git a/test/test_importer.py b/test/test_importer.py index 48a489258..74d82a6a1 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -1383,38 +1383,38 @@ class MultiDiscAlbumsInDirTest(_common.TestCase): def setUp(self): super(MultiDiscAlbumsInDirTest, self).setUp() - self.base = os.path.abspath(os.path.join(self.temp_dir, 'tempdir')) + self.base = os.path.abspath(os.path.join(self.temp_dir, b'tempdir')) os.mkdir(self.base) self.dirs = [ # Nested album, multiple subdirs. # Also, false positive marker in root dir, and subtitle for disc 3. - os.path.join(self.base, 'ABCD1234'), - os.path.join(self.base, 'ABCD1234', 'cd 1'), - os.path.join(self.base, 'ABCD1234', 'cd 3 - bonus'), + os.path.join(self.base, b'ABCD1234'), + os.path.join(self.base, b'ABCD1234', b'cd 1'), + os.path.join(self.base, b'ABCD1234', b'cd 3 - bonus'), # Nested album, single subdir. # Also, punctuation between marker and disc number. - os.path.join(self.base, 'album'), - os.path.join(self.base, 'album', 'cd _ 1'), + os.path.join(self.base, b'album'), + os.path.join(self.base, b'album', b'cd _ 1'), # Flattened album, case typo. # Also, false positive marker in parent dir. - os.path.join(self.base, 'artist [CD5]'), - os.path.join(self.base, 'artist [CD5]', 'CAT disc 1'), - os.path.join(self.base, 'artist [CD5]', 'CAt disc 2'), + os.path.join(self.base, b'artist [CD5]'), + os.path.join(self.base, b'artist [CD5]', b'CÀT disc 1'), + os.path.join(self.base, b'artist [CD5]', b'CÀt disc 2'), # Single disc album, sorted between CAT discs. - os.path.join(self.base, 'artist [CD5]', 'CATS'), + os.path.join(self.base, b'artist [CD5]', b'CÀTS'), ] self.files = [ - os.path.join(self.base, 'ABCD1234', 'cd 1', 'song1.mp3'), - os.path.join(self.base, 'ABCD1234', 'cd 3 - bonus', 'song2.mp3'), - os.path.join(self.base, 'ABCD1234', 'cd 3 - bonus', 'song3.mp3'), - os.path.join(self.base, 'album', 'cd _ 1', 'song4.mp3'), - os.path.join(self.base, 'artist [CD5]', 'CAT disc 1', 'song5.mp3'), - os.path.join(self.base, 'artist [CD5]', 'CAt disc 2', 'song6.mp3'), - os.path.join(self.base, 'artist [CD5]', 'CATS', 'song7.mp3'), + os.path.join(self.base, b'ABCD1234', b'cd 1', b'song1.mp3'), + os.path.join(self.base, b'ABCD1234', b'cd 3 - bonus', b'song2.mp3'), + os.path.join(self.base, b'ABCD1234', b'cd 3 - bonus', b'song3.mp3'), + os.path.join(self.base, b'album', b'cd _ 1', b'song4.mp3'), + os.path.join(self.base, b'artist [CD5]', b'CÀT disc 1', b'song5.mp3'), + os.path.join(self.base, b'artist [CD5]', b'CÀt disc 2', b'song6.mp3'), + os.path.join(self.base, b'artist [CD5]', b'CÀTS', b'song7.mp3'), ] for path in self.dirs: