1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-12 21:22:17 +00:00

scandir for covers too

This commit is contained in:
Alban Féron 2019-06-30 17:32:26 +02:00
parent 007a6e139b
commit 0bb61b6c7d
No known key found for this signature in database
GPG Key ID: 8CE0313646D16165

View File

@ -7,11 +7,13 @@
#
# Distributed under terms of the GNU AGPLv3 license.
import os, os.path
import os.path
import re
from PIL import Image
from .py23 import scandir
EXTENSIONS = (".jpg", ".jpeg", ".png", ".bmp")
NAMING_SCORE_RULES = (
("cover", 5),
@ -67,16 +69,11 @@ def find_cover_in_folder(path, album_name=None):
raise ValueError("Invalid path")
candidates = []
for f in os.listdir(path):
try:
file_path = os.path.join(path, f)
except UnicodeError:
for entry in scandir(path):
if not is_valid_cover(entry.path):
continue
if not is_valid_cover(file_path):
continue
cover = CoverFile(f, album_name)
cover = CoverFile(entry.name, album_name)
candidates.append(cover)
if not candidates: