Commit 9b967e10 authored by Hermann Krumrey's avatar Hermann Krumrey

Fix issue with music album artist names with relative paths

parent 74a40a14
......@@ -53,7 +53,7 @@ class MusicAlbum(Component):
self.parent_path = parent_path
self.parent_ids = parent_ids
self.artist_name = os.path.basename(os.path.normpath(parent_path))
self.artist_name = os.path.basename(os.path.abspath(parent_path))
self.name = json_data["name"]
self.genre = json_data["genre"]
......
......@@ -127,7 +127,7 @@ class AlbumArtFetchCommand(Command):
img = None
if img is None:
self.logger.warning("Couldn't download cover files")
self.logger.warning("Couldn't download cover file {}".format(dest))
return
with open(tmp_file, "wb") as f:
......@@ -165,17 +165,21 @@ class AlbumArtFetchCommand(Command):
)
urls = []
urlmap = {}
for a in cover_page.find_all("a"):
category = a.text.strip().lower()
if category in ["original", "250px", "500px"]:
urlmap[category] = a["href"]
urlmap = {
"original": [],
"250px": [],
"500px": []
} # type: Dict[str, List[str]]
for art in cover_page.select(".artwork-cont"):
for a in art.find_all("a"):
category = a.text.strip().lower()
if category in ["original", "250px", "500px"]:
urlmap[category].append(a["href"])
for category in ["original", "500px", "250px"]:
href = urlmap.get(category)
if href is not None:
urls.append("https:" + href)
for link in urlmap[category]:
urls.append("https:" + link)
try:
displayed = cover_page.select(".cover-art")[0].find("img")["src"]
......
......@@ -45,6 +45,8 @@ class MusicTagCommand(Command):
:return: None
"""
cls.add_directories_arg(parser)
parser.add_argument("--force-album-art-refresh", action="store_true",
help="Forces an album art refresh")
def execute(self):
"""
......@@ -84,7 +86,8 @@ class MusicTagCommand(Command):
and key != "APIC:Cover":
id3.pop(key)
if "APIC:Cover" not in id3.keys():
if "APIC:Cover" not in id3.keys() or \
self.args.force_album_art_refresh:
with open(cover_file, "rb") as f:
img = f.read()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment