mirror of
https://github.com/SoongNoonien/mpdevil.git
synced 2023-08-10 21:12:44 +03:00
improved cover fetching
This commit is contained in:
parent
86f439c891
commit
03b34d1c29
@ -230,19 +230,18 @@ class FocusFrame(Gtk.Frame):
|
|||||||
self.style_context.remove_provider(self.provider)
|
self.style_context.remove_provider(self.provider)
|
||||||
|
|
||||||
class Cover(object):
|
class Cover(object):
|
||||||
|
regex=re.compile(r'^\.?(album|cover|folder|front).*\.(gif|jpeg|jpg|png)$', flags=re.IGNORECASE)
|
||||||
def __init__(self, lib_path, song_file):
|
def __init__(self, lib_path, song_file):
|
||||||
self.lib_path=lib_path or "/"
|
self.lib_path=lib_path or "/"
|
||||||
self.path=None
|
self.path=None
|
||||||
if not song_file == None:
|
if not song_file == None:
|
||||||
head_tail=os.path.split(song_file)
|
head, tail=os.path.split(song_file)
|
||||||
if self.lib_path[-1] == "/":
|
song_dir=os.path.join(self.lib_path, head)
|
||||||
path=(self.lib_path+head_tail[0]+"/")
|
if os.path.exists(song_dir):
|
||||||
else:
|
for f in os.listdir(song_dir):
|
||||||
path=(self.lib_path+"/"+head_tail[0]+"/")
|
if self.regex.match(f):
|
||||||
if os.path.exists(path):
|
self.path=os.path.join(song_dir, f)
|
||||||
filelist=[file for file in os.listdir(path) if file.endswith('.jpg') or file.endswith('.png') or file.endswith('.gif')]
|
break
|
||||||
if not filelist == []:
|
|
||||||
self.path=(path+filelist[0])
|
|
||||||
|
|
||||||
def get_pixbuf(self, size):
|
def get_pixbuf(self, size):
|
||||||
if self.path == None:
|
if self.path == None:
|
||||||
|
Loading…
Reference in New Issue
Block a user