Skip to content

Commit 5590c87

Browse files
Merge pull request #43 from Keeper-of-the-Keys/dynamic-cover-art
Modifications that allow dynamic loading of cover art.
2 parents 682760e + 374315b commit 5590c87

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/gpodder/coverart.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,9 @@ def __init__(self, core):
4646

4747
def get_cover(self, podcast, download=False, episode=None):
4848
if episode:
49-
if podcast.download_episode_art == True:
50-
# Get episode art.
51-
filename = episode.art_file
52-
cover_url = episode.episode_art_url
53-
else:
54-
cover_url = None
49+
# Get episode art.
50+
filename = episode.art_file
51+
cover_url = episode.episode_art_url
5552

5653
else:
5754
# Get podcast cover.
@@ -67,7 +64,7 @@ def get_cover(self, podcast, download=False, episode=None):
6764
# Return already existing files
6865
for extension in self.EXTENSIONS:
6966
if os.path.exists(filename + extension):
70-
return filename + extension
67+
return 'file://' + filename + extension
7168

7269
# If allowed to download files, do so here
7370
if download:
@@ -104,8 +101,10 @@ def get_cover(self, podcast, download=False, episode=None):
104101
with open(temp_filename, 'wb') as fp:
105102
fp.write(data)
106103

107-
return filename + extension
104+
return 'file://' + filename + extension
108105
except Exception as e:
109106
logger.warn('Cannot save cover art', exc_info=True)
107+
else:
108+
return cover_url
110109

111110
return None

src/gpodder/model.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,13 @@ def delete_download(self):
271271
if filename is not None:
272272
util.delete_file(filename)
273273

274+
art_filename = self.art_file
275+
if art_filename is not None:
276+
for extension in self.podcast.model.core.cover_downloader.EXTENSIONS:
277+
if os.path.exists(art_filename + extension):
278+
art_filename = art_filename + extension
279+
util.delete_file(art_filename)
280+
274281
self.state = gpodder.STATE_DELETED
275282
self.is_new = False
276283
self.save()
@@ -758,10 +765,6 @@ def _consume_custom_feed(self, custom_feed):
758765
# Add new episodes to episodes
759766
self.episodes.extend(new_episodes)
760767

761-
# Verify that all episode art is up-to-date
762-
for episode in self.episodes:
763-
self.model.core.cover_downloader.get_cover(self, download=True, episode=episode)
764-
765768
# Sort episodes by pubdate, descending
766769
self.episodes.sort(key=lambda e: e.published, reverse=True)
767770

0 commit comments

Comments
 (0)