Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
use cover.jpg in folder if present
Browse files Browse the repository at this point in the history
  • Loading branch information
duarm committed Jul 17, 2023
1 parent 9f032c3 commit 07ac401
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions media/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,20 @@ def validate(self):
return True

def _get_info_from_tag(self):
match = re.search(r"(.+)\.(.+)", self.uri())
match = re.search(r"(.+)\/(.+)\.(.+)", self.uri())
assert match is not None

file_no_ext = match[1]
ext = match[2]
file_path = match[1] + '/'
file_name = match[2]
ext = match[3]

try:
im = None
path_thumbnail = file_no_ext + ".jpg"
path_thumbnail = file_path + file_name + ".jpg"
if os.path.isfile(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":
# title: TIT2
Expand Down Expand Up @@ -159,7 +162,7 @@ def _get_info_from_tag(self):
pass

if not self.title:
self.title = os.path.basename(file_no_ext)
self.title = os.path.basename(file_path + file_name)

@staticmethod
def _prepare_thumbnail(im):
Expand Down

0 comments on commit 07ac401

Please sign in to comment.