mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
scandir for covers too
This commit is contained in:
parent
007a6e139b
commit
0bb61b6c7d
@ -7,11 +7,13 @@
|
|||||||
#
|
#
|
||||||
# Distributed under terms of the GNU AGPLv3 license.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
import os, os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
from .py23 import scandir
|
||||||
|
|
||||||
EXTENSIONS = (".jpg", ".jpeg", ".png", ".bmp")
|
EXTENSIONS = (".jpg", ".jpeg", ".png", ".bmp")
|
||||||
NAMING_SCORE_RULES = (
|
NAMING_SCORE_RULES = (
|
||||||
("cover", 5),
|
("cover", 5),
|
||||||
@ -67,16 +69,11 @@ def find_cover_in_folder(path, album_name=None):
|
|||||||
raise ValueError("Invalid path")
|
raise ValueError("Invalid path")
|
||||||
|
|
||||||
candidates = []
|
candidates = []
|
||||||
for f in os.listdir(path):
|
for entry in scandir(path):
|
||||||
try:
|
if not is_valid_cover(entry.path):
|
||||||
file_path = os.path.join(path, f)
|
|
||||||
except UnicodeError:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not is_valid_cover(file_path):
|
cover = CoverFile(entry.name, album_name)
|
||||||
continue
|
|
||||||
|
|
||||||
cover = CoverFile(f, album_name)
|
|
||||||
candidates.append(cover)
|
candidates.append(cover)
|
||||||
|
|
||||||
if not candidates:
|
if not candidates:
|
||||||
|
Loading…
Reference in New Issue
Block a user