mirror of
https://github.com/SoongNoonien/mpdevil.git
synced 2023-08-10 21:12:44 +03:00
fixed cover loading error when no music dir is specified
This commit is contained in:
43
bin/mpdevil
43
bin/mpdevil
@ -1394,28 +1394,27 @@ class Cover(object):
|
|||||||
lib_path=settings.get_value("paths")[active_profile]
|
lib_path=settings.get_value("paths")[active_profile]
|
||||||
if lib_path == "":
|
if lib_path == "":
|
||||||
lib_path=GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_MUSIC)
|
lib_path=GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_MUSIC)
|
||||||
regex_str=settings.get_value("regex")[active_profile]
|
if lib_path is not None:
|
||||||
|
regex_str=settings.get_value("regex")[active_profile]
|
||||||
if regex_str == "":
|
if regex_str == "":
|
||||||
regex=re.compile(COVER_REGEX, flags=re.IGNORECASE)
|
regex=re.compile(COVER_REGEX, flags=re.IGNORECASE)
|
||||||
else:
|
else:
|
||||||
regex_str=regex_str.replace("%AlbumArtist%", song.get("albumartist", ""))
|
regex_str=regex_str.replace("%AlbumArtist%", song.get("albumartist", ""))
|
||||||
regex_str=regex_str.replace("%Album%", song.get("album", ""))
|
regex_str=regex_str.replace("%Album%", song.get("album", ""))
|
||||||
try:
|
try:
|
||||||
regex=re.compile(regex_str, flags=re.IGNORECASE)
|
regex=re.compile(regex_str, flags=re.IGNORECASE)
|
||||||
except:
|
except:
|
||||||
print("illegal regex:", regex_str)
|
print("illegal regex:", regex_str)
|
||||||
return
|
return
|
||||||
|
if song_file is not None:
|
||||||
if song_file is not None:
|
song_dir=os.path.join(lib_path, os.path.dirname(song_file))
|
||||||
song_dir=os.path.join(lib_path, os.path.dirname(song_file))
|
if song_dir.endswith(".cue"):
|
||||||
if song_dir.endswith(".cue"):
|
song_dir=os.path.dirname(song_dir) # get actual directory of .cue file
|
||||||
song_dir=os.path.dirname(song_dir) # get actual directory of .cue file
|
if os.path.exists(song_dir):
|
||||||
if os.path.exists(song_dir):
|
for f in os.listdir(song_dir):
|
||||||
for f in os.listdir(song_dir):
|
if regex.match(f):
|
||||||
if regex.match(f):
|
self.path=os.path.join(song_dir, f)
|
||||||
self.path=os.path.join(song_dir, f)
|
break
|
||||||
break
|
|
||||||
|
|
||||||
def get_pixbuf(self, size):
|
def get_pixbuf(self, size):
|
||||||
if self.path is None: # fallback needed
|
if self.path is None: # fallback needed
|
||||||
|
Reference in New Issue
Block a user