use cover.jpg in folder if present

Merge pull request #369 from duarm/master
This commit is contained in:
azlux 2023-07-18 11:14:42 +02:00 committed by GitHub
commit 52b1b18aaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,17 +84,20 @@ class FileItem(BaseItem):
return True return True
def _get_info_from_tag(self): def _get_info_from_tag(self):
match = re.search(r"(.+)\.(.+)", self.uri()) match = re.search(r"(.+)\/(.+)\.(.+)", self.uri())
assert match is not None assert match is not None
file_no_ext = match[1] file_path = match[1] + '/'
ext = match[2] file_name = match[2]
ext = match[3]
try: try:
im = None im = None
path_thumbnail = file_no_ext + ".jpg" path_thumbnail = file_path + file_name + ".jpg"
if os.path.isfile(path_thumbnail): if os.path.isfile(path_thumbnail):
im = Image.open(path_thumbnail) im = Image.open(path_thumbnail)
elif os.path.isfile(file_path + "cover.jpg"):
im = Image.open(file_path + "cover.jpg")
if ext == "mp3": if ext == "mp3":
# title: TIT2 # title: TIT2
@ -159,7 +162,7 @@ class FileItem(BaseItem):
pass pass
if not self.title: if not self.title:
self.title = os.path.basename(file_no_ext) self.title = os.path.basename(file_path + file_name)
@staticmethod @staticmethod
def _prepare_thumbnail(im): def _prepare_thumbnail(im):