Browse Source

Add method to retrieve the fullpath of the cover file

pull/98/head
Oliverpool 9 years ago
parent
commit
6e1b47ac86
  1. 18
      patacrep/songs/__init__.py

18
patacrep/songs/__init__.py

@ -194,6 +194,24 @@ class Song:
""" """
raise NotImplementedError() raise NotImplementedError()
def get_cover_fullpath(self, default=None):
filename = self.data.get('cov')
if not filename:
return default
dirname = os.path.dirname(self.fullpath)
filepath = os.path.join(dirname, str(filename))
filepath += '.'
extensions = ['jpg', 'png']
for extension in extensions:
if os.path.isfile(filepath + extension):
return filepath + extension
# How to handle when the cover should have been there ?
# raise FileNotFoundError()
return default
def unprefixed_title(title, prefixes): def unprefixed_title(title, prefixes):
"""Remove the first prefix of the list in the beginning of title (if any). """Remove the first prefix of the list in the beginning of title (if any).
""" """

Loading…
Cancel
Save